/*
- $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>
" -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"
);
}
break;
case 'f':
force = 1;
+ exclusive = 1;
flags |= DBD_FLAGS_FORCE | DBD_FLAGS_EXCL;
break;
case ':':
/* 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.");
}
/*
/*
- $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>
}
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);
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);
} 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);
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);