-
- return lockfd;
-}
-
-void free_lock(int lockfd)
-{
- struct flock lock;
-
- lock.l_start = 0;
- lock.l_whence = SEEK_SET;
- lock.l_len = 0;
- lock.l_type = F_UNLCK;
- fcntl(lockfd, F_SETLK, &lock);
- close(lockfd);
-}
-
-static void usage ()
-{
- printf("Usage: dbd [-e|-v|-x] -d [-i] | -s | -r [-f] <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"
- " -s Scan volume:\n"
- " 1. Compare 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"
- " -r Rebuild volume:\n"
- " 1. Sync 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"
- " Option: -f wipe database and rebuild from IDs stored in AppleDouble files,\n"
- " only available for volumes with 'cachecnid' option\n\n"
- "General options:\n"
- " -e only work on inactive volumes and lock them (exclusive)\n"
- " -x rebuild indexes\n"
- " -v verbose\n"
- );