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;
}
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<<FILPBIT_DFLEN) | (1<<FILPBIT_EXTDFLEN) |
ad_tmplock(ofork->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)
uint16_t of_refnum;
int of_flags;
struct ofork **prevp, *next;
-// struct ofork *of_d_prev, *of_d_next;
};
#define OPENFORK_DATA (0)
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,
&& 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)
/* 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. */
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);
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];
{
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)
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,
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,
/* --------------------- */
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);
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");
}
/*!
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));