From 564ead6bf656f97db24f0abb624435736e62e4aa Mon Sep 17 00:00:00 2001 From: didg Date: Fri, 6 Nov 2009 03:51:54 +0000 Subject: [PATCH] small optimization, in of_stat '../' is never modified --- etc/afpd/ofork.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/etc/afpd/ofork.c b/etc/afpd/ofork.c index fd269e78..90bf4ff6 100644 --- a/etc/afpd/ofork.c +++ b/etc/afpd/ofork.c @@ -1,5 +1,5 @@ /* - * $Id: ofork.c,v 1.28 2009-10-13 22:55:37 didg Exp $ + * $Id: ofork.c,v 1.29 2009-11-06 03:51:54 didg Exp $ * * Copyright (c) 1996 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -290,10 +290,14 @@ int ret; return ret; } -/* -------------------------- */ +/* -------------------------- + stat the current directory. + stat(".") works even if "." is deleted thus + we have to stat ../name because we want to know if it's there +*/ int of_statdir (const struct vol *vol, struct path *path) { -static char pathname[ MAXPATHLEN + 1]; +static char pathname[ MAXPATHLEN + 1] = "../"; int ret; if (*path->m_name) { @@ -303,8 +307,7 @@ int ret; path->st_errno = 0; path->st_valid = 1; /* FIXME, what about: we don't have r-x perm anymore ? */ - strcpy(pathname, "../"); - strlcat(pathname, path->d_dir->d_u_name, MAXPATHLEN); + strlcpy(pathname +3, path->d_dir->d_u_name, sizeof (pathname) -3); if (!(ret = stat(pathname, &path->st))) return 0; -- 2.39.2