/*
- $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>
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,
"",
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"
" 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"
" 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"
/* 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;
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;
}
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));
/* 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) {