- aint = 0;
-#if AD_VERSION > AD_VERSION1
- /* look in AD v2 header */
- if (adp)
- 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);
- /* Throw errors if cnid_add fails. */
- if (aint == CNID_INVALID) {
- switch (errno) {
- case CNID_ERR_PARAM:
- LOG(log_error, logtype_afpd, "getfilparams: Incorrect parameters passed to cnid_add");
- return(AFPERR_PARAM);
- case CNID_ERR_PATH:
- return(AFPERR_PARAM);
- case CNID_ERR_DB:
- case CNID_ERR_MAX:
- return(AFPERR_MISC);
- }
- }
-#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
- * other wierd places). While we consider this Apple's bug,
- * this is the work-around: In order to maintain constant and
- * unique DIDs and FNUMs, we monotonically generate the DIDs
- * during the session, and derive the FNUMs from the filesystem.
- * Since the DIDs are small, we insure that the FNUMs are fairly
- * large by setting thier high bits to the device number.
- *
- * AFS already does something very similar to this for the
- * inode number, so we don't repeat the procedure.
- *
- * new algorithm:
- * due to complaints over did's being non-persistent,
- * here's the current hack to provide semi-persistent
- * 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.
- *
- * both the inode and device information are actually hashes
- * that are then truncated to the requisite bit length.
- *
- * it should be okay to use lstat to deal with symlinks.
- */
-#ifdef USE_LASTDID
- aint = htonl(( st->st_dev << 16 ) | (st->st_ino & 0x0000ffff));
-#else /* USE_LASTDID */
- lstp = lstat(upath, &lst) < 0 ? st : &lst;
- aint = htonl(CNID(lstp, 1));
-#endif /* USE_LASTDID */
- }
-
- memcpy(data, &aint, sizeof( aint ));
- data += sizeof( aint );