]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/ofork.c
Merge symlink branch
[netatalk.git] / etc / afpd / ofork.c
index fd269e78d9bd924d85053938807e17bcb2c9129b..d9c4f31e8e5b0d2685b740a9cddf0dc6a8303fa7 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ofork.c,v 1.28 2009-10-13 22:55:37 didg Exp $
+ * $Id: ofork.c,v 1.31 2010-02-10 14:05:37 franklahm Exp $
  *
  * Copyright (c) 1996 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -285,15 +285,19 @@ int of_stat  (struct path *path)
 int ret;
     path->st_errno = 0;
     path->st_valid = 1;
-    if ((ret = stat(path->u_name, &path->st)) < 0)
+    if ((ret = lstat(path->u_name, &path->st)) < 0)
        path->st_errno = errno;
    return ret;
 }
 
-/* -------------------------- */
-int of_statdir  (const struct vol *vol, struct path *path)
+/* -------------------------- 
+   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  (struct vol *vol, struct path *path)
 {
-static char pathname[ MAXPATHLEN + 1];
+static char pathname[ MAXPATHLEN + 1] = "../";
 int ret;
 
     if (*path->m_name) {
@@ -303,10 +307,9 @@ 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)))
+    if (!(ret = lstat(pathname, &path->st)))
         return 0;
         
     path->st_errno = errno;
@@ -315,7 +318,7 @@ int ret;
        if (movecwd(vol, curdir->d_parent)) 
            return -1;
        path->st_errno = 0;
-       if ((ret = stat(path->d_dir->d_u_name, &path->st)) < 0) 
+       if ((ret = lstat(path->d_dir->d_u_name, &path->st)) < 0) 
            path->st_errno = errno;
     }
     return ret;