]> arthur.barton.de Git - netatalk.git/commitdiff
Fixes
authorfranklahm <franklahm>
Mon, 25 May 2009 13:52:14 +0000 (13:52 +0000)
committerfranklahm <franklahm>
Mon, 25 May 2009 13:52:14 +0000 (13:52 +0000)
etc/cnid_dbd/cmd_dbd.c
etc/cnid_dbd/cmd_dbd_scanvol.c

index db290c1a63fc1aca0723b36323f51204db291e86..a6b907b57969866d254fe8e71983a328d890645e 100644 (file)
@@ -1,5 +1,5 @@
 /* 
-   $Id: cmd_dbd.c,v 1.3 2009-05-22 20:48:44 franklahm Exp $
+   $Id: cmd_dbd.c,v 1.4 2009-05-25 13:52:14 franklahm Exp $
 
    Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
    
@@ -234,26 +234,31 @@ static void usage ()
            "   -d Dump CNID database\n"
            "      Option: -i dump indexes too\n"
            "   -s Scan volume:\n"
-           "      1. Compare database with volume\n"
+           "      1. Compare CNIDs in database with volume\n"
            "      2. Check if .AppleDouble dirs exist\n"
            "      3. Check if  AppleDouble file exist\n"
            "      4. Report orphaned AppleDouble files\n"
            "      5. Check for directories inside AppleDouble directories\n"
            "      6. Check name encoding by roundtripping, log on error\n"
+           "      7. Check for orphaned CNIDs in database (requires -e)\n"
            "   -r Rebuild volume:\n"
-           "      1. Sync database with volume\n"
+           "      1. Sync CNIDSs in database with volume\n"
            "      2. Make sure .AppleDouble dir exist, create if missing\n"
            "      3. Make sure AppleDouble file exists, create if missing\n"
            "      4. Delete orphaned AppleDouble files\n"
            "      5. Check for directories inside AppleDouble directories\n"
            "      6. Check name encoding by roundtripping, log on error\n"
+           "      7. Check for orphaned CNIDs in database (requires -e)\n"
            "      Option: -f wipe database and rebuild from IDs stored in AppleDouble files,\n"
-           "                 only available for volumes with 'cachecnid' option.\n"
-           "                 Implies -e."
+           "                 only available for volumes with 'cachecnid' option. Implies -e.\n"
            "General options:\n"
            "   -e only work on inactive volumes and lock them (exclusive)\n"
            "   -x rebuild indexes (just for completeness, mostly useless!)\n"
-           "   -v verbose\n"
+           "   -v verbose\n\n"
+           "WARNING:\n"
+           "If you want/need to run an -r -f rebuild after adding 'cachecnid' to a volume configuration,\n"
+           "you must run a rebuild with -r alone at first in order to sync all existing CNIDs from the db\n"
+           "to the AppleDouble files!\n"
         );
 }
 
@@ -297,6 +302,7 @@ int main(int argc, char **argv)
             break;
         case 'f':
             force = 1;
+            exclusive = 1;
             flags |= DBD_FLAGS_FORCE | DBD_FLAGS_EXCL;
             break;
         case ':':
@@ -362,10 +368,10 @@ int main(int argc, char **argv)
     /* Check if -f is requested and wipe db if yes */
     if ((flags & DBD_FLAGS_FORCE) && (volinfo.v_flags & AFPVOL_CACHE)) {
         char cmd[8 + MAXPATHLEN];
-        snprintf(cmd, 8 + MAXPATHLEN, "rm -f %s/cnid2.db", dbpath);
-        dbd_log( LOGSTD, "Removing old database of volume: '%s'", volpath);
+        snprintf(cmd, 8 + MAXPATHLEN, "rm -f %s/*", dbpath);
+        dbd_log( LOGDEBUG, "Removing old database of volume: '%s'", volpath);
         system(cmd);
-        dbd_log( LOGSTD, "Removed old database.");
+        dbd_log( LOGDEBUG, "Removed old database.");
     }
 
     /* 
index 5da4527bcc5666fd8a6f5e8c0eda1bb643415b84..2f54fa805fcad87abda8c6a7b5228bdc28c00f3c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  $Id: cmd_dbd_scanvol.c,v 1.5 2009-05-23 06:28:27 franklahm Exp $
+  $Id: cmd_dbd_scanvol.c,v 1.6 2009-05-25 13:52:14 franklahm Exp $
 
   Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
 
@@ -413,6 +413,7 @@ static cnid_t check_cnid(const char *name, cnid_t did, struct stat *st, int adfi
         }
         else
             ad_cnid = ad_getid(&ad, st->st_dev, st->st_ino, did, stamp);            
+
         if (ad_cnid == 0)
             dbd_log( LOGSTD, "Incorrect CNID data in .AppleDouble data for '%s/%s' (bad stamp?)", cwdbuf, name);
 
@@ -438,7 +439,8 @@ static cnid_t check_cnid(const char *name, cnid_t did, struct stat *st, int adfi
     if (rply.result == CNID_DBD_RES_OK) {
         db_cnid = rply.cnid;
     } else if (rply.result == CNID_DBD_RES_NOTFOUND) {
-        dbd_log( LOGSTD, "No CNID for '%s/%s' in database", cwdbuf, name);
+        if ( ! (dbd_flags & DBD_FLAGS_FORCE))
+            dbd_log( LOGSTD, "No CNID for '%s/%s' in database", cwdbuf, name);
         db_cnid = 0;
     } else {
         dbd_log( LOGSTD, "Fatal error resolving '%s/%s'", cwdbuf, name);
@@ -468,7 +470,7 @@ static cnid_t check_cnid(const char *name, cnid_t did, struct stat *st, int adfi
     } else if (ad_cnid && (db_cnid == 0)) {
         /* in ad-file but not in db */
         if ( ! (dbd_flags & DBD_FLAGS_SCAN)) {
-            dbd_log( LOGSTD, "CNID rebuild add for '%s/%s', adding with CNID from ad-file: %u", cwdbuf, name, ntohl(ad_cnid));
+            dbd_log( LOGDEBUG, "CNID rebuild add for '%s/%s', adding with CNID from ad-file: %u", cwdbuf, name, ntohl(ad_cnid));
             rqst.cnid = ad_cnid;
             ret = dbd_delete(dbd, &rqst, &rply);
             dbif_txn_close(dbd, ret);
@@ -784,7 +786,7 @@ int cmd_dbd_scanvol(DBD *dbd_ref, struct volinfo *volinfo, dbd_flags_t flags)
     if ( (scanvol(volinfo, flags)) != 0)
         return -1;
 
-    /* We can only do this in excluse mode, otherwise we might delete CNIDs added from
+    /* We can only do this in exclusive mode, otherwise we might delete CNIDs added from
        other clients in between our pass 1 and 2 */
     if (flags & DBD_FLAGS_EXCL)
         delete_orphaned_cnids(dbd, dbd_rebuild, flags);