]> arthur.barton.de Git - netatalk.git/blobdiff - etc/cnid_dbd/cmd_dbd.c
usage of dbd cleanup option -c
[netatalk.git] / etc / cnid_dbd / cmd_dbd.c
index 78e5cd4763493312c741f8068bca091d7529a136..dc4c3923d90eeb1a0e47c3c24bb4b4df32d4333f 100644 (file)
@@ -1,5 +1,5 @@
 /* 
-   $Id: cmd_dbd.c,v 1.21 2009-12-21 06:41:09 franklahm Exp $
+   $Id: cmd_dbd.c,v 1.26 2010-04-20 16:46:20 hat001 Exp $
 
    Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
    
@@ -91,7 +91,7 @@ static int exclusive;           /* Exclusive volume access */
 static struct db_param db_param = {
     NULL,                       /* Volume dirpath */
     1,                          /* bdb logfile autoremove */
-    64 * 1024 * 1024,           /* bdb cachesize */
+    64 * 1024,                  /* bdb cachesize (64 MB) */
     -1,                         /* not used ... */
     -1,
     "",
@@ -229,12 +229,12 @@ static void free_lock(int lockfd)
 
 static void usage (void)
 {
-    printf("Usage: dbd [-e|-v|-x] -d [-i] | -s [-n]| -r [-f] | -u <path to netatalk volume>\n"
+    printf("Usage: dbd [-e|-v|-x] -d [-i] | -s [-c|-n]| -r [-c|-f] | -u <path to netatalk volume>\n"
            "dbd can dump, scan, reindex and rebuild Netatalk dbd CNID databases.\n"
            "dbd must be run with appropiate permissions i.e. as root.\n\n"
            "Main commands are:\n"
            "   -d Dump CNID database\n"
-           "      Option: -i dump indexes too\n"
+           "      Option: -i dump indexes too\n\n"
            "   -s Scan volume:\n"
            "      1. Compare CNIDs in database with volume\n"
            "      2. Check if .AppleDouble dirs exist\n"
@@ -244,7 +244,8 @@ static void usage (void)
            "      6. Check name encoding by roundtripping, log on error\n"
            "      7. Check for orphaned CNIDs in database (requires -e)\n"
            "      8. Open and close adouble files\n"
-           "      Option: -n Don't open CNID database, skip CNID checks\n"
+           "      Options: -c Don't check .AppleDouble stuff, only ckeck orphaned.\n"
+           "               -n Don't open CNID database, skip CNID checks\n\n"
            "   -r Rebuild volume:\n"
            "      1. Sync CNIDSs in database with volume\n"
            "      2. Make sure .AppleDouble dir exist, create if missing\n"
@@ -254,8 +255,9 @@ static void usage (void)
            "      6. Check name encoding by roundtripping, log on error\n"
            "      7. Check for orphaned CNIDs in database (requires -e)\n"
            "      8. Open and close adouble files\n"
-           "      Option: -f wipe database and rebuild from IDs stored in AppleDouble files,\n"
-           "                 only available for volumes without 'nocnidcache' option. Implies -e.\n"
+           "      Options: -c Don't create .AppleDouble stuff, only cleanup orphaned.\n"
+           "               -f wipe database and rebuild from IDs stored in AppleDouble files,\n"
+           "                  only available for volumes without 'nocnidcache' option. Implies -e.\n\n"
            "   -u Prepare upgrade:\n"
            "      Before installing an upgraded version of Netatalk that is linked against\n"
            "      a newer BerkeleyDB lib, run `dbd -u ...` from the OLD Netatalk pior to\n"
@@ -287,8 +289,11 @@ int main(int argc, char **argv)
     /* Inhereting perms in ad_mkdir etc requires this */
     ad_setfuid(0);
 
-    while ((c = getopt(argc, argv, ":dsnruvxife")) != -1) {
+    while ((c = getopt(argc, argv, ":cdefinrsuvx")) != -1) {
         switch(c) {
+        case 'c':
+            flags |= DBD_FLAGS_CLEANUP;
+            break;
         case 'd':
             dump = 1;
             break;
@@ -300,7 +305,7 @@ int main(int argc, char **argv)
             flags |= DBD_FLAGS_SCAN;
             break;
         case 'n':
-            nocniddb = 1;
+            nocniddb = 1; /* FIXME: this could/should be a flag too for consistency */
             break;
         case 'r':
             rebuild = 1;
@@ -342,6 +347,8 @@ int main(int argc, char **argv)
     }
     volpath = argv[optind];
 
+    setvbuf(stdout, (char *) NULL, _IONBF, 0);
+
     /* Remember cwd */
     if ((cdir = open(".", O_RDONLY)) < 0) {
         dbd_log( LOGSTD, "Can't open dir: %s", strerror(errno));
@@ -353,9 +360,9 @@ int main(int argc, char **argv)
 
     /* Setup logging. Should be portable among *NIXes */
     if (!verbose)
-        setuplog("console log_info /dev/tty");
+        setuplog("default log_info /dev/tty");
     else
-        setuplog("console log_debug /dev/tty");
+        setuplog("default log_debug /dev/tty");
 
     /* Load .volinfo file */
     if (loadvolinfo(volpath, &volinfo) == -1) {