/*
- $Id: cmd_dbd.c,v 1.24 2009-12-21 17:00:17 franklahm Exp $
+ $Id: cmd_dbd.c,v 1.25 2010-04-11 07:01:23 franklahm Exp $
Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
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 [-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: -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: -f wipe database and rebuild from IDs stored in AppleDouble files,\n"
+ " only available for volumes without 'nocnidcache' option. Implies -e.\n"
+ " -c Dont create .AppleDouble stuff, only cleanup orphaned.\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;
/*
- $Id: cmd_dbd_scanvol.c,v 1.20 2010-02-15 13:58:38 franklahm Exp $
+ $Id: cmd_dbd_scanvol.c,v 1.21 2010-04-11 07:01:23 franklahm Exp $
Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
struct adouble ad;
char *adname;
+ if (dbd_flags & DBD_FLAGS_CLEANUP)
+ return 0;
+
if (S_ISREG(st->st_mode))
adflags = 0;
else
if ((ret = ea_open(&volume, fname, EA_RDWR, &ea)) != 0) {
if (errno == ENOENT)
return 0;
- dbd_log(LOGSTD, "Error calling ea_open for file: %s/%s, removing EA files",
- cwdbuf, fname);
+ dbd_log(LOGSTD, "Error calling ea_open for file: %s/%s, removing EA files", cwdbuf, fname);
if ( ! (dbd_flags & DBD_FLAGS_SCAN))
remove_eafiles(fname, &ea);
return -1;
struct adouble ad;
char *mname = NULL;
+ if (dbd_flags & DBD_FLAGS_CLEANUP)
+ return 0;
+
/* Check for ad-dir */
if ( (addir_ok = access(ADv2_DIRNAME, F_OK)) != 0) {
if (errno != ENOENT) {
if ( (volinfo->v_flags & AFPVOL_CACHE) && ADFILE_OK) {
ad_init(&ad, volinfo->v_adouble, volinfo->v_ad_options);
if (ad_open_metadata( name, adflags, O_RDWR, &ad) != 0) {
+
+ if (dbd_flags & DBD_FLAGS_CLEANUP)
+ return 0;
+
dbd_log( LOGSTD, "Error opening AppleDouble file for '%s/%s': %s", cwdbuf, name, strerror(errno));
return 0;
}
dbd \- CNID database maintanance
.SH "SYNOPSIS"
.HP \w'\fBdbd\fR\fB\fR\ 'u
-\fBdbd\fR\fB\fR [\-evx] {\-d\ [\-i] | \-s\ [n] | \-r\ [\-f] | \-u} \fIvolumepath\fR
+\fBdbd\fR\fB\fR [\-evx] {\-d\ [\-i] | \-s\ [n] | \-r\ [\-c|\-f] | \-u} \fIvolumepath\fR
.SH "DESCRIPTION"
.PP
\fBdbd\fR
.PP
Options:
.RS 4
+\fB\-c\fR
+Dont create \&.AppleDouble stuff, only cleanup orphaned\&.
+
\fB\-f\fR
Wipe database and rebuild from IDs stored in AppleDouble files, only available for volumes without
\fBnocnidcache\fR