* FIX: afpd: Fix dircache bug, NetAFP Bug ID #13
* FIX: dbd: Better checking for duplicated or bogus CNIDs from AppleDouble
files
+* FIX: dbd: Remove BerkeleyDB database environment after running `dbd`. This
+ is crucial for the automatic BerkeleyDB database upgrade feature which
+ is built into cnid_dbd and dbd.
* FIX: Fix compilation error when AppleTalk support is disabled
* FIX: Portability fixes
+* FIX: search of surrogate pair
Changes in 2.2.1
================
# Provides: netatalk
# Required-Start: $local_fs
# Required-Stop: $local_fs
-# Should-Start: $network $named $remote_fs $syslog slpd
+# Should-Start: $network $named $remote_fs $syslog slpd avahi-daemon
# Should-Stop: $remote_fs $network $syslog
# Default-Start: 3 5
# Default-Stop:
static void usage (void)
{
- printf("Usage: dbd [-e|-t|-v|-x] -d [-i] | -s [-c|-n]| -r [-c|-f] | -u <path to netatalk volume>\n"
+ printf("dbd (Netatalk %s)\n"
+ "Usage: dbd [-e|-t|-v|-x] -d [-i] | -s [-c|-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"
" 7. Check for orphaned CNIDs in database (requires -e)\n"
" 8. Open and close adouble files\n"
" Options: -c Don't check .AppleDouble stuff, only ckeck orphaned.\n"
- " -n Don't open CNID database, skip CNID checks\n\n"
+ " -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"
" 7. Check for orphaned CNIDs in database (requires -e)\n"
" 8. Open and close adouble files\n"
" Options: -c Don't create .AppleDouble stuff, only cleanup orphaned.\n"
- " -f wipe database and rebuild from IDs stored in AppleDouble files,\n"
- " only available for volumes without 'nocnidcache' option. Implies -e.\n\n"
+ " -f wipe database and rebuild from IDs stored in AppleDouble\n"
+ " files, only available for volumes without 'nocnidcache'\n"
+ " option. Implies -e.\n\n"
" -u Upgrade:\n"
- " Opens the database which triggers any necessary upgrades, then closes and exits.\n\n"
+ " Opens the database which triggers any necessary upgrades,\n"
+ " then closes and exits.\n\n"
"General options:\n"
" -e only work on inactive volumes and lock them (exclusive)\n"
" -x rebuild indexes (just for completeness, mostly useless!)\n"
" -t show statistics while running\n"
" -v verbose\n\n"
"WARNING:\n"
- "For -r -f restore of the CNID database from the adouble files, the CNID must of course\n"
- "be synched to them files first with a plain -r rebuild !\n"
+ "For -r -f restore of the CNID database from the adouble files,\n"
+ "the CNID must of course be synched to them files first with a plain -r rebuild!\n"
+ , VERSION
);
}
/* Get db lock */
if ((db_locked = get_lock(LOCK_EXCL, dbpath)) == -1)
- goto exit_failure;
+ goto exit_noenv;
if (db_locked != LOCK_EXCL) {
/* Couldn't get exclusive lock, try shared lock if -e wasn't requested */
if (exclusive) {
dbd_log(LOGSTD, "Database is in use and exlusive was requested");
- goto exit_failure;
+ goto exit_noenv;
}
if ((db_locked = get_lock(LOCK_SHRD, NULL)) != LOCK_SHRD)
- goto exit_failure;
+ goto exit_noenv;
}
/* Check if -f is requested and wipe db if yes */
if ((flags & DBD_FLAGS_FORCE) && rebuild && (volinfo.v_flags & AFPVOL_CACHE)) {
char cmd[8 + MAXPATHLEN];
if ((db_locked = get_lock(LOCK_FREE, NULL)) != 0)
- goto exit_failure;
+ goto exit_noenv;
snprintf(cmd, 8 + MAXPATHLEN, "rm -rf \"%s\"", dbpath);
dbd_log( LOGDEBUG, "Removing old database of volume: '%s'", volpath);
}
dbd_log( LOGDEBUG, "Removed old database.");
if ((db_locked = get_lock(LOCK_EXCL, dbpath)) == -1)
- goto exit_failure;
+ goto exit_noenv;
}
/*
*/
if ( ! nocniddb) {
if ((dbd = dbif_init(dbpath, "cnid2.db")) == NULL)
- goto exit_failure;
+ goto exit_noenv;
if (dbif_env_open(dbd,
&db_param,
(db_locked == LOCK_EXCL) ? (DBOPTIONS | DB_RECOVER) : DBOPTIONS) < 0) {
dbd_log( LOGSTD, "error opening database!");
- goto exit_failure;
+ goto exit_noenv;
}
if (db_locked == LOCK_EXCL)
ret = 0;
exit_failure:
+ if (dbif_env_remove(dbpath) < 0) {
+ dbd_log( LOGSTD, "Error removing BerkeleyDB database environment");
+ ret++;
+ }
get_lock(0, NULL);
-
+
+exit_noenv:
if ((fchdir(cdir)) < 0)
dbd_log(LOGSTD, "fchdir: %s", strerror(errno));
set_processname("cnid_metad");
- while (( cc = getopt( argc, argv, "ds:p:h:u:g:l:f:")) != -1 ) {
+ while (( cc = getopt( argc, argv, "vVds:p:h:u:g:l:f:")) != -1 ) {
switch (cc) {
+ case 'v':
+ case 'V':
+ printf("cnid_metad (Netatalk %s)\n", VERSION);
+ return -1;
case 'd':
debug = 1;
break;
set_processname("cnid_dbd");
- while (( ret = getopt( argc, argv, "d")) != -1 ) {
+ while (( ret = getopt( argc, argv, "vVd")) != -1 ) {
switch (ret) {
+ case 'v':
+ case 'V':
+ printf("cnid_dbd (Netatalk %s)\n", VERSION);
+ return -1;
case 'd':
delete_bdb = 1;
break;
ucs2_t *strcasechr_w(const ucs2_t *s, ucs2_t c)
{
while (*s != 0) {
-/* LOG(log_debug, logtype_default, "Comparing %X to %X (%X - %X)", c, *s, toupper_w(c), toupper_w(*s));*/
- if (toupper_w(c) == toupper_w(*s)) return (ucs2_t *)s;
+ if (tolower_w(c) == tolower_w(*s)) return (ucs2_t *)s;
s++;
}
if (c == *s) return (ucs2_t *)s;
{
if (*s == 0) return NULL;
while (s[1] != 0) {
- if (toupper_sp(c_sp) == toupper_sp((uint32_t)*s << 16 | (uint32_t)s[1])) return (ucs2_t *)s;
+ if (tolower_sp(c_sp) == tolower_sp((uint32_t)*s << 16 | (uint32_t)s[1])) return (ucs2_t *)s;
s++;
}
/*******************************************************************
wide strcasestr()
********************************************************************/
-/* */
+/* surrogate pair support */
ucs2_t *strcasestr_w(const ucs2_t *s, const ucs2_t *ins)
{
slen = strlen_w(s);
inslen = strlen_w(ins);
r = (ucs2_t *)s;
- while ((r = strcasechr_w(r, *ins))) {
- if (strncasecmp_w(r, ins, inslen) == 0) return r;
- r++;
+
+ if ((0xD800 <= *ins) && (*ins < 0xDC00)) {
+ if ((0xDC00 <= ins[1]) && (ins[1] < 0xE000)) {
+ u_int32_t ins_sp = (u_int32_t)*ins << 16 | (u_int32_t)ins[1];
+ while ((r = strcasechr_sp(r, ins_sp))) {
+ if (strncasecmp_w(r, ins, inslen) == 0) return r;
+ r++;
+ }
+ } else {
+ return NULL; /* illegal sequence */
+ }
+ } else {
+ while ((r = strcasechr_w(r, *ins))) {
+ if (strncasecmp_w(r, ins, inslen) == 0) return r;
+ r++;
+ }
}
return NULL;
}
/*******************************************************************
copy a string with max len
********************************************************************/
+/* This function is not used. */
+/* NOTE: not check isolation of surrogate pair */
ucs2_t *strncpy_w(ucs2_t *dest, const ucs2_t *src, const size_t max)
{
/*******************************************************************
append a string of len bytes and add a terminator
********************************************************************/
+/* These functions are not used. */
+/* NOTE: not check isolation of surrogate pair */
ucs2_t *strncat_w(ucs2_t *dest, const ucs2_t *src, const size_t max)
{
size_t start;
return dest;
}
-
+/* no problem of surrogate pair */
ucs2_t *strcat_w(ucs2_t *dest, const ucs2_t *src)
{
size_t start;