From: rufustfirefly Date: Tue, 14 Aug 2001 14:00:08 +0000 (+0000) Subject: CNID/DID patch from Uwe Hees (moderately tested) X-Git-Tag: netatalk-1-5-rc1~290 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=f5258ea02c1c37403571cd6a86c4e66a4aab1c10 CNID/DID patch from Uwe Hees (moderately tested) --- diff --git a/ChangeLog b/ChangeLog index 7dfa7436..c0b575e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ + +2001-08-14 jeff b + + * acconfig.h, configure.in, etc/afpd/directory.c, + etc/afpd/enumerate.c, etc/afpd/file.c, etc/afpd/file.h, + etc/afpd/filedir.c, etc/afpd/fork.c, etc/afpd/volume.c, + etc/afpd/volume.h, libatalk/Makefile.am, + libatalk/cnid/cnid_add.c, libatalk/cnid/cnid_close.c, + libatalk/cnid/cnid_delete.c, libatalk/cnid/cnid_lookup.c, + libatalk/cnid/cnid_nextid.c, libatalk/cnid/cnid_open.c, + libatalk/cnid/cnid_private.h, libatalk/cnid/cnid_update.c: + DID database and reincluding libatalk/cnid back into + compiled tree (Uwe Hees) + + * libatalk/cnid/.cvsignore: updated .cvsignore list for + CNID patch (Jeff) + 2001-08-09 Sam Noble * configure.in, acconfig.h: Merged a patch from meeroh@mit.edu @@ -21,7 +38,7 @@ 2001-06-27 jeff b * many, many, files: more malformed ifdef correction, nicer - comments, etc, etc, etc + comments, etc, etc, etc (Jeff) * etc/afpd/directory.c, etc/afpd/uid.c, etc/afpd/uid.h: fixes for force-uidgid to compile properly. haven't tested it, but @@ -51,7 +68,7 @@ support in both afpd and papd (Jason Keltz ) * etc/*/*.{c,h}: corrected malformed defines, nicer comments, - CVS Id tags + CVS Id tags (Jeff) 2001-06-20 jeff b diff --git a/acconfig.h b/acconfig.h index 131c6300..16bab5d0 100644 --- a/acconfig.h +++ b/acconfig.h @@ -4,6 +4,7 @@ #undef ADMIN_GRP #undef AFS #undef BSD4_4 +#undef CNID_DB #undef DEBUG #undef DLSYM_PREPEND_UNDERSCORE #undef DID_MTAB diff --git a/configure.in b/configure.in index 60ac163f..4889aa00 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -dnl $Id: configure.in,v 1.95 2001-08-09 16:54:57 samnoble Exp $ +dnl $Id: configure.in,v 1.96 2001-08-14 14:00:08 rufustfirefly Exp $ dnl configure.in for netatalk AC_INIT(bin/adv1tov2/adv1tov2.c) @@ -231,20 +231,28 @@ AC_ARG_ENABLE(dropkludge, AC_ARG_ENABLE(force-uidgid, [ --enable-force-uidgid allow forcing of uid/gid per volume (BROKEN) ], - if test "$enableval" = "yes"; then + if test "$enableval" = "yes"; then AC_DEFINE(FORCE_UIDGID, 1) AC_MSG_RESULT([enabling forcing of uid/gid per volume]) fi ) +AC_ARG_ENABLE(cnid-db, + [ --enable-cnid-db use persistent cnid database per volume (EXPERIMENTAL) ], + if test "$enableval" = "yes"; then + AC_DEFINE(CNID_DB, 1) + AC_MSG_RESULT([using persistent cnid database per volume]) + fi +) + AC_ARG_WITH(did, [ --with-did=[scheme] set DID scheme (last,mtab)], if test "x$withval" != "xno" ; then - if test "$withval" = "last"; then + if test "$withval" = "last"; then AC_DEFINE(USE_LASTDID, 1) AC_MSG_RESULT([enabling build without DID dev/inode mapping kludge]) fi - if test "$withval" = "mtab"; then + if test "$withval" = "mtab"; then AC_DEFINE(DID_MTAB, 1) AC_MSG_RESULT([enabling mtab-based DID creation support]) fi @@ -275,11 +283,11 @@ AC_ARG_WITH(pam, compile_pam=no use_pam_so=no AC_DEFINE(USE_PAM, 0) - AC_MSG_RESULT([Disabling pam modules support]) + AC_MSG_RESULT([disabling pam modules support]) ) if test "x$compile_pam" = "xyes"; then use_pam_so=yes - AC_MSG_RESULT([Enabling pam modules support]) + AC_MSG_RESULT([enabling pam modules support]) fi shadowpw=no @@ -630,7 +638,7 @@ AC_ARG_ENABLE(pgp-uam, dnl --------------------- check for building Kerberos v4 UAM module AC_ARG_ENABLE(krb4-uam, - [ --enable-krb4-uam enable build of Kerberos v4 UAM module], + [ --enable-krb4-uam enable build of Kerberos v4 UAM module], if test "$enableval" = "yes"; then AC_DEFINE(UAM_KRB4, 1) compile_kerberos=yes @@ -703,6 +711,7 @@ AC_OUTPUT([Makefile libatalk/adouble/Makefile libatalk/asp/Makefile libatalk/atp/Makefile + libatalk/cnid/Makefile libatalk/compat/Makefile libatalk/dsi/Makefile libatalk/nbp/Makefile diff --git a/etc/afpd/directory.c b/etc/afpd/directory.c index 3b2a1ce8..b2162df4 100644 --- a/etc/afpd/directory.c +++ b/etc/afpd/directory.c @@ -1,5 +1,5 @@ /* - * $Id: directory.c,v 1.13 2001-06-27 14:53:16 rufustfirefly Exp $ + * $Id: directory.c,v 1.14 2001-08-14 14:00:10 rufustfirefly Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -22,7 +22,9 @@ #include #include #include +#ifdef CNID_DB #include +#endif /* CNID_DB */ #include #include #include @@ -1751,9 +1753,9 @@ int deletecurdir( vol, path, pathlen ) } dirchildremove(curdir, fdir); -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB cnid_delete(vol->v_db, fdir->d_did); -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ dir_remove( vol, fdir ); #ifdef FORCE_UIDGID diff --git a/etc/afpd/enumerate.c b/etc/afpd/enumerate.c index d67627e8..90137c38 100644 --- a/etc/afpd/enumerate.c +++ b/etc/afpd/enumerate.c @@ -1,5 +1,5 @@ /* - * $Id: enumerate.c,v 1.5 2001-06-20 18:33:04 rufustfirefly Exp $ + * $Id: enumerate.c,v 1.6 2001-08-14 14:00:10 rufustfirefly Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -24,8 +24,9 @@ #include #include #include +#ifdef CNID_DB #include - +#endif /* CNID_DB */ #include "desktop.h" #include "directory.h" #include "volume.h" @@ -61,11 +62,17 @@ adddir( vol, dir, name, namlen, upath, upathlen, st ) strcpy( cdir->d_name, name ); cdir->d_name[namlen] = '\0'; -#if AD_VERSION > AD_VERSION1 + cdir->d_did = 0; + +#ifdef CNID_DB /* find out if we have a fixed did already */ - if (!(cdir->d_did = cnid_lookup(vol->v_db, st, dir->d_did, upath, - upathlen))) { - memset(&ad, 0, sizeof(ad)); + cdir->d_did = cnid_lookup(vol->v_db, st, dir->d_did, upath, + upathlen); +#endif /* CNID_DB */ + + if (cdir->d_did == 0) { +#if AD_VERSION > AD_VERSION1 + memset(&ad, 0, sizeof(ad)); if (ad_open(upath, ADFLAGS_HF|ADFLAGS_DIR, O_RDONLY, 0, &ad) < 0) { /* if we can't parse the AppleDouble header, return 0 for the DID */ cdir->d_did = 0; @@ -73,11 +80,18 @@ adddir( vol, dir, name, namlen, upath, upathlen, st ) /* ... else retrieve the DID entry into cdir->d_did */ memcpy(&cdir->d_did, ad_entry(&ad, ADEID_DID), sizeof(cdir->d_did)); ad_close(&ad, ADFLAGS_HF); - } - - if (!(cdir->d_did = cnid_add(vol->v_db, st, dir->d_did, upath, - upathlen, cdir->d_did))) { -#ifdef USE_LASTDID + } +#endif /* AD_VERSION */ + +#ifdef CNID_DB + /* add to cnid db */ + cdir->d_did = cnid_add(vol->v_db, st, dir->d_did, upath, + upathlen, cdir->d_did); +#endif /* CNID_DB */ + } + + if (cdir->d_did == 0) { +#ifdef USE_LASTDID /* last way of doing DIDs */ cdir->d_did = htonl( vol->v_lastdid++ ); #else /* USE_LASTDID */ @@ -90,24 +104,7 @@ adddir( vol, dir, name, namlen, upath, upathlen, st ) cdir->d_did = htonl( CNID(lstp, 0) ); #endif /* DID_MTAB */ #endif /* USE_LASTDID */ - } } -#else /* AD_VERSION */ - -#ifdef USE_LASTDID - /* last way of doing DIDs */ - cdir->d_did = htonl( vol->v_lastdid++ ); -#else /* USE_LASTDID */ - lstp = lstat(upath, &lst) < 0 ? st : &lst; -#ifdef DID_MTAB - /* mtab way of doing DIDs */ - cdir->d_did = htonl( afpd_st_cnid ( lstp ) ); -#else /* DID_MTAB */ - /* the old way of doing DIDs (default) */ - cdir->d_did = htonl( CNID(lstp, 0) ); -#endif /* DID_MTAB */ -#endif /* USE_LASTDID */ -#endif /* AD_VERSION */ if ((edir = dirinsert( vol, cdir ))) { if (edir->d_name) { diff --git a/etc/afpd/file.c b/etc/afpd/file.c index 5506c4ec..8de41ace 100644 --- a/etc/afpd/file.c +++ b/etc/afpd/file.c @@ -1,5 +1,5 @@ /* - * $Id: file.c,v 1.24 2001-07-12 23:18:12 srittau Exp $ + * $Id: file.c,v 1.25 2001-08-14 14:00:10 rufustfirefly Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -33,8 +33,9 @@ #include #include #include +#ifdef CNID_DB #include - +#endif /* CNID_DB */ #include "directory.h" #include "desktop.h" #include "volume.h" @@ -59,7 +60,7 @@ * files: * ioFlFndrInfo 16 -> type 4 type field * creator 4 creator field - * flags 2 finder flags: + * flags 2 finder flags: * alias, bundle, etc. * location 4 location in window * folder 2 window that contains file @@ -201,16 +202,28 @@ int getfilparams(vol, bitmap, path, dir, st, buf, buflen ) break; case FILPBIT_FNUM : + aint = 0; +#ifdef CNID_DB + /* find out if we have a fixed did already */ + aint = cnid_lookup(vol->v_db, st, dir->d_did, upath, + strlen(upath)); +#endif /* CNID_DB */ + + /* look in AD v2 header */ + if (aint == 0) + { #if AD_VERSION > AD_VERSION1 - /* use the CNID database if we're using AD v2 */ - if (isad) - memcpy(&aint, ad_entry(adp, ADEID_DID), sizeof(aint)); - else - aint = 0; - - if (!(aint = cnid_add(vol->v_db, st, dir->d_did, upath, - strlen(upath), aint))) { + if (isad) + memcpy(&aint, ad_entry(adp, ADEID_DID), sizeof(aint)); #endif /* AD_VERSION > AD_VERSION1 */ + +#ifdef CNID_DB + aint = cnid_add(vol->v_db, st, dir->d_did, upath, + strlen(upath), aint); +#endif /* CNID_DB */ + } + + if (aint == 0) { /* * What a fucking mess. First thing: DID and FNUMs are * in the same space for purposes of enumerate (and several @@ -227,7 +240,7 @@ int getfilparams(vol, bitmap, path, dir, st, buf, buflen ) * new algorithm: * due to complaints over did's being non-persistent, * here's the current hack to provide semi-persistent - * did's: + * did's: * 1) we reserve the first bit for file ids. * 2) the next 7 bits are for the device. * 3) the remaining 24 bits are for the inode. @@ -247,11 +260,9 @@ int getfilparams(vol, bitmap, path, dir, st, buf, buflen ) aint = htonl(CNID(lstp, 1)); #endif /* DID_MTAB */ #endif /* USE_LASTDID */ + } -#if AD_VERSION > AD_VERSION1 - } -#endif /* AD_VERSION > AD_VERSION1 */ - memcpy(data, &aint, sizeof( aint )); + memcpy(data, &aint, sizeof( aint )); data += sizeof( aint ); break; @@ -310,7 +321,7 @@ int getfilparams(vol, bitmap, path, dir, st, buf, buflen ) achar = '\x00'; ashort = 0x0000; } - + *data++ = achar; *data++ = 0; memcpy(data, &ashort, sizeof( ashort )); @@ -462,7 +473,7 @@ int afp_createfile(obj, ibuf, ibuflen, rbuf, rbuflen ) } ad_setentrylen( adp, ADEID_NAME, strlen( path )); - memcpy(ad_entry( adp, ADEID_NAME ), path, + memcpy(ad_entry( adp, ADEID_NAME ), path, ad_getentrylen( adp, ADEID_NAME )); ad_flush( adp, ADFLAGS_DF|ADFLAGS_HF ); ad_close( adp, ADFLAGS_DF|ADFLAGS_HF ); @@ -642,7 +653,7 @@ int setfilparams(vol, path, bitmap, buf ) case FILPBIT_FINFO : if ((memcmp( ad_entry( adp, ADEID_FINDERI ), ufinderi, 8 ) == 0) - && (em = getextmap( path )) && + && (em = getextmap( path )) && (memcmp(buf, em->em_type, sizeof( em->em_type )) == 0) && (memcmp(buf + 4, em->em_creator, sizeof( em->em_creator )) == 0)) { @@ -1025,7 +1036,7 @@ int copyfile(src, dst, newname, noadouble ) #endif /* SENDFILE_FLAVOR_LINUX */ while (1) { if ((cc = read(sfd, filebuf, sizeof(filebuf))) < 0) { - if (errno == EINTR) + if (errno == EINTR) continue; err = AFPERR_PARAM; break; @@ -1110,7 +1121,7 @@ copydata_done: unlink(dst); return err; } - + if (newname) { memset(&ad, 0, sizeof(ad)); if ( ad_open( dst, noadouble | ADFLAGS_HF, O_RDWR|O_CREAT, @@ -1264,7 +1275,7 @@ delete_unlock: } -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB /* return a file id */ int afp_createid(obj, ibuf, ibuflen, rbuf, rbuflen ) AFPObj *obj; @@ -1283,7 +1294,7 @@ int afp_createid(obj, ibuf, ibuflen, rbuf, rbuflen ) #ifdef DEBUG syslog(LOG_INFO, "begin afp_createid:"); #endif /* DEBUG */ - + *rbuflen = 0; ibuf += 2; @@ -1331,6 +1342,7 @@ int afp_createid(obj, ibuf, ibuflen, rbuf, rbuflen ) return AFPERR_EXISTID; } +#if AD_VERSION > AD_VERSION1 memset(&ad, 0, sizeof(ad)); if (ad_open( upath, ADFLAGS_HF, O_RDONLY, 0, &ad ) < 0) id = 0; @@ -1344,6 +1356,7 @@ int afp_createid(obj, ibuf, ibuflen, rbuf, rbuflen ) *rbuflen = sizeof(id); return AFP_OK; } +#endif /* AD_VERSION > AD_VERSION1 */ #ifdef DEBUG syslog(LOG_INFO, "ending afp_createid...:"); @@ -1380,7 +1393,7 @@ int afp_resolveid(obj, ibuf, ibuflen, rbuf, rbuflen ) #ifdef DEBUG syslog(LOG_INFO, "begin afp_resolveid:"); #endif /* DEBUG */ - + *rbuflen = 0; ibuf += 2; @@ -1431,7 +1444,7 @@ int afp_resolveid(obj, ibuf, ibuflen, rbuf, rbuflen ) #ifdef DEBUG syslog(LOG_INFO, "end afp_resolveid:"); #endif /* DEBUG */ - + return AFP_OK; } @@ -1513,7 +1526,7 @@ int afp_deleteid(obj, ibuf, ibuflen, rbuf, rbuflen ) return err; } -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ #define APPLETEMP ".AppleTempXXXXXX" @@ -1528,10 +1541,10 @@ int afp_exchangefiles(obj, ibuf, ibuflen, rbuf, rbuflen ) char *spath, temp[17], *path, *p; char *supath, *upath; int err; -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB int slen, dlen; -#endif /* AD_VERSION > AD_VERSION1 */ - cnid_t sid, did; +#endif /* CNID_DB */ + u_int32_t sid, did; u_int16_t vid; #ifdef DEBUG @@ -1593,10 +1606,10 @@ int afp_exchangefiles(obj, ibuf, ibuflen, rbuf, rbuflen ) /* look for the source cnid. if it doesn't exist, don't worry about * it. */ -#if AD_VERSION > AD_VERSION1 - sid = cnid_lookup(vol->v_db, &srcst, sdir->d_did, supath, +#ifdef CNID_DB + sid = cnid_lookup(vol->v_db, &srcst, sdir->d_did, supath, slen = strlen(supath)); -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ if (( dir = dirsearch( vol, did )) == NULL ) { return( AFPERR_PARAM ); @@ -1628,13 +1641,13 @@ int afp_exchangefiles(obj, ibuf, ibuflen, rbuf, rbuflen ) } } -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB /* look for destination id. */ - did = cnid_lookup(vol->v_db, &destst, curdir->d_did, upath, + did = cnid_lookup(vol->v_db, &destst, curdir->d_did, upath, dlen = strlen(upath)); -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ - /* construct a temp name. + /* construct a temp name. * NOTE: the temp file will be in the dest file's directory. it * will also be inaccessible from AFP. */ memcpy(temp, APPLETEMP, sizeof(APPLETEMP)); @@ -1647,7 +1660,7 @@ int afp_exchangefiles(obj, ibuf, ibuflen, rbuf, rbuflen ) of_rename(vol, sdir, spath, curdir, temp); /* rename destination to source */ - if ((err = renamefile(path, p, spath, vol_noadouble(vol))) < 0) + if ((err = renamefile(path, p, spath, vol_noadouble(vol))) < 0) goto err_src_to_tmp; of_rename(vol, curdir, path, sdir, spath); @@ -1656,9 +1669,9 @@ int afp_exchangefiles(obj, ibuf, ibuflen, rbuf, rbuflen ) goto err_dest_to_src; of_rename(vol, curdir, temp, curdir, path); -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB /* id's need switching. src -> dest and dest -> src. */ - if (sid && (cnid_update(vol->v_db, sid, &destst, curdir->d_did, + if (sid && (cnid_update(vol->v_db, sid, &destst, curdir->d_did, upath, dlen) < 0)) { switch (errno) { case EPERM: @@ -1684,7 +1697,7 @@ int afp_exchangefiles(obj, ibuf, ibuflen, rbuf, rbuflen ) cnid_update(vol->v_db, sid, &srcst, sdir->d_did, supath, slen); goto err_temp_to_dest; } -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ #ifdef DEBUG syslog(LOG_INFO, "ending afp_exchangefiles:"); @@ -1693,7 +1706,7 @@ int afp_exchangefiles(obj, ibuf, ibuflen, rbuf, rbuflen ) return AFP_OK; - /* all this stuff is so that we can unwind a failed operation + /* all this stuff is so that we can unwind a failed operation * properly. */ err_temp_to_dest: /* rename dest to temp */ diff --git a/etc/afpd/file.h b/etc/afpd/file.h index 4e7e77c7..e0dde7af 100644 --- a/etc/afpd/file.h +++ b/etc/afpd/file.h @@ -1,5 +1,5 @@ /* - * $Id: file.h,v 1.2 2001-06-20 18:33:04 rufustfirefly Exp $ + * $Id: file.h,v 1.3 2001-08-14 14:00:10 rufustfirefly Exp $ * * Copyright (c) 1990,1991 Regents of The University of Michigan. * All Rights Reserved. @@ -87,11 +87,11 @@ extern int afp_exchangefiles __P((AFPObj *, char *, int, char *, int *)); extern int afp_setfilparams __P((AFPObj *, char *, int, char *, int *)); extern int afp_copyfile __P((AFPObj *, char *, int, char *, int *)); extern int afp_createfile __P((AFPObj *, char *, int, char *, int *)); -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB extern int afp_createid __P((AFPObj *, char *, int, char *, int *)); extern int afp_resolveid __P((AFPObj *, char *, int, char *, int *)); extern int afp_deleteid __P((AFPObj *, char *, int, char *, int *)); -#else /* AD_VERSION > AD_VERSION1 */ +#else /* CNID_DB */ #define afp_createid afp_null #define afp_resolveid afp_null #define afp_deleteid afp_null diff --git a/etc/afpd/filedir.c b/etc/afpd/filedir.c index a53a1eb3..5d5e0b24 100644 --- a/etc/afpd/filedir.c +++ b/etc/afpd/filedir.c @@ -1,5 +1,5 @@ /* - * $Id: filedir.c,v 1.10 2001-06-20 18:33:04 rufustfirefly Exp $ + * $Id: filedir.c,v 1.11 2001-08-14 14:00:10 rufustfirefly Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -18,7 +18,9 @@ #include #include #include +#ifdef CNID_DB #include +#endif #include #include #ifdef HAVE_FCNTL_H @@ -292,9 +294,9 @@ int afp_rename(obj, ibuf, ibuflen, rbuf, rbuflen ) u_int32_t did; int plen; u_int16_t vid; -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB cnid_t id; -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ #ifdef DEBUG syslog(LOG_INFO, "begin afp_rename:"); @@ -375,9 +377,9 @@ int afp_rename(obj, ibuf, ibuflen, rbuf, rbuflen ) upath = mtoupath(vol, path); -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB id = cnid_get(vol->v_db, curdir->d_did, upath, strlen(upath)); -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ if ( rename( upath, newpath ) < 0 ) { switch ( errno ) { @@ -390,11 +392,11 @@ int afp_rename(obj, ibuf, ibuflen, rbuf, rbuflen ) } } -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB if (stat(newpath, &st) < 0) /* this shouldn't fail */ return AFPERR_MISC; cnid_update(vol->v_db, id, &st, curdir->d_did, newpath, strlen(newpath)); -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ if ( !odir ) { newadpath = obj->newtmp; @@ -500,10 +502,10 @@ int afp_delete(obj, ibuf, ibuflen, rbuf, rbuflen ) } else if (of_findname(vol, curdir, path)) { rc = AFPERR_BUSY; } else if ((rc = deletefile( upath = mtoupath(vol, path ))) == AFP_OK) { -#if AD_VERSION > AD_VERSION1 /* get rid of entry */ +#ifdef CNID_DB /* get rid of entry */ cnid_t id = cnid_get(vol->v_db, curdir->d_did, upath, strlen(upath)); cnid_delete(vol->v_db, id); -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ } if ( rc == AFP_OK ) { setvoltime(obj, vol ); @@ -561,9 +563,9 @@ int afp_moveandrename(obj, ibuf, ibuflen, rbuf, rbuflen ) int did, rc; int plen; u_int16_t vid; -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB cnid_t id; -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ #ifdef DROPKLUDGE int retvalue; #endif /* DROPKLUDGE */ @@ -606,19 +608,19 @@ int afp_moveandrename(obj, ibuf, ibuflen, rbuf, rbuflen ) /* not a directory */ strcpy(newname, path); strcpy(oldname, path); /* an extra copy for of_rename */ -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB p = mtoupath(vol, path); id = cnid_get(vol->v_db, sdir->d_did, p, strlen(p)); -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ p = ctoupath( vol, sdir, newname ); } else { odir = curdir; strcpy( newname, odir->d_name ); - strcpy(oldname, odir->d_name); + strcpy(oldname, odir->d_name); p = ctoupath( vol, odir->d_parent, newname ); -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB id = curdir->d_did; /* we already have the CNID */ -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ } /* * p now points to the full pathname of the source fs object. @@ -691,14 +693,14 @@ int afp_moveandrename(obj, ibuf, ibuflen, rbuf, rbuflen ) #endif /* DROPKLUDGE */ if ( rc == AFP_OK ) { -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB /* renaming may have moved the file/dir across a filesystem */ - if (stat(upath, &st) < 0) + if (stat(upath, &st) < 0) return AFPERR_MISC; - + /* fix up the catalog entry */ cnid_update(vol->v_db, id, &st, curdir->d_did, upath, strlen(upath)); -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ setvoltime(obj, vol ); } diff --git a/etc/afpd/fork.c b/etc/afpd/fork.c index bd9d0a4e..b14499fb 100644 --- a/etc/afpd/fork.c +++ b/etc/afpd/fork.c @@ -1,5 +1,5 @@ /* - * $Id: fork.c,v 1.5 2001-06-20 18:33:04 rufustfirefly Exp $ + * $Id: fork.c,v 1.6 2001-08-14 14:00:10 rufustfirefly Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -36,7 +36,9 @@ #include #include #include +#ifdef CNID_DB #include +#endif #include "fork.h" #include "file.h" @@ -155,7 +157,7 @@ static int getforkparams(ofork, bitmap, buf, buflen, attrbits ) memcpy(data, ufinderi, 8 ); if (( em = getextmap( ofork->of_name )) != NULL ) { memcpy(data, em->em_type, sizeof( em->em_type )); - memcpy(data + 4, em->em_creator, + memcpy(data + 4, em->em_creator, sizeof( em->em_creator )); } } @@ -173,29 +175,38 @@ static int getforkparams(ofork, bitmap, buf, buflen, attrbits ) break; case FILPBIT_FNUM : - /* - * See file.c getfilparams() for why this is done this - * way. - */ + aint = 0; +#ifdef CNID_DB + /* find out if we have a fixed did already */ + aint = cnid_lookup(ofork->of_vol->v_db, &st, + ofork->of_dir->d_did, + upath, strlen(upath)); +#endif /* CNID_DB */ + + /* look in AD v2 header */ + if (aint == 0) + { #if AD_VERSION > AD_VERSION1 - if (isad) - memcpy(&aint, ad_entry(ofork->of_ad, ADEID_DID), sizeof(aint)); - else - aint = 0; - - if (!(aint = cnid_add(ofork->of_vol->v_db, &st, - ofork->of_dir->d_did, - upath, strlen(upath), aint))) { + if (isad) + memcpy(&aint, ad_entry(ofork->of_ad, ADEID_DID), sizeof(aint)); #endif /* AD_VERSION > AD_VERSION1 */ + +#ifdef CNID_DB + aint = cnid_add(ofork->of_vol->v_db, &st, + ofork->of_dir->d_did, + upath, strlen(upath), aint); +#endif /* CNID_DB */ + } + + if (aint == 0) { #ifdef AFS aint = st.st_ino; #else /* AFS */ aint = ( st.st_dev << 16 ) | ( st.st_ino & 0x0000ffff ); #endif /* AFS */ -#if AD_VERSION > AD_VERSION1 } -#endif /* AD_VERSION > AD_VERSION1 */ - memcpy(data, &aint, sizeof( aint )); + + memcpy(data, &aint, sizeof( aint )); data += sizeof( aint ); break; @@ -414,7 +425,7 @@ int afp_openfork(obj, ibuf, ibuflen, rbuf, rbuflen ) if (!ret && (access & OPENACC_RD)) { ofork->of_flags |= AFPFORK_ACCRD; ret = ad_lock(ofork->of_ad, eid, ADLOCK_RD | ADLOCK_FILELOCK, - AD_FILELOCK_RD, 1, ofrefnum); + AD_FILELOCK_RD, 1, ofrefnum); } /* can we access the fork? */ diff --git a/etc/afpd/volume.c b/etc/afpd/volume.c index 662b8dae..42744291 100644 --- a/etc/afpd/volume.c +++ b/etc/afpd/volume.c @@ -1,5 +1,5 @@ /* - * $Id: volume.c,v 1.8 2001-06-20 18:33:04 rufustfirefly Exp $ + * $Id: volume.c,v 1.9 2001-08-14 14:00:10 rufustfirefly Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -23,7 +23,9 @@ #include #include #include +#ifdef CNID_DB #include +#endif /* CNID_DB*/ #include #ifdef HAVE_FCNTL_H #include @@ -60,9 +62,9 @@ static struct vol *volumes = NULL; static int lastvid = 0; -#if AD_VERSION == AD_VERSION1 +#ifndef CNID_DB static char *Trash = "\02\024Network Trash Folder"; -#endif /* AD_VERSION == AD_VERSION1 */ +#endif /* CNID_DB */ static struct extmap *extmap = NULL, *defextmap = NULL; #define VOLOPT_ALLOW 0 /* user allow list */ @@ -345,13 +347,13 @@ static void volset(struct vol_option *options, char *volname, int vlen, p = strtok(NULL, ","); } -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB } else if (optionok(tmp, "dbpath:", val)) { if (options[VOLOPT_DBPATH].c_value) free(options[VOLOPT_DBPATH].c_value); - + options[VOLOPT_DBPATH].c_value = strdup(val + 1); -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ } else if (optionok(tmp, "mapchars:",val)) { if (options[VOLOPT_MAPCHARS].c_value) free(options[VOLOPT_MAPCHARS].c_value); @@ -382,7 +384,7 @@ static void volset(struct vol_option *options, char *volname, int vlen, } else { /* we'll assume it's a volume name. */ - strncpy(volname, tmp, vlen); + strncpy(volname, tmp, vlen); } } @@ -456,10 +458,10 @@ static int creatvol(const char *path, char *name, struct vol_option *options) if (options[VOLOPT_PASSWORD].c_value) volume->v_password = strdup(options[VOLOPT_PASSWORD].c_value); -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB if (options[VOLOPT_DBPATH].c_value) volume->v_dbpath = strdup(options[VOLOPT_DBPATH].c_value); -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ #ifdef FORCE_UIDGID @@ -643,10 +645,10 @@ static int readvolfile(obj, p1, p2, user, pwent) if (strncmp(path, VOLOPT_DEFAULT, VOLOPT_DEFAULT_LEN) == 0) { *tmp = '\0'; for (i = 0; i < VOLOPT_NUM; i++) { - if (parseline( sizeof( path ) - VOLOPT_DEFAULT_LEN - 1, + if (parseline( sizeof( path ) - VOLOPT_DEFAULT_LEN - 1, path + VOLOPT_DEFAULT_LEN) < 0) break; - volset(save_options, tmp, sizeof(tmp) - 1, + volset(save_options, tmp, sizeof(tmp) - 1, obj->options.nlspath, path + VOLOPT_DEFAULT_LEN); } } @@ -721,7 +723,7 @@ static int readvolfile(obj, p1, p2, user, pwent) if (((options[VOLOPT_FLAGS].i_value & AFPVOL_RO) == 0) && ((accessvol(options[VOLOPT_ROLIST].c_value, obj->username) == 1) || - !accessvol(options[VOLOPT_RWLIST].c_value, + !accessvol(options[VOLOPT_RWLIST].c_value, obj->username))) options[VOLOPT_FLAGS].i_value |= AFPVOL_RO; @@ -763,7 +765,7 @@ static void load_volumes(AFPObj *obj) } else if (pwent) { /* * Read user's AppleVolumes or .AppleVolumes file - * If neither are readable, read the default volumes file. if + * If neither are readable, read the default volumes file. if * that doesn't work, create a user share. */ if ( readvolfile(obj, pwent->pw_dir, "AppleVolumes", 1, pwent) < 0 && @@ -850,7 +852,7 @@ static int getvolparams( bitmap, vol, st, buf, buflen ) * .Parent file here if it doesn't exist. */ memset(&ad, 0, sizeof(ad)); - if ( ad_open( vol->v_path, vol_noadouble(vol) | + if ( ad_open( vol->v_path, vol_noadouble(vol) | ADFLAGS_HF|ADFLAGS_DIR, O_RDWR | O_CREAT, 0666, &ad) < 0 ) { isad = 0; @@ -889,11 +891,11 @@ static int getvolparams( bitmap, vol, st, buf, buflen ) switch ( bit ) { case VOLPBIT_ATTR : -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB ashort = VOLPBIT_ATTR_FILEID; -#else /* AD_VERSION > AD_VERSION1 */ +#else /* CNID_DB */ ashort = 0; -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ /* check for read-only. * NOTE: we don't actually set the read-only flag unless * it's passed in that way as it's possible to mount @@ -1077,9 +1079,9 @@ int afp_openvol(obj, ibuf, ibuflen, rbuf, rbuflen ) { struct stat st; char *volname; -#if AD_VERSION == AD_VERSION1 +#ifndef CNID_DB char *p; -#endif /* AD_VERSION == AD_VERSION1 */ +#endif /* CNID_DB */ struct vol *volume; struct dir *dir; int len, ret, buflen; @@ -1155,7 +1157,15 @@ int afp_openvol(obj, ibuf, ibuflen, rbuf, rbuflen ) ret = AFPERR_PARAM; goto openvol_err; } -#if AD_VERSION == AD_VERSION1 + +#ifdef CNID_DB + if (volume->v_dbpath) + volume->v_db = cnid_open (volume->v_dbpath); + if (volume->v_db == 0) + volume->v_db = cnid_open (volume->v_path); +#endif /* CNID_DB */ + +#ifndef CNID_DB /* * If you mount a volume twice, the second time the trash appears on * the desk-top. That's because the Mac remembers the DID for the @@ -1165,7 +1175,7 @@ int afp_openvol(obj, ibuf, ibuflen, rbuf, rbuflen ) */ p = Trash; cname( volume, volume->v_dir, &p ); -#endif /* AD_VERSION == AD_VERSION1 */ +#endif /* CNID_DB */ return( AFP_OK ); @@ -1204,7 +1214,7 @@ int afp_closevol(obj, ibuf, ibuflen, rbuf, rbuflen ) dirfree( vol->v_root ); vol->v_dir = NULL; -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB cnid_close(vol->v_db); vol->v_db = NULL; #endif /* AD_VERSION > AD_VERSION1 */ @@ -1269,7 +1279,7 @@ void setvoltime(obj, vol ) * where no other users can interfere, so there's no issue here */ } - + /* a little granularity */ if (vol->v_time < tv.tv_sec) { vol->v_time = tv.tv_sec; diff --git a/etc/afpd/volume.h b/etc/afpd/volume.h index 6731e28b..3ad6acec 100644 --- a/etc/afpd/volume.h +++ b/etc/afpd/volume.h @@ -1,5 +1,5 @@ /* - * $Id: volume.h,v 1.5 2001-06-20 18:33:04 rufustfirefly Exp $ + * $Id: volume.h,v 1.6 2001-08-14 14:00:10 rufustfirefly Exp $ * * Copyright (c) 1990,1994 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -49,10 +49,10 @@ struct vol { int v_nfs, v_casefold; struct codepage *v_mtoupage, *v_utompage, *v_badumap; char *v_password; -#if AD_VERSION > AD_VERSION1 +#ifdef CNID_DB void *v_db; char *v_dbpath; -#endif /* AD_VERSION > AD_VERSION1 */ +#endif /* CNID_DB */ #ifdef FORCE_UIDGID char *v_forceuid; char *v_forcegid; diff --git a/libatalk/Makefile.am b/libatalk/Makefile.am index 9dae0ab0..9bf3f7b1 100644 --- a/libatalk/Makefile.am +++ b/libatalk/Makefile.am @@ -1,6 +1,6 @@ # Makefile.am for libatalk/ -SUBDIRS = adouble asp atp compat dsi nbp netddp util +SUBDIRS = adouble asp atp compat cnid dsi nbp netddp util lib_LTLIBRARIES = libatalk.la @@ -9,6 +9,7 @@ LIBATALK_DEPS = \ asp/libasp.la \ atp/libatp.la \ compat/libcompat.la \ + cnid/libcnid.la \ dsi/libdsi.la \ nbp/libnbp.la \ netddp/libnetddp.la \ diff --git a/libatalk/cnid/.cvsignore b/libatalk/cnid/.cvsignore new file mode 100644 index 00000000..d82fec32 --- /dev/null +++ b/libatalk/cnid/.cvsignore @@ -0,0 +1,7 @@ +Makefile.in +Makefile +.libs +.deps +*.lo +*.la +*.o diff --git a/libatalk/cnid/cnid_add.c b/libatalk/cnid/cnid_add.c index fb06371f..00879ea0 100644 --- a/libatalk/cnid/cnid_add.c +++ b/libatalk/cnid/cnid_add.c @@ -1,10 +1,10 @@ -/* - * $Id: cnid_add.c,v 1.2 2001-06-29 14:14:46 rufustfirefly Exp $ +/* + * $Id: cnid_add.c,v 1.3 2001-08-14 14:00:10 rufustfirefly Exp $ * * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu) * All Rights Reserved. See COPYRIGHT. * - * cnid_add (db, dev, ino, did, name, hint): + * cnid_add (db, dev, ino, did, name, hint): * add a name to the CNID database. we use both dev/ino and did/name * to keep track of things. */ @@ -37,23 +37,21 @@ /* add an entry to the CNID databases. we do this as a transaction * to prevent messiness. */ -static int add_cnid(CNID_private *db, DBT *key, DBT *data) +static int add_cnid(CNID_private *db, DB_TXN *ptid, DBT *key, DBT *data) { DBT altkey, altdata; DB_TXN *tid; - DB_TXNMGR *txnp; - txnp = db->dbenv.tx_info; memset(&altkey, 0, sizeof(altkey)); memset(&altdata, 0, sizeof(altdata)); retry: - if (errno = txn_begin(txnp, NULL, &tid)) { + if (errno = txn_begin(db->dbenv, ptid, &tid,0)) { return errno; } /* main database */ - if (errno = db->db_cnid->put(db->db_cnid, tid, + if (errno = db->db_cnid->put(db->db_cnid, tid, key, data, DB_NOOVERWRITE)) { txn_abort(tid); if (errno == EAGAIN) @@ -88,88 +86,117 @@ retry: return errno; } - return txn_commit(tid); + return txn_commit(tid, 0); } - + /* 0 is not a valid cnid. this will do a cnid_lookup beforehand and return that cnid if it exists. */ -cnid_t cnid_add(void *CNID, const struct stat *st, +cnid_t cnid_add(void *CNID, const struct stat *st, const cnid_t did, const char *name, const int len, cnid_t hint) { CNID_private *db; DBT key, data; + DBT rootinfo_key, rootinfo_data; + DB_TXN *tid; struct flock lock; cnid_t id, save; - - - if (!(db = CNID) || !st || !name) + + int debug = 0; + + + if (!(db = CNID) || !st || !name) { return 0; - - /* just do a lookup if RootInfo is read-only. */ - if (db->flags & (CNIDFLAG_ROOTINFO_RO | CNIDFLAG_DB_RO)) - return cnid_lookup(db, st, did, name, len); + } + + /* do a lookup... */ + id = cnid_lookup(db, st, did, name, len); + /* ...return id if it is valid or if RootInfo is read-only. */ + if (id || (db->flags & CNIDFLAG_DB_RO)) { + if (debug) + syslog(LOG_ERR, "cnid_add: looked up did %d, name %s as %d", did, name, id); + return id; + } /* initialize everything */ memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); - /* acquire a lock on RootInfo. as the cnid database is the only user - * of RootInfo, we just use our own locks. - * - * NOTE: we lock it here to serialize access to the database. */ - lock.l_type = F_WRLCK; - lock.l_whence = SEEK_SET; - lock.l_start = ad_getentryoff(&db->rootinfo, ADEID_DID); - lock.l_len = ad_getentrylen(&db->rootinfo, ADEID_DID); - if (fcntl(ad_hfileno(&db->rootinfo), F_SETLKW, &lock) < 0) { - syslog(LOG_ERR, "cnid_add: can't establish lock: %m"); - goto cleanup_err; - } - - /* if it's already stored, just return it */ - if ((id = cnid_lookup(db, st, did, name, len))) { - hint = id; - goto cleanup_unlock; - } - /* just set hint, and the key will change. */ key.data = &hint; key.size = sizeof(hint); - - if ((data.data = + + if ((data.data = make_cnid_data(st, did, name, len)) == NULL) { syslog(LOG_ERR, "cnid_add: path name too long."); - goto cleanup_unlock; + goto cleanup_err; } data.size = CNID_HEADER_LEN + len + 1; - - /* start off with the hint. it should be in network byte order. + + /* Abort and retry the modification. */ + if (0) { +retry: if ((errno = txn_abort(tid)) != 0) + syslog(LOG_ERR, "cnid_add: txn_begin failed (%d)", errno); + /* FALLTHROUGH */ + } + + /* Begin the transaction. */ + if ((errno = txn_begin(db->dbenv, NULL, &tid, 0)) != 0) { + syslog(LOG_ERR, "cnid_add: txn_begin failed (%d)", errno); + goto cleanup_err; + } + + /* start off with the hint. it should be in network byte order. * we need to make sure that somebody doesn't add in restricted * cnid's to the database. */ if (ntohl(hint) >= CNID_START) { /* if the key doesn't exist, add it in. don't fiddle with nextID. */ - errno = add_cnid(db, &key, &data); + errno = add_cnid(db, tid, &key, &data); switch (errno) { case DB_KEYEXIST: /* need to use RootInfo after all. */ break; default: - syslog(LOG_ERR, "cnid_add: unable to add CNID(%x)", hint); + syslog(LOG_ERR, "cnid_add: unable to add CNID(%x)", hint); hint = 0; - /* fall through */ + goto cleanup_abort; case 0: - goto cleanup_unlock; + if (debug) + syslog(LOG_ERR, "cnid_add: used hint for did %d, name %s as %d", did, name, hint); + goto cleanup_commit; } - } - - /* no need to refresh the header file */ - memcpy(&hint, ad_entry(&db->rootinfo, ADEID_DID), sizeof(hint)); + } + + memset(&rootinfo_key, 0, sizeof(&rootinfo_key)); + memset(&rootinfo_data, 0, sizeof(&rootinfo_data)); + + /* just set hint, and the key will change. */ + rootinfo_key.data = ROOTINFO_KEY; + rootinfo_key.size = ROOTINFO_KEYLEN; + + /* Get the key. */ + switch (errno = db->db_didname->get(db->db_didname, tid, &rootinfo_key, &rootinfo_data, 0)) { + case DB_LOCK_DEADLOCK: + goto retry; + case 0: + memcpy (&hint, rootinfo_data.data, sizeof(hint)); + if (debug) + syslog(LOG_ERR, "cnid_add: found rootinfo for did %d, name %s as %d", did, name, hint); + break; + case DB_NOTFOUND: + hint = htonl(CNID_START); + if (debug) + syslog(LOG_ERR, "cnid_add: using CNID_START for did %d, name %s as %d", did, name, hint); + break; + default: + syslog(LOG_ERR, "cnid_add: unable to lookup rootinfo (%d)", errno); + goto cleanup_abort; + } /* search for a new id. we keep the first id around to check for * wrap-around. NOTE: i do it this way so that we can go back and * fill in holes. */ save = id = ntohl(hint); - while (errno = add_cnid(db, &key, &data)) { + while (errno = add_cnid(db, tid, &key, &data)) { /* don't use any of the special CNIDs */ if (++id < CNID_START) id = CNID_START; @@ -177,21 +204,40 @@ cnid_t cnid_add(void *CNID, const struct stat *st, if ((errno != DB_KEYEXIST) || (save == id)) { syslog(LOG_ERR, "cnid_add: unable to add CNID(%x)", hint); hint = 0; - goto cleanup_unlock; + goto cleanup_abort; } hint = htonl(id); } /* update RootInfo with the next id. */ - id = htonl(++id); - memcpy(ad_entry(&db->rootinfo, ADEID_DID), &id, sizeof(id)); - ad_flush(&db->rootinfo, ADFLAGS_HF); + rootinfo_data.data = &hint; + rootinfo_data.size = sizeof(hint); + + switch (errno = db->db_didname->put(db->db_didname, tid, &rootinfo_key, &rootinfo_data, 0)) { + case DB_LOCK_DEADLOCK: + goto retry; + case 0: + break; + default: + syslog(LOG_ERR, "cnid_add: unable to update rootinfo (%d)", errno); + goto cleanup_abort; + } + -cleanup_unlock: - lock.l_type = F_UNLCK; - fcntl(ad_hfileno(&db->rootinfo), F_SETLK, &lock); +cleanup_commit: + /* The transaction finished, commit it. */ + if ((errno = txn_commit(tid, 0)) != 0) { + syslog(LOG_ERR, "cnid_add: txn_commit failed (%d)", errno); + goto cleanup_err; + } + + if (debug) + syslog(LOG_ERR, "cnid_add: returned cnid for did %d, name %s as %d", did, name, hint); return hint; +cleanup_abort: + txn_abort(tid); + cleanup_err: return 0; } diff --git a/libatalk/cnid/cnid_close.c b/libatalk/cnid/cnid_close.c index 9745f853..7541f0c7 100644 --- a/libatalk/cnid/cnid_close.c +++ b/libatalk/cnid/cnid_close.c @@ -1,5 +1,5 @@ /* - * $Id: cnid_close.c,v 1.2 2001-06-29 14:14:46 rufustfirefly Exp $ + * $Id: cnid_close.c,v 1.3 2001-08-14 14:00:10 rufustfirefly Exp $ */ #ifdef HAVE_CONFIG_H @@ -35,18 +35,16 @@ void cnid_close(void *CNID) lock.l_whence = SEEK_SET; lock.l_start = lock.l_len = 0; if (fcntl(db->lockfd, F_SETLK, &lock) == 0) { - DB_TXNMGR *txnp; char **list, **first; - - txnp = db->dbenv.tx_info; - errno = txn_checkpoint(txnp, 0, 0); + + errno = txn_checkpoint(db->dbenv, 0, 0, 0); while (errno == DB_INCOMPLETE) - errno = txn_checkpoint(txnp, 0, 0); - - /* we've checkpointed, so clean up the log files. + errno = txn_checkpoint(db->dbenv, 0, 0, 0); + + /* we've checkpointed, so clean up the log files. * NOTE: any real problems will make log_archive return an error. */ - chdir(db->dbenv.db_log_dir ? db->dbenv.db_log_dir : db->dbenv.db_home); - if (!log_archive(db->dbenv.lg_info, &first, DB_ARCH_LOG, NULL)) { + chdir(db->dbenv->db_log_dir ? db->dbenv->db_log_dir : db->dbenv->db_home); + if (!log_archive(db->dbenv, &first, DB_ARCH_LOG, NULL)) { list = first; while (*list) { if (truncate(*list, 0) < 0) @@ -61,9 +59,11 @@ void cnid_close(void *CNID) db->db_didname->close(db->db_didname, 0); db->db_devino->close(db->db_devino, 0); db->db_cnid->close(db->db_cnid, 0); - db_appexit(&db->dbenv); + + db->dbenv->close(db->dbenv, 0); + /* db->dbenv->remove(db->dbenv, db->dbenv->db_home, 0); */ + if (db->lockfd > -1) close(db->lockfd); /* this will also close any lock we have. */ - ad_close(&db->rootinfo, ADFLAGS_HF); free(db); } diff --git a/libatalk/cnid/cnid_delete.c b/libatalk/cnid/cnid_delete.c index 8e3c3497..3a8410d1 100644 --- a/libatalk/cnid/cnid_delete.c +++ b/libatalk/cnid/cnid_delete.c @@ -1,5 +1,5 @@ -/* - * $Id: cnid_delete.c,v 1.2 2001-06-29 14:14:46 rufustfirefly Exp $ +/* + * $Id: cnid_delete.c,v 1.3 2001-08-14 14:00:10 rufustfirefly Exp $ * * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu) * All Rights Reserved. See COPYRIGHT. @@ -28,18 +28,16 @@ int cnid_delete(void *CNID, const cnid_t id) CNID_private *db; DBT key, data; DB_TXN *tid; - DB_TXNMGR *txnp; if (!(db = CNID) || !id || (db->flags & CNIDFLAG_DB_RO)) return -1; - txnp = db->dbenv.tx_info; memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); - + retry: - if (errno = txn_begin(txnp, NULL, &tid)) { + if (errno = txn_begin(db->dbenv, NULL, &tid, 0)) { return errno; } @@ -107,7 +105,7 @@ retry: goto abort_err; } - return txn_commit(tid); + return txn_commit(tid, 0); abort_err: syslog(LOG_ERR, "cnid_del: unable to delete CNID(%x)", id); diff --git a/libatalk/cnid/cnid_lookup.c b/libatalk/cnid/cnid_lookup.c index 5987c12d..2d0dbe7e 100644 --- a/libatalk/cnid/cnid_lookup.c +++ b/libatalk/cnid/cnid_lookup.c @@ -1,5 +1,5 @@ /* - * $Id: cnid_lookup.c,v 1.2 2001-06-29 14:14:46 rufustfirefly Exp $ + * $Id: cnid_lookup.c,v 1.3 2001-08-14 14:00:10 rufustfirefly Exp $ */ #ifdef HAVE_CONFIG_H @@ -32,21 +32,21 @@ cnid_t cnid_lookup(void *CNID, char *buf; CNID_private *db; DBT key, devdata, diddata; - DB_TXNMGR *txnp; int devino = 1, didname = 1; cnid_t id = 0; - + + int debug = 0; + if (!(db = CNID) || !st || !name) return 0; - /* do a little checkpointing if necessary. i stuck it here as - * cnid_lookup gets called when we do directory lookups. only do + /* do a little checkpointing if necessary. i stuck it here as + * cnid_lookup gets called when we do directory lookups. only do * this if we're using a read-write database. */ if ((db->flags & CNIDFLAG_DB_RO) == 0) { - txnp = db->dbenv.tx_info; - errno = txn_checkpoint(txnp, LOGFILEMAX, CHECKTIMEMAX); + errno = txn_checkpoint(db->dbenv, LOGFILEMAX, CHECKTIMEMAX, 0); while (errno == DB_INCOMPLETE) - errno = txn_checkpoint(txnp, 0, 0); + errno = txn_checkpoint(db->dbenv, 0, 0, 0); } if ((buf = make_cnid_data(st, did, name, len)) == NULL) { @@ -65,19 +65,19 @@ cnid_t cnid_lookup(void *CNID, &key, &devdata, 0)) { if (errno == EAGAIN) continue; - + if (errno == DB_NOTFOUND) { devino = 0; break; } - + syslog(LOG_ERR, "cnid_lookup: can't get CNID(%u/%u)", st->st_dev, st->st_ino); return 0; } /* did/name is right afterwards. */ - key.data = buf + CNID_DEVINO_LEN; + key.data = buf + CNID_DEVINO_LEN; key.size = CNID_DID_LEN + len + 1; memset(&diddata, 0, sizeof(diddata)); while (errno = db->db_didname->get(db->db_didname, NULL, @@ -95,19 +95,23 @@ cnid_t cnid_lookup(void *CNID, return 0; } - /* set id. honor did/name over dev/ino as dev/ino isn't necessarily + /* set id. honor did/name over dev/ino as dev/ino isn't necessarily * 1-1. */ if (didname) { memcpy(&id, diddata.data, sizeof(id)); } else if (devino) { memcpy(&id, devdata.data, sizeof(id)); - } + } /* either entries in both databases exist or neither of them do. */ - if ((devino && didname) || !(devino || didname)) + if ((devino && didname) || !(devino || didname)) { + if (debug) + syslog(LOG_ERR, "cnid_lookup: looked up did %d, name %s as %d", did, name, id); return id; - + } /* fix up the databases */ cnid_update(db, id, st, did, name, len); + if (debug) + syslog(LOG_ERR, "cnid_lookup: looked up did %d, name %s as %d (needed update)", did, name, id); return id; } diff --git a/libatalk/cnid/cnid_nextid.c b/libatalk/cnid/cnid_nextid.c index 8d505792..49a1de25 100644 --- a/libatalk/cnid/cnid_nextid.c +++ b/libatalk/cnid/cnid_nextid.c @@ -1,6 +1,7 @@ /* - * $Id: cnid_nextid.c,v 1.2 2001-06-29 14:14:46 rufustfirefly Exp $ + * $Id: cnid_nextid.c,v 1.3 2001-08-14 14:00:10 rufustfirefly Exp $ */ +#ifdef unused #ifdef HAVE_CONFIG_H #include "config.h" @@ -28,3 +29,4 @@ cnid_t cnid_nextid(void *CNID) memcpy(&id, ad_entry(&db->rootinfo, ADEID_DID), sizeof(id)); return id; } +#endif \ No newline at end of file diff --git a/libatalk/cnid/cnid_open.c b/libatalk/cnid/cnid_open.c index 796c5495..0f26c118 100644 --- a/libatalk/cnid/cnid_open.c +++ b/libatalk/cnid/cnid_open.c @@ -1,5 +1,5 @@ -/* - * $Id: cnid_open.c,v 1.2 2001-06-29 14:14:46 rufustfirefly Exp $ +/* + * $Id: cnid_open.c,v 1.3 2001-08-14 14:00:10 rufustfirefly Exp $ * * Copyright (c) 1999. Adrian Sun (asun@zoology.washington.edu) * All Rights Reserved. See COPYRIGHT. @@ -37,6 +37,7 @@ #include "config.h" #endif /* HAVE_CONFIG_H */ +#include #include #include #ifdef HAVE_UNISTD_H @@ -61,9 +62,6 @@ #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif /* ! MIN */ -#define ROOTINFO "RootInfo" -#define ROOTINFO_LEN 8 - #define DBHOME ".AppleDB" #define DBCNID "cnid.db" #define DBDEVINO "devino.db" @@ -71,7 +69,7 @@ #define DBSHORTNAME "shortname.db" /* did/8+3 mapping */ #define DBMACNAME "macname.db" /* did/31 mapping */ #define DBLONGNAME "longname.db" /* did/unicode mapping */ -#define DBLOCKFILE "/cnid.lock" +#define DBLOCKFILE "cnid.lock" #define DBHOMELEN 8 #define DBLEN 10 @@ -87,7 +85,7 @@ #define DBOPTIONS (DB_CREATE | DB_INIT_MPOOL | DB_INIT_LOCK | \ DB_INIT_LOG | DB_INIT_TXN | DB_TXN_NOSYNC | DB_RECOVER) -#define MAXITER 0xFFFF /* maximum number of simultaneously open CNID +#define MAXITER 0xFFFF /* maximum number of simultaneously open CNID * databases. */ /* the first compare that's always done. */ @@ -116,6 +114,7 @@ static int compare_unix(const DBT *a, const DBT *b) for (len = MIN(a->size, b->size); len-- > 4; sa++, sb++) if (ret = (*sa - *sb)) return ret; /* sort by lexical ordering */ + return a->size - b->size; /* sort by length */ } @@ -123,11 +122,11 @@ static int compare_unix(const DBT *a, const DBT *b) * did/macname, and did/shortname. i think did/longname needs a * unicode table to work. also, we can't use strdiacasecmp as that * returns a match if a < b. */ -static int compare_mac(const DBT *a, const DBT *b) +static int compare_mac(const DBT *a, const DBT *b) { u_int8_t *sa, *sb; int len, ret; - + /* sort by did */ if (ret = compare_did(a, b)) return ret; @@ -136,13 +135,17 @@ static int compare_mac(const DBT *a, const DBT *b) sb = b->data + 4; for (len = MIN(a->size, b->size); len-- > 4; sa++, sb++) if (ret = (_diacasemap[*sa] - _diacasemap[*sb])) - return ret; /* sort by lexical ordering */ + return ret; /* sort by lexical ordering */ + return a->size - b->size; /* sort by length */ } /* for unicode names -- right now it's the same as compare_mac. */ -#define compare_unicode(a, b) compare_mac((a), (b)) +static int compare_unicode(const DBT *a, const DBT *b) +{ + return compare_mac(a,b); +} void *cnid_open(const char *dir) { @@ -150,14 +153,13 @@ void *cnid_open(const char *dir) struct flock lock; char path[MAXPATHLEN + 1]; CNID_private *db; - DB_INFO dbi; DBT key, data; int open_flag, len; if (!dir) return NULL; - /* this checks both RootInfo and .AppleDB */ + /* this checks .AppleDB */ if ((len = strlen(dir)) > (MAXPATHLEN - DBLEN - 1)) { syslog(LOG_ERR, "cnid_open: path too large"); return NULL; @@ -168,7 +170,7 @@ void *cnid_open(const char *dir) return NULL; } db->magic = CNID_DB_MAGIC; - + strcpy(path, dir); if (path[len - 1] != '/') { strcat(path, "/"); @@ -178,48 +180,6 @@ void *cnid_open(const char *dir) lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; - /* we create and initialize RootInfo if it doesn't exist. */ - strcat(path, ROOTINFO); - if (ad_open(path, ADFLAGS_HF, O_RDWR, 0666, &db->rootinfo) < 0) { - cnid_t id; - - /* see if we can open it read-only. if it's read-only, we can't - * add CNIDs. */ - memset(&db->rootinfo, 0, sizeof(db->rootinfo)); - if (ad_open(path, ADFLAGS_HF, O_RDONLY, 0666, &db->rootinfo) == 0) { - db->flags = CNIDFLAG_ROOTINFO_RO; - syslog(LOG_INFO, "cnid_open: read-only RootInfo"); - goto mkdir_appledb; - } - - /* create the file */ - memset(&db->rootinfo, 0, sizeof(db->rootinfo)); - if (ad_open(path, ADFLAGS_HF, O_CREAT | O_RDWR, 0666, - &db->rootinfo) < 0) { - syslog(LOG_ERR, "cnid_open: ad_open(RootInfo)"); - goto fail_db; - } - - /* lock the RootInfo file. this and cnid_add are the only places - * that should fiddle with RootInfo. */ - lock.l_start = ad_getentryoff(&db->rootinfo, ADEID_DID); - lock.l_len = ad_getentrylen(&db->rootinfo, ADEID_DID); - if (fcntl(ad_hfileno(&db->rootinfo), F_SETLKW, &lock) < 0) { - syslog(LOG_ERR, "cnid_open: can't establish lock: %m"); - goto fail_adouble; - } - - /* store the beginning CNID */ - id = htonl(CNID_START); - memcpy(ad_entry(&db->rootinfo, ADEID_DID), &id, sizeof(id)); - ad_flush(&db->rootinfo, ADFLAGS_HF); - - /* unlock it */ - lock.l_type = F_UNLCK; - fcntl(ad_hfileno(&db->rootinfo), F_SETLK, &lock); - lock.l_type = F_WRLCK; - } - mkdir_appledb: strcpy(path + len, DBHOME); if ((stat(path, &st) < 0) && (ad_mkdir(path, 0777) < 0)) { @@ -242,24 +202,27 @@ mkdir_appledb: close(db->lockfd); db->lockfd = -1; break; - } + } } - } + } path[len + DBHOMELEN] = '\0'; open_flag = DB_CREATE; /* try a full-blown transactional environment */ - if (db_appinit(path, NULL, &db->dbenv, DBOPTIONS)) { + if (db_env_create(&db->dbenv, 0)) { + syslog(LOG_ERR, "cnid_open: db_env_create failed"); + goto fail_lock; + } + + if (db->dbenv->open(db->dbenv, path, DBOPTIONS, 0666)) { /* try with a shared memory pool */ - memset(&db->dbenv, 0, sizeof(db->dbenv)); - if (db_appinit(path, NULL, &db->dbenv, DB_INIT_MPOOL)) { + if (db->dbenv->open(db->dbenv, path, DB_INIT_MPOOL, 0666)) { /* try without any options. */ - memset(&db->dbenv, 0, sizeof(db->dbenv)); - if (db_appinit(path, NULL, &db->dbenv, 0)) { - syslog(LOG_ERR, "cnid_open: db_appinit failed"); - goto fail_lock; + if (db->dbenv->open(db->dbenv, path, 0, 0666)) { + syslog(LOG_ERR, "cnid_open: db_env_open failed"); + goto fail_lock; } } db->flags |= CNIDFLAG_DB_RO; @@ -267,12 +230,12 @@ mkdir_appledb: syslog(LOG_INFO, "cnid_open: read-only CNID database"); } - memset(&dbi, 0, sizeof(dbi)); - /* did/name reverse mapping. we use a btree for this one. */ - dbi.bt_compare = compare_unix; - if (db_open(DBDIDNAME, DB_BTREE, open_flag, 0666, &db->dbenv, &dbi, - &db->db_didname)) { + if (db_create(&db->db_didname, db->dbenv, 0)) + goto fail_appinit; + + db->db_didname->set_bt_compare(db->db_didname, compare_unix); + if (db->db_didname->open(db->db_didname, DBDIDNAME, NULL, DB_BTREE, open_flag, 0666)) { goto fail_appinit; } @@ -281,17 +244,19 @@ mkdir_appledb: memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); key.data = DBVERSION_KEY; - key.len = DBVERSION_KEY_LEN; + key.size = DBVERSION_KEYLEN; while (errno = db->db_didname->get(db->db_didname, NULL, &key, &data, 0)) { switch (errno) { case EAGAIN: continue; - + case DB_NOTFOUND: + { u_int32_t version = htonl(DBVERSION); data.data = &version; - data.len = sizeof(version); + data.size = sizeof(version); + } dbversion_retry: if (db->db_didname->put(db->db_didname, NULL, &key, &data, DB_NOOVERWRITE)) @@ -304,7 +269,7 @@ dbversion_retry: goto fail_appinit; } } - + /* XXX: in the future, we might check for version number here. */ #if 0 memcpy(&version, data.data, sizeof(version)); @@ -313,65 +278,82 @@ dbversion_retry: } #endif /* 0 */ +#ifdef EXTENDED_DB /* did/macname mapping. btree this one. */ - dbi.bt_compare = compare_mac; - if (db_open(DBMACNAME, DB_BTREE, open_flag, 0666, &db->dbenv, &dbi, - &db->db_macname)) { + if (db_create(&db->db_macname, db->dbenv, 0)) + goto fail_appinit; + + db->db_macname->set_bt_compare(db->db_macname, compare_mac); + if (db->db_macname->open(db->db_macname, DBMACNAME, NULL, DB_BTREE, open_flag, 0666)) { db->db_didname->close(db->db_didname, 0); goto fail_appinit; } /* did/shortname mapping */ - if (db_open(DBSHORTNAME, DB_BTREE, open_flag, 0666, &db->dbenv, &dbi, - &db->db_shortname)) { + if (db_create(&db->db_shortname, db->dbenv, 0)) + goto fail_appinit; + + db->db_shortname->set_bt_compare(db->db_shortname, compare_mac); + if (db->db_shortname->open(db->db_shortname, DBSHORTNAME, NULL, DB_BTREE, open_flag, 0666)) { db->db_didname->close(db->db_didname, 0); db->db_macname->close(db->db_macname, 0); goto fail_appinit; } /* did/longname mapping */ - dbi.bt_compare = compare_unicode; - if (db_open(DBLONGNAME, DB_BTREE, open_flag, 0666, &db->dbenv, &dbi, - &db->db_longname)) { + if (db_create(&db->db_longname, db->dbenv, 0)) + goto fail_appinit; + + db->db_longname->set_bt_compare(db->db_longname, compare_unicode); + if (db->db_longname->open(db->db_longname, DBLONGNAME, NULL, DB_BTREE, open_flag, 0666)) { db->db_didname->close(db->db_didname, 0); db->db_macname->close(db->db_macname, 0); db->db_shortname->close(db->db_shortname, 0); goto fail_appinit; } +#endif /* EXTENDED_DB */ /* dev/ino reverse mapping. we hash this one. */ - dbi.bt_compare = NULL; - if (db_open(DBDEVINO, DB_HASH, open_flag, 0666, &db->dbenv, &dbi, - &db->db_devino)) { + if (db_create(&db->db_devino, db->dbenv, 0)) + goto fail_appinit; + + if (db->db_devino->open(db->db_devino, DBDEVINO, NULL, DB_HASH, open_flag, 0666)) { db->db_didname->close(db->db_didname, 0); +#ifdef EXTENDED_DB db->db_macname->close(db->db_macname, 0); db->db_shortname->close(db->db_shortname, 0); db->db_longname->close(db->db_longname, 0); +#endif /* EXTENDED_DB */ goto fail_appinit; } /* main cnid database. we hash this one as well. */ - if (db_open(DBCNID, DB_HASH, open_flag, 0666, &db->dbenv, &dbi, - &db->db_cnid)) { + if (db_create(&db->db_cnid, db->dbenv, 0)) + goto fail_appinit; + + if (db->db_cnid->open(db->db_cnid, DBCNID, NULL, DB_HASH, open_flag, 0666)) { db->db_didname->close(db->db_didname, 0); +#ifdef EXTENDED_DB db->db_macname->close(db->db_macname, 0); db->db_shortname->close(db->db_shortname, 0); db->db_longname->close(db->db_longname, 0); +#endif /* EXTENDED_DB */ db->db_devino->close(db->db_devino, 0); goto fail_appinit; } + return db; - + fail_appinit: syslog(LOG_ERR, "cnid_open: db_open failed"); - db_appexit(&db->dbenv); + db->dbenv->close(db->dbenv, 0); + /* db->dbenv->remove(db->dbenv, db->dbenv->db_home, 0); */ fail_lock: if (db->lockfd > -1) close(db->lockfd); fail_adouble: - ad_close(&db->rootinfo, ADFLAGS_HF); fail_db: free(db); diff --git a/libatalk/cnid/cnid_private.h b/libatalk/cnid/cnid_private.h index 90f76ca7..d60d726b 100644 --- a/libatalk/cnid/cnid_private.h +++ b/libatalk/cnid/cnid_private.h @@ -1,5 +1,5 @@ /* - * $Id: cnid_private.h,v 1.2 2001-06-29 14:14:46 rufustfirefly Exp $ + * $Id: cnid_private.h,v 1.3 2001-08-14 14:00:10 rufustfirefly Exp $ */ #ifndef LIBATALK_CNID_PRIVATE_H @@ -29,13 +29,23 @@ #define CNIDFLAG_ROOTINFO_RO (1 << 0) #define CNIDFLAG_DB_RO (1 << 1) +/* the key is in the form of a did/name pair. in this case, + * we use 0/RootInfo. */ +#define ROOTINFO_KEY "\0\0\0\0RootInfo" +#define ROOTINFO_KEYLEN 12 + typedef struct CNID_private { u_int32_t magic; - DB *db_cnid, *db_didname, *db_devino, - *db_shortname, *db_macname, *db_longname; - DB_ENV dbenv; - struct adouble rootinfo; - int lockfd, flags; + DB *db_cnid; + DB *db_didname; + DB *db_devino; +#ifdef EXTENDED_DB + DB *db_shortname; + DB *db_macname; + DB *db_longname; +#endif /* EXTENDED_DB */ + DB_ENV* dbenv; + int lockfd, flags; } CNID_private; /* on-disk data format (in network byte order where appropriate) -- @@ -105,18 +115,19 @@ static __inline__ char *make_cnid_data(const struct stat *st, const char *name, const int len) { static char start[CNID_HEADER_LEN + MAXPATHLEN + 1]; + char *buf = start; u_int32_t i; - + if (len > MAXPATHLEN) return NULL; i = htonl(st->st_dev); - memcpy(start, &i, sizeof(i)); + buf = memcpy(buf, &i, sizeof(i)); i = htonl(st->st_ino); - memcpy(start + sizeof(i), &i, sizeof(i)); + buf = memcpy(buf + sizeof(i), &i, sizeof(i)); /* did is already in network byte order */ - memcpy(start + CNID_DEVINO_LEN, &did, sizeof(did)); - memcpy(start + CNID_HEADER_LEN, name, len); + buf = memcpy(buf + sizeof(i), &did, sizeof(did)); + buf = memcpy(buf + sizeof(did), name, len); *(buf + len) = '\0'; buf += len + 1; diff --git a/libatalk/cnid/cnid_update.c b/libatalk/cnid/cnid_update.c index 2d332041..b23f8b8b 100644 --- a/libatalk/cnid/cnid_update.c +++ b/libatalk/cnid/cnid_update.c @@ -1,5 +1,5 @@ /* - * $Id: cnid_update.c,v 1.2 2001-06-29 14:14:46 rufustfirefly Exp $ + * $Id: cnid_update.c,v 1.3 2001-08-14 14:00:10 rufustfirefly Exp $ */ #ifdef HAVE_CONFIG_H @@ -24,14 +24,13 @@ /* cnid_update: takes the given cnid and updates the metadata. to handle the did/name data, there are a bunch of functions to get and set the various fields. */ -int cnid_update(void *CNID, cnid_t id, const struct stat *st, - const cnid_t did, const char *name, const int len, - const char *info, const int infolen) +int cnid_update(void *CNID, const cnid_t id, const struct stat *st, + const cnid_t did, const char *name, const int len/*, + const char *info, const int infolen*/) { CNID_private *db; DBT key, data, altdata; DB_TXN *tid; - DB_TXNMGR *txnp; if (!(db = CNID) || !id || !st || !name || (db->flags & CNIDFLAG_DB_RO)) return -1; @@ -39,11 +38,10 @@ int cnid_update(void *CNID, cnid_t id, const struct stat *st, memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); memset(&altdata, 0, sizeof(altdata)); - txnp = db->dbenv.tx_info; /* begin a transaction */ retry: - if (errno = txn_begin(txnp, NULL, &tid)) { + if (errno = txn_begin(db->dbenv, NULL, &tid, 0)) { return errno; } @@ -65,7 +63,7 @@ retry: txn_abort(tid); goto retry; } - + /* silently fail on a non-existent entry */ if (errno != DB_NOTFOUND) { txn_abort(tid); @@ -88,14 +86,14 @@ retry: goto update_err; } } - + /* delete the old aliases if necessary */ /* make a new entry */ data.data = make_cnid_data(st, did, name, len); data.size = CNID_HEADER_LEN + len + 1; - + /* put a new dev/ino mapping in */ key.data = data.data; key.size = CNID_DEVINO_LEN; @@ -108,7 +106,7 @@ retry: } goto update_err; } - + /* put a new did/name mapping in */ key.data = data.data + CNID_DEVINO_LEN; key.size = data.size - CNID_DEVINO_LEN; @@ -119,7 +117,7 @@ retry: } goto update_err; } - + /* update the old CNID with the new info */ key.data = &id; key.size = sizeof(id); @@ -130,9 +128,9 @@ retry: } goto update_err; } - + /* end transaction */ - return txn_commit(tid); + return txn_commit(tid, 0); update_err: syslog(LOG_ERR, "cnid_update: can't update CNID(%x)", id);