From: franklahm Date: Sun, 11 Apr 2010 07:01:23 +0000 (+0000) Subject: New dbd cleanup option -c X-Git-Tag: netatalk-2-1~20 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=0c42bd5e13947f9a5b12c2ae234bfeedb128a654 New dbd cleanup option -c --- diff --git a/NEWS b/NEWS index 027ef145..e0d1f6ed 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ Changes in 2.1-release * NEW: afpd: new volume option "volsizelimit" for limitting reported volume size. Useful for limitting TM backup size. +* UPD: dbd: -c option for rebuilding volumes which prevents the creation + of .AppleDouble stuff, only removes orphaned files. Changes in 2.1-beta2 ==================== diff --git a/etc/cnid_dbd/cmd_dbd.c b/etc/cnid_dbd/cmd_dbd.c index aa2930aa..6ce3e23a 100644 --- a/etc/cnid_dbd/cmd_dbd.c +++ b/etc/cnid_dbd/cmd_dbd.c @@ -1,5 +1,5 @@ /* - $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 @@ -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 \n" + printf("Usage: dbd [-e|-v|-x] -d [-i] | -s [-n]| -r [-c|-f] | -u \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,7 @@ 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: -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 +254,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: -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" @@ -287,8 +288,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 +304,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; diff --git a/etc/cnid_dbd/cmd_dbd.h b/etc/cnid_dbd/cmd_dbd.h index e2364054..a1d51b67 100644 --- a/etc/cnid_dbd/cmd_dbd.h +++ b/etc/cnid_dbd/cmd_dbd.h @@ -13,6 +13,7 @@ typedef unsigned int dbd_flags_t; #define DBD_FLAGS_SCAN (1 << 0) #define DBD_FLAGS_FORCE (1 << 1) #define DBD_FLAGS_EXCL (1 << 2) +#define DBD_FLAGS_CLEANUP (1 << 3) /* Dont create AD stuff, but cleanup orphaned */ #define ADv2_DIRNAME ".AppleDouble" diff --git a/etc/cnid_dbd/cmd_dbd_scanvol.c b/etc/cnid_dbd/cmd_dbd_scanvol.c index be0aaf9c..d94c2224 100644 --- a/etc/cnid_dbd/cmd_dbd_scanvol.c +++ b/etc/cnid_dbd/cmd_dbd_scanvol.c @@ -1,5 +1,5 @@ /* - $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 @@ -280,6 +280,9 @@ static int check_adfile(const char *fname, const struct stat *st) struct adouble ad; char *adname; + if (dbd_flags & DBD_FLAGS_CLEANUP) + return 0; + if (S_ISREG(st->st_mode)) adflags = 0; else @@ -388,8 +391,7 @@ static int check_eafiles(const char *fname) 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; @@ -439,6 +441,9 @@ static int check_addir(int volroot) 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) { @@ -657,6 +662,10 @@ static cnid_t check_cnid(const char *name, cnid_t did, struct stat *st, int adfi 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; } diff --git a/man/man1/dbd.1 b/man/man1/dbd.1 index 819ec9be..185ba5aa 100644 --- a/man/man1/dbd.1 +++ b/man/man1/dbd.1 @@ -22,7 +22,7 @@ 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 @@ -236,6 +236,9 @@ Open and close adouble files .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