]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/vfs/vfs.c
libatal/vfs: stats a path before checking if it is a directory
[netatalk.git] / libatalk / vfs / vfs.c
index 8570497656ae0c6e9d957145336909e6d0e88b33..a349cfe8cd4c63b1e6137f1400073ae33b4664c3 100644 (file)
@@ -170,7 +170,6 @@ static int RF_setfilmode_adouble(VFS_FUNC_ARGS_SETFILEMODE)
 static int RF_setdirunixmode_adouble(VFS_FUNC_ARGS_SETDIRUNIXMODE)
 {
     const char *adouble = vol->ad_path(name, ADFLAGS_DIR );
-    int  dropbox = vol->v_flags;
 
     if (dir_rx_set(mode)) {
         if (chmod_acl(ad_dir(adouble), (DIRBITS | mode) & ~vol->v_umask) < 0 ) 
@@ -208,7 +207,6 @@ static int setdirmode_adouble_loop(const struct vol *vol, struct dirent *de _U_,
 
 static int RF_setdirmode_adouble(VFS_FUNC_ARGS_SETDIRMODE)
 {
-    int   dropbox = vol->v_flags;
     mode_t hf_mode = ad_hf_mode(mode);
     const char  *adouble = vol->ad_path(name, ADFLAGS_DIR );
     const char  *adouble_p = ad_dir(adouble);
@@ -218,7 +216,7 @@ static int RF_setdirmode_adouble(VFS_FUNC_ARGS_SETDIRMODE)
             return -1;
     }
 
-    if (for_each_adouble("setdirmode", adouble_p, setdirmode_adouble_loop, &hf_mode, 0, vol->v_umask))
+    if (for_each_adouble("setdirmode", adouble_p, setdirmode_adouble_loop, vol, &hf_mode, 0))
         return -1;
 
     if (!dir_rx_set(mode)) {
@@ -410,6 +408,9 @@ static int RF_posix_acl(VFS_FUNC_ARGS_ACL)
     struct stat st;
     int len;
 
+    if (stat(path, &st) == -1)
+        EC_FAIL;
+
     if (S_ISDIR(st.st_mode)) {
         len = snprintf(buf, MAXPATHLEN, "%s/.AppleDouble",path);
         if (len < 0 || len >=  MAXPATHLEN)
@@ -487,7 +488,7 @@ static int RF_renamedir_ea(VFS_FUNC_ARGS_RENAMEDIR)
 }
 
 /* Returns 1 if the entry is NOT an ._ file */
-static int deletecurdir_ea_osx_chkifempty_loop(struct dirent *de, char *name, void *data _U_, int flag _U_, mode_t v_umask _U_)
+static int deletecurdir_ea_osx_chkifempty_loop(const struct vol *vol, struct dirent *de, char *name, void *data _U_, int flag _U_)
 {
     if (de->d_name[0] != '.' || de->d_name[0] == '_')
         return 1;
@@ -495,7 +496,7 @@ static int deletecurdir_ea_osx_chkifempty_loop(struct dirent *de, char *name, vo
     return 0;
 }
 
-static int deletecurdir_ea_osx_loop(struct dirent *de, char *name, void *data _U_, int flag _U_, mode_t v_umask _U_)
+static int deletecurdir_ea_osx_loop(const struct vol *vol, struct dirent *de, char *name, void *data _U_, int flag _U_)
 {
     int ret;
     
@@ -515,7 +516,7 @@ static int RF_deletecurdir_ea(VFS_FUNC_ARGS_DELETECURDIR)
     /* first check if there's really no other file besides files starting with ._ */
     if ((err = for_each_adouble("deletecurdir_ea_osx", ".",
                                 deletecurdir_ea_osx_chkifempty_loop,
-                                NULL, 0, 0)) != 0) {
+                                vol, NULL, 0)) != 0) {
         if (err == 1)
             return AFPERR_DIRNEMPT;
         return AFPERR_MISC;
@@ -524,7 +525,7 @@ static int RF_deletecurdir_ea(VFS_FUNC_ARGS_DELETECURDIR)
     /* Now delete orphaned ._ files */
     if ((err = for_each_adouble("deletecurdir_ea_osx", ".",
                                 deletecurdir_ea_osx_loop,
-                                NULL, 0, 0)) != 0)
+                                vol, NULL, 0)) != 0)
         return err;
 
 #endif
@@ -542,7 +543,7 @@ static int RF_setdirunixmode_ea(VFS_FUNC_ARGS_SETDIRUNIXMODE)
 static int RF_setfilmode_ea(VFS_FUNC_ARGS_SETFILEMODE)
 {
 #ifndef HAVE_EAFD
-    return adouble_setfilmode(vol->ad_path(name, ADFLAGS_HF ), mode, st, vol->v_umask);
+    return adouble_setfilmode(vol, vol->ad_path(name, ADFLAGS_HF ), mode, st);
 #endif
     return 0;
 }