From: Ralph Boehme Date: Thu, 13 Feb 2014 11:28:44 +0000 (+0100) Subject: dbd: remove orphaned ._ AppleDouble files. Bug #549. X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=e421da9fdfa2026757b60277a83614fe4a7db2ab;hp=61b71601b2afd2bda64485fa71117c8aa5fd7380 dbd: remove orphaned ._ AppleDouble files. Bug #549. --- diff --git a/NEWS b/NEWS index 1f7aa7dc..162ea29d 100644 --- 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 ================ diff --git a/etc/cnid_dbd/cmd_dbd_scanvol.c b/etc/cnid_dbd/cmd_dbd_scanvol.c index b9fbf3e8..ba1cd623 100644 --- a/etc/cnid_dbd/cmd_dbd_scanvol.c +++ b/etc/cnid_dbd/cmd_dbd_scanvol.c @@ -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;