/*
- * $Id: directory.c,v 1.119 2009-11-19 10:41:23 franklahm Exp $
+ * $Id: directory.c,v 1.126 2010-01-06 15:37:01 franklahm Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
extern void addir_inherit_acl(const struct vol *vol);
#endif
+/*
+ * Directory caches
+ * ================
+ *
+ * There are currently two cache structures where afpd caches directory information
+ * a) a DID/dirname cache in a hashtable
+ * b) a (red-black) tree with CNIDs as key
+ *
+ * a) is for searching by DID/dirname
+ * b) is for searching by CNID
+ *
+ * Through additional parent, child, previous and next pointers, b) is also used to
+ * represent the on-disk layout of the filesystem. parent and child point to parent
+ * and child directory respectively, linking 2 or more subdirectories in one
+ * directory with previous and next pointers.
+ *
+ * Usage examples, highlighting the main functions:
+ *
+ * a) is eg used in enumerate():
+ * if IS_DIR
+ * dir = dirsearch_byname() // search in cache
+ * if (dir == NULL) // not found
+ * dir = adddir() // add to cache
+ * getdirparams()
+ *
+ * b) is eg used in afp_getfildirparams()
+ * dirlookup() // wrapper for cache and db search
+ * => dir = dirsearch() // search in cache
+ * if (dir) // found
+ * return
+ * else // not found,
+ * cnid_resolve() // resolve with CNID database
+ * cname() // add to cache
+ */
+
struct dir *curdir;
int afp_errno;
dirfreename(edir);
edir->d_m_name = cdir->d_m_name;
edir->d_u_name = cdir->d_u_name;
+ edir->d_u_name_len = cdir->d_u_name_len;
edir->d_m_name_ucs2 = cdir->d_m_name_ucs2;
free(cdir);
cdir = edir;
(1 << DIRPBIT_FINFO)))) {
ad_init(&ad, vol->v_adouble, vol->v_ad_options);
- if ( !ad_metadata( upath, ADFLAGS_DIR, &ad) ) {
+ if ( !ad_metadata( upath, ADFLAGS_CREATE|ADFLAGS_DIR, &ad) ) {
isad = 1;
}
}
}
ad_init(&ad, vol->v_adouble, vol->v_ad_options);
- if (ad_open_metadata( upath, vol_noadouble(vol)|ADFLAGS_DIR, O_CREAT, &ad) < 0) {
+ if (ad_open_metadata( upath, ADFLAGS_DIR, O_CREAT, &ad) < 0) {
/*
* Check to see what we're trying to set. If it's anything
* but ACCESS, UID, or GID, give an error. If it's any of those
}
ad_init(&ad, vol->v_adouble, vol->v_ad_options);
- if (ad_open_metadata( ".", vol_noadouble(vol)|ADFLAGS_DIR, O_CREAT, &ad ) < 0) {
+ if (ad_open_metadata( ".", ADFLAGS_DIR, O_CREAT, &ad ) < 0) {
if (vol_noadouble(vol))
goto createdir_done;
return( AFPERR_ACCESS );
dir->d_u_name = buf;
strcpy( dir->d_u_name, dst );
}
+ dir->d_u_name_len = strlen(dir->d_u_name);
if (dir->d_m_name_ucs2)
free(dir->d_m_name_ucs2);
fdir = curdir;
ad_init(&ad, vol->v_adouble, vol->v_ad_options);
+ /* we never want to create a resource fork here, we are going to delete it */
if ( ad_metadata( ".", ADFLAGS_DIR, &ad) == 0 ) {
ad_getattr(&ad, &ashort);
if ((afp_version < 32) || !(obj->options.flags & OPTION_UUID ))
return AFPERR_PARAM;
LOG(log_debug, logtype_afpd, "afp_mapid: valid UUID request");
+ uuidtype_t type;
len = getnamefromuuid( ibuf, &name, &type);
if (len != 0) /* its a error code, not len */
return AFPERR_NOITEM;