From: Frank Lahm Date: Mon, 12 Mar 2012 14:34:40 +0000 (+0100) Subject: Remove empty adoubel rfork and use UNIX name in struct adouble X-Git-Url: https://arthur.barton.de/gitweb/?a=commitdiff_plain;h=080aff015fa627cab032d6009ff3b27e7c2a46d6;p=netatalk.git Remove empty adoubel rfork and use UNIX name in struct adouble --- diff --git a/etc/afpd/fce_api.c b/etc/afpd/fce_api.c index 69458f08..23991feb 100644 --- a/etc/afpd/fce_api.c +++ b/etc/afpd/fce_api.c @@ -513,24 +513,15 @@ int fce_register_new_file( struct path *path ) int fce_register_file_modification( struct ofork *ofork ) { - char *u_name = NULL; - struct vol *vol; int ret = AFP_OK; - if (ofork == NULL || ofork->of_vol == NULL) + if (ofork == NULL) return AFPERR_PARAM; if (!(fce_ev_enabled & (1 << FCE_FILE_MODIFY))) return ret; - vol = ofork->of_vol; - - if (NULL == (u_name = mtoupath(vol, of_name(ofork), ofork->of_did, utf8_encoding(vol->v_obj)))) - { - return AFPERR_MISC; - } - - ret = register_fce( u_name, false, FCE_FILE_MODIFY ); + ret = register_fce(of_name(ofork), false, FCE_FILE_MODIFY ); return ret; } diff --git a/etc/afpd/fork.c b/etc/afpd/fork.c index f0ccf003..9b41b956 100644 --- a/etc/afpd/fork.c +++ b/etc/afpd/fork.c @@ -64,10 +64,10 @@ static int getforkparams(const AFPObj *obj, struct ofork *ofork, uint16_t bitmap vol = ofork->of_vol; dir = dirlookup(vol, ofork->of_did); - if (NULL == (path.u_name = mtoupath(vol, of_name(ofork), dir->d_did, utf8_encoding(obj)))) { + if (NULL == (path.m_name = utompath(vol, of_name(ofork), dir->d_did, utf8_encoding(obj)))) { return( AFPERR_MISC ); } - path.m_name = of_name(ofork); + path.u_name = of_name(ofork); path.id = 0; st = &path.st; if ( bitmap & ( (1<of_ad, eid, ADLOCK_WR, size, st_size -size, ofork->of_refnum) < 0) { goto afp_setfork_err; } - err = ad_rtruncate(ofork->of_ad, size); + if (ofork->of_ad->ad_vers == AD_VERSION_EA) { +#if HAVE_EAFD + err = sys_lremovexattr(of_name(ofork), AD_EA_RESO); +#else + err = unlink(ofork->of_vol->ad_path(of_name(ofork), 0)); +#endif + } else { + err = ad_rtruncate(ofork->of_ad, size); + } if (st_size > size) ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, size, st_size -size, ofork->of_refnum); if (err < 0) diff --git a/etc/afpd/fork.h b/etc/afpd/fork.h index b8a6d3a9..f5861180 100644 --- a/etc/afpd/fork.h +++ b/etc/afpd/fork.h @@ -26,7 +26,6 @@ struct ofork { uint16_t of_refnum; int of_flags; struct ofork **prevp, *next; -// struct ofork *of_d_prev, *of_d_next; }; #define OPENFORK_DATA (0) @@ -52,7 +51,7 @@ struct ofork { extern struct ofork *writtenfork; #endif -#define of_name(a) (a)->of_ad->ad_m_name +#define of_name(a) (a)->of_ad->ad_name /* in ofork.c */ extern struct ofork *of_alloc (struct vol *, struct dir *, char *, uint16_t *, const int, diff --git a/etc/afpd/ofork.c b/etc/afpd/ofork.c index 5fc6a1d5..fc91c03b 100644 --- a/etc/afpd/ofork.c +++ b/etc/afpd/ofork.c @@ -98,7 +98,9 @@ int of_rename(const struct vol *vol, && s_of->key.dev == of->key.dev && s_of->key.inode == of->key.inode ) { if (!done) { - strlcpy( of_name(of), newpath, of->of_ad->ad_m_namelen); + free(of_name(of)); + if ((of_name(of) = strdup(newpath)) == NULL) + return AFPERR_MISC; done = 1; } if (newdir != olddir) @@ -187,19 +189,13 @@ of_alloc(struct vol *vol, /* initialize to zero. This is important to ensure that ad_open really does reinitialize the structure. */ ad_init(ad, vol); - - ad->ad_m_namelen = UTF8FILELEN_EARLY +1; - /* here's the deal: we allocate enough for the standard mac file length. - * in the future, we'll reallocate in fairly large jumps in case - * of long unicode names */ - if (( ad->ad_m_name =(char *)malloc( ad->ad_m_namelen )) == NULL ) { + if ((ad->ad_name = strdup(path)) == NULL) { LOG(log_error, logtype_afpd, "of_alloc: malloc: %s", strerror(errno) ); free(ad); free(of); oforks[ of_refnum ] = NULL; return NULL; } - strlcpy( ad->ad_m_name, path, ad->ad_m_namelen); } else { /* Increase the refcount on this struct adouble. This is decremented again in oforc_dealloc. */ @@ -380,7 +376,7 @@ void of_dealloc( struct ofork *of) of->of_ad->ad_refcount--; if ( of->of_ad->ad_refcount <= 0) { - free( of->of_ad->ad_m_name ); + free( of->of_ad->ad_name ); free( of->of_ad); } else {/* someone's still using it. just free this user's locks */ ad_unlock(of->of_ad, of->of_refnum, of->of_flags & AFPFORK_ERROR ? 0 : 1); diff --git a/include/atalk/adouble.h b/include/atalk/adouble.h index cfc4302b..5b276a5a 100644 --- a/include/atalk/adouble.h +++ b/include/atalk/adouble.h @@ -217,8 +217,7 @@ struct adouble { int ad_refcount; /* multiple forks may open one adouble */ off_t ad_rlen; /* ressource fork len with AFP 3.0 * * the header parameter size is too small. */ - char *ad_m_name; /* mac name for open fork */ - int ad_m_namelen; + char *ad_name; /* name in server encoding (usually UTF8) */ struct adouble_fops *ad_ops; uint16_t ad_open_forks; /* open forks (by others) */ char ad_data[AD_DATASZ_MAX]; diff --git a/libatalk/adouble/ad_attr.c b/libatalk/adouble/ad_attr.c index bc089ac6..e5fe323f 100644 --- a/libatalk/adouble/ad_attr.c +++ b/libatalk/adouble/ad_attr.c @@ -91,7 +91,6 @@ int ad_setid (struct adouble *adp, const dev_t dev, const ino_t ino , const uint { uint32_t tmp; - LOG(log_maxdebug, logtype_afpd, "ad_setid(\"%s\"): CNID: %" PRIu32 "", adp->ad_m_name, ntohl(id)); ad_setentrylen( adp, ADEID_PRIVID, sizeof(id)); tmp = id; if (adp->ad_vers == AD_VERSION_EA) diff --git a/libatalk/adouble/ad_lock.c b/libatalk/adouble/ad_lock.c index b28304b9..bdae8dc4 100644 --- a/libatalk/adouble/ad_lock.c +++ b/libatalk/adouble/ad_lock.c @@ -362,8 +362,7 @@ int ad_lock(struct adouble *ad, uint32_t eid, int locktype, off_t off, off_t len int type; int ret = 0, fcntl_lock_err = 0; - LOG(log_debug, logtype_default, "ad_lock(\"%s\", %s, %s, off: %jd (%s), len: %jd): BEGIN", - ad->ad_m_name ? ad->ad_m_name : "???", + LOG(log_debug, logtype_default, "ad_lock(%s, %s, off: %jd (%s), len: %jd): BEGIN", eid == ADEID_DFORK ? "data" : "reso", locktypetostr(locktype), (intmax_t)off, @@ -509,8 +508,7 @@ int ad_tmplock(struct adouble *ad, uint32_t eid, int locktype, off_t off, off_t int err; int type; - LOG(log_debug, logtype_default, "ad_tmplock(\"%s\", %s, %s, off: %jd (%s), len: %jd): BEGIN", - ad->ad_m_name ? ad->ad_m_name : "???", + LOG(log_debug, logtype_default, "ad_tmplock(%s, %s, off: %jd (%s), len: %jd): BEGIN", eid == ADEID_DFORK ? "data" : "reso", locktypetostr(locktype), (intmax_t)off, @@ -574,8 +572,7 @@ exit: /* --------------------- */ void ad_unlock(struct adouble *ad, const int fork, int unlckbrl) { - LOG(log_debug, logtype_default, "ad_unlock(\"%s\", unlckbrl: %d): BEGIN", - ad->ad_m_name ? ad->ad_m_name : "???", unlckbrl); + LOG(log_debug, logtype_default, "ad_unlock(unlckbrl: %d): BEGIN", unlckbrl); if (ad_data_fileno(ad) != -1) { adf_unlock(ad, &ad->ad_data_fork, fork, unlckbrl); @@ -584,7 +581,7 @@ void ad_unlock(struct adouble *ad, const int fork, int unlckbrl) adf_unlock(ad, &ad->ad_resource_fork, fork, unlckbrl); } - LOG(log_debug, logtype_default, "ad_unlock(\"%s\"): END", ad->ad_m_name ? ad->ad_m_name : "???"); + LOG(log_debug, logtype_default, "ad_unlock: END"); } /*! @@ -602,8 +599,7 @@ int ad_testlock(struct adouble *ad, int eid, const off_t off) int ret = 0; off_t lock_offset; - LOG(log_debug, logtype_default, "ad_testlock(\"%s\", %s, off: %jd (%s): BEGIN", - ad->ad_m_name ? ad->ad_m_name : "???", + LOG(log_debug, logtype_default, "ad_testlock(%s, off: %jd (%s): BEGIN", eid == ADEID_DFORK ? "data" : "reso", (intmax_t)off, shmdstrfromoff(off));