]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/extattrs.c
only call stat(path) if it's not done in cname
[netatalk.git] / etc / afpd / extattrs.c
index b198f7718d4a7050a4a179378129188f78bd4505..3e758cf2a8c3c913a2a557a0677fdc08698d17b9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  $Id: extattrs.c,v 1.15 2009-10-28 01:52:49 didg Exp $
+  $Id: extattrs.c,v 1.17 2009-10-29 10:27:45 didg Exp $
   Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
@@ -21,8 +21,6 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
 
 #include <atalk/adouble.h>
 #include <atalk/vfs.h>
@@ -80,7 +78,7 @@ int afp_listextattr(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, siz
     struct vol          *vol;
     struct dir          *dir;
     struct path         *s_path;
-    struct stat         st;
+    struct stat         *st;
     struct adouble      ad, *adp = NULL;
     struct ofork        *of;
     char                *uname, *FinderInfo;
@@ -134,9 +132,17 @@ int afp_listextattr(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, siz
             LOG(log_error, logtype_afpd, "afp_listextattr: cname error: %s", strerror(errno));
             return AFPERR_NOOBJ;
         }
-        uname = s_path->u_name;
 
-        /*
+        st   = &s_path->st;
+        if (!s_path->st_valid) {
+            /* it's a dir in our cache, we didn't stat it, do it now */
+            of_statdir(vol, s_path);
+        }
+        if ( s_path->st_errno != 0 ) {
+            return( AFPERR_NOOBJ );
+        }
+
+        uname = s_path->u_name;        /*
           We have to check the FinderInfo for the file, because if they aren't all 0
           we must return the synthetic attribute "com.apple.FinderInfo".
           Note: the client will never (never seen in traces) request that attribute
@@ -149,8 +155,7 @@ int afp_listextattr(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf, siz
             adp = &ad;
         }
 
-        stat(uname, &st);
-        if (S_ISDIR(st.st_mode))
+        if (S_ISDIR(st->st_mode))
             adflags = ADFLAGS_DIR;
 
         if ( ad_metadata( uname, adflags, adp) < 0 ) {