/*
- * $Id: file.c,v 1.129 2010-01-06 11:08:53 franklahm Exp $
+ * $Id: file.c,v 1.130 2010-01-06 14:05:15 franklahm Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
u_int32_t get_id(struct vol *vol, struct adouble *adp, const struct stat *st,
const cnid_t did, char *upath, const int len)
{
- u_int32_t aint = 0;
+ u_int32_t adcnid;
+ u_int32_t dbcnid = CNID_INVALID;
if (vol->v_cdb != NULL) {
/* prime aint with what we think is the cnid, set did to zero for
catching moved files */
- aint = ad_getid(adp, st->st_dev, st->st_ino, 0, vol->v_stamp);
+ adcnid = ad_getid(adp, st->st_dev, st->st_ino, 0, vol->v_stamp);
- aint = cnid_add(vol->v_cdb, st, did, upath, len, aint);
+ dbcnid = cnid_add(vol->v_cdb, st, did, upath, len, adcnid);
/* Throw errors if cnid_add fails. */
- if (aint == CNID_INVALID) {
+ if (dbcnid == CNID_INVALID) {
switch (errno) {
case CNID_ERR_CLOSE: /* the db is closed */
break;
return CNID_INVALID;
}
}
- else if (adp ) {
- /* update the ressource fork
- * for a folder adp is always null
- */
- if (ad_setid(adp, st->st_dev, st->st_ino, aint, did, vol->v_stamp)) {
+ else if (adp && (adcnid != dbcnid)) {
+ /* Update the ressource fork. For a folder adp is always null */
+ LOG(log_debug, logtype_afpd, "get_id: calling ad_setid. adcnid: %u, dbcnid: %u", htonl(adcnid), htonl(dbcnid));
+ if (ad_setid(adp, st->st_dev, st->st_ino, dbcnid, did, vol->v_stamp)) {
ad_flush(adp);
}
}
}
- return aint;
+ return dbcnid;
}
/* -------------------------- */
id = get_id(vol, adp, st, dir->d_did, upath, strlen(upath));
else
id = path->id;
- if (id == 0)
+ if (id == CNID_INVALID)
return afp_errno;
if (!path->m_name) {
path->m_name = utompath(vol, upath, id, utf8_encoding());
/*
- * $Id: ad_attr.c,v 1.13 2009-12-23 07:21:08 franklahm Exp $
+ * $Id: ad_attr.c,v 1.14 2010-01-06 14:05:15 franklahm Exp $
*/
#ifdef HAVE_CONFIG_H
* only use the ID if adouble is writable for us.
*/
if (adp
- && ( adp->ad_options & ADVOL_CACHE)
+ && (adp->ad_options & ADVOL_CACHE)
&& (adp->ad_md->adf_flags & O_RDWR )
- && (sizeof(dev_t) == ad_getentrylen(adp, ADEID_PRIVID)) /* One check to ensure ALL values are there */
+ && (sizeof(dev_t) == ad_getentrylen(adp, ADEID_PRIVDEV)) /* One check to ensure ALL values are there */
) {
memcpy(&dev, ad_entry(adp, ADEID_PRIVDEV), sizeof(dev_t));
memcpy(&ino, ad_entry(adp, ADEID_PRIVINO), sizeof(ino_t));
/*
- * $Id: ad_open.c,v 1.67 2010-01-06 12:59:10 franklahm Exp $
+ * $Id: ad_open.c,v 1.68 2010-01-06 14:05:15 franklahm Exp $
*
* Copyright (c) 1999 Adrian Sun (asun@u.washington.edu)
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* ADFLAGS_CREATE: force creation of header file, but only as use, not as root
* @param adp pointer to struct adouble
*
- * @note caller MUST pass ADFLAGS_DIR for directories
+ * @note caller MUST pass ADFLAGS_DIR for directories. Whether ADFLAGS_CREATE really creates
+ * a adouble file depends on various other volume options, eg. ADVOL_CACHE
*/
int ad_metadata(const char *name, int flags, struct adouble *adp)
{
dir = flags & ADFLAGS_DIR;
/* Check if we shall call ad_open with O_CREAT */
- if ( ! (adp->ad_options & ADVOL_NOADOUBLE) && (flags & ADFLAGS_CREATE) )
+ if ( (adp->ad_options & ADVOL_CACHE)
+ && ! (adp->ad_options & ADVOL_NOADOUBLE)
+ && (flags & ADFLAGS_CREATE) )
create = O_CREAT;
if ((ret = ad_open(name, ADFLAGS_HF | dir, O_RDWR | create, 0666, adp)) < 0 && errno == EACCES) {