]> arthur.barton.de Git - netatalk.git/commitdiff
dbd: remove orphaned ._ AppleDouble files. Bug #549.
authorRalph Boehme <rb@sernet.de>
Thu, 13 Feb 2014 11:28:44 +0000 (12:28 +0100)
committerRalph Boehme <rb@sernet.de>
Thu, 13 Feb 2014 11:33:39 +0000 (12:33 +0100)
NEWS
etc/cnid_dbd/cmd_dbd_scanvol.c

diff --git a/NEWS b/NEWS
index 1f7aa7dc5d5e60b0e8fd5baf5ba04808c30a7d65..162ea29d69baf7c9a1f654eb1a4fff3001099d9a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Changes in 3.1.1
 * FIX: Registering with mDNS crashed. Bug #540
 * FIX: Saving from applications like Photoshop may fail, because
        removing the ressource fork AppleDouble file failed. Bug #542.
+* FIX: dbd: remove orphaned ._ AppleDouble files. Bug #549.
 
 Changes in 3.1.0
 ================
index b9fbf3e88ac4d63bea0766caa4fef714b522ffee..ba1cd623e0b54dd778ccf2b5a80cdfc3df0a72d4 100644 (file)
@@ -610,6 +610,22 @@ static cnid_t check_cnid(const char *name, cnid_t did, struct stat *st, int adfi
     return db_cnid;
 }
 
+static void check_orphaned(const char *name)
+{
+    int rc;
+    struct stat sb;
+
+    if (strlen(name) < 3)
+        return;
+
+    rc = lstat(&name[2], &sb);
+
+    if (rc != 0 && errno == ENOENT) {
+        dbd_log(LOGSTD, "Removing orphaned AppleDouble \"%s/%s\"", cwdbuf, name);
+        unlink(name);
+    }
+}
+
 /*
   This is called recursively for all dirs.
   volroot=1 means we're in the volume root dir, 0 means we aren't.
@@ -717,6 +733,15 @@ static int dbd_readdir(int volroot, cnid_t did)
            Tests
         **************************************************************************/
 
+        /* Check for invalid names and orphaned ._ files */
+        if (S_ISREG(st.st_mode) && (strncmp(ep->d_name, "._", strlen("._")) == 0))
+            check_orphaned(ep->d_name);
+
+        if (!vol->vfs->vfs_validupath(vol, ep->d_name)) {
+            dbd_log(LOGSTD, "Ignoring \"%s/%s\"", cwdbuf, ep->d_name);
+            continue;
+        }
+
         /* Check for appledouble file, create if missing, but only if we have addir */
         const char *name = NULL;
         adfile_ok = -1;