Changes in 2.2.1
================
-* FIX: cnid_dbd: increase BerkeleyDB locks and lockobjs
* FIX: afpd: increase BerkeleyDB locks and lockobjs
+* FIX: cnid_dbd: increase BerkeleyDB locks and lockobjs
+* FIX: cnid_dbd: implement -d option, deletes CNID db
* FIX: suse: initscript return better status
* FIX: Sourcecode distribution: add missing headers
* FIX: Solaris 10: missing dirfd replacement function
sprintf(buf2, "%i", rqstfd);
if (up->count == MAXSPAWN) {
- /* there's a pb with the db inform child
- * it will run recover, delete the db whatever
- */
- LOG(log_error, logtype_cnid, "try with -d %s", up->volinfo->v_path);
+ /* there's a pb with the db inform child, it will delete the db */
+ LOG(log_warning, logtype_cnid,
+ "Multiple attempts to start CNID db daemon for \"%s\" failed, wiping the slate clean...",
+ up->volinfo->v_path);
ret = execlp(dbdpn, dbdpn, "-d", volpath, buf1, buf2, logconfig, NULL);
- }
- else {
+ } else {
ret = execlp(dbdpn, dbdpn, volpath, buf1, buf2, logconfig, NULL);
}
/* Yikes! We're still here, so exec failed... */
int main(int argc, char *argv[])
{
struct db_param *dbp;
- int err = 0;
+ int err = 0, ret, delete_bdb = 0;
int ctrlfd, clntfd;
char *logconfig;
set_processname("cnid_dbd");
- /* FIXME: implement -d from cnid_metad */
- if (argc != 5) {
- LOG(log_error, logtype_cnid, "main: not enough arguments");
- exit(1);
+ while (( ret = getopt( argc, argv, "d")) != -1 ) {
+ switch (ret) {
+ case 'd':
+ delete_bdb = 1;
+ break;
+ }
}
- ctrlfd = atoi(argv[2]);
- clntfd = atoi(argv[3]);
- logconfig = strdup(argv[4]);
- setuplog(logconfig);
+ if (argc - optind != 4) {
+ LOG(log_error, logtype_cnid, "main: not enough arguments");
+ exit(EXIT_FAILURE);
+ }
/* Load .volinfo file */
- if (loadvolinfo(argv[1], &volinfo) == -1) {
+ if (loadvolinfo(argv[optind], &volinfo) == -1) {
LOG(log_error, logtype_cnid, "Cant load volinfo for \"%s\"", argv[1]);
exit(EXIT_FAILURE);
}
strncpy(dbpath, volinfo.v_dbpath, MAXPATHLEN - strlen("/.AppleDB"));
strcat(dbpath, "/.AppleDB");
+ ctrlfd = atoi(argv[optind + 1]);
+ clntfd = atoi(argv[optind + 2]);
+ logconfig = strdup(argv[optind + 3]);
+ setuplog(logconfig);
+
if (vol_load_charsets(&volinfo) == -1) {
LOG(log_error, logtype_cnid, "Error loading charsets!");
exit(EXIT_FAILURE);
}
}
+ if (delete_bdb && (db_locked == LOCK_EXCL)) {
+ LOG(log_warning, logtype_cnid, "main: too many CNID db opening attempts, wiping the slate clean");
+ chdir(dbpath);
+ system("rm -f cnid2.db lock log.* __db.*");
+ if ((db_locked = get_lock(LOCK_EXCL, dbpath)) != LOCK_EXCL) {
+ LOG(log_error, logtype_cnid, "main: fatal db lock error");
+ exit(EXIT_FAILURE);
+ }
+ }
+
set_signal();
/* SIGINT and SIGTERM are always off, unless we are in pselect */