/*
- * $Id: fork.c,v 1.54 2005-04-28 20:49:43 bfernhomberg Exp $
+ * $Id: fork.c,v 1.55 2005-09-28 09:46:37 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
vol = ofork->of_vol;
dir = ofork->of_dir;
- if (NULL == (path.u_name = mtoupath(vol, ofork->of_name, dir->d_did, utf8_encoding()))) {
+ if (NULL == (path.u_name = mtoupath(vol, of_name(ofork), dir->d_did, utf8_encoding()))) {
return( AFPERR_MISC );
}
- path.m_name = ofork->of_name;
+ path.m_name = of_name(ofork);
st = &path.st;
if ( bitmap & ( (1<<FILPBIT_DFLEN) | (1<<FILPBIT_EXTDFLEN) |
(1<<FILPBIT_FNUM) | (1 << FILPBIT_CDATE) |
goto afp_setfork_err;
if (ad_flush( ofork->of_ad, ADFLAGS_HF ) < 0) {
- LOG(log_error, logtype_afpd, "afp_setforkparams(%s): ad_flush: %s", ofork->of_name, strerror(errno) );
+ LOG(log_error, logtype_afpd, "afp_setforkparams(%s): ad_flush: %s", of_name(ofork), strerror(errno) );
return AFPERR_PARAM;
}
} else
#ifdef AFS
if ( flushfork( ofork ) < 0 ) {
- LOG(log_error, logtype_afpd, "afp_setforkparams(%s): flushfork: %s", ofork->of_name, strerror(errno) );
+ LOG(log_error, logtype_afpd, "afp_setforkparams(%s): flushfork: %s", of_name(ofork), strerror(errno) );
}
#endif /* AFS */
if ( ad_hfileno( of->of_ad ) == -1 || !memcmp( ufinderi, ad_entry( of->of_ad, ADEID_FINDERI),8)) {
/* no resource fork or no finderinfo, use our files extension mapping */
- if (!( em = getextmap( of->of_name )) || memcmp( "TEXT", em->em_type, sizeof( em->em_type ))) {
+ if (!( em = getextmap( of_name(of) )) || memcmp( "TEXT", em->em_type, sizeof( em->em_type ))) {
return 0;
}
/* file type is TEXT */
cc = ad_read(ofork->of_ad, eid, offset, rbuf, *rbuflen);
if ( cc < 0 ) {
- LOG(log_error, logtype_afpd, "afp_read(%s): ad_read: %s", ofork->of_name, strerror(errno) );
+ LOG(log_error, logtype_afpd, "afp_read(%s): ad_read: %s", of_name(ofork), strerror(errno) );
*rbuflen = 0;
return( AFPERR_PARAM );
}
if (errno == EINVAL || errno == ENOSYS)
goto afp_read_loop;
else {
- LOG(log_error, logtype_afpd, "afp_read(%s): ad_readfile: %s", ofork->of_name, strerror(errno));
+ LOG(log_error, logtype_afpd, "afp_read(%s): ad_readfile: %s", of_name(ofork), strerror(errno));
goto afp_read_exit;
}
}
goto afp_read_done;
afp_read_exit:
- LOG(log_error, logtype_afpd, "afp_read(%s): %s", ofork->of_name, strerror(errno));
+ LOG(log_error, logtype_afpd, "afp_read(%s): %s", of_name(ofork), strerror(errno));
dsi_readdone(dsi);
ad_tmplock(ofork->of_ad, eid, ADLOCK_CLR, saveoff, savereqcount,ofork->of_refnum);
obj->exit(EXITERR_CLNT);
}
if ( flushfork( ofork ) < 0 ) {
- LOG(log_error, logtype_afpd, "afp_flushfork(%s): %s", ofork->of_name, strerror(errno) );
+ LOG(log_error, logtype_afpd, "afp_flushfork(%s): %s", of_name(ofork), strerror(errno) );
}
return( AFP_OK );
if ( ad_dfileno( ofork->of_ad ) != -1 &&
fsync( ad_dfileno( ofork->of_ad )) < 0 ) {
LOG(log_error, logtype_afpd, "flushfork(%s): dfile(%d) %s",
- ofork->of_name, ad_dfileno(ofork->of_ad), strerror(errno) );
+ of_name(ofork), ad_dfileno(ofork->of_ad), strerror(errno) );
err = -1;
}
if (err < 0)
LOG(log_error, logtype_afpd, "flushfork(%s): hfile(%d) %s",
- ofork->of_name, ad_hfileno(ofork->of_ad), strerror(errno) );
+ of_name(ofork), ad_hfileno(ofork->of_ad), strerror(errno) );
}
return( err );
return( AFPERR_PARAM );
}
if ( of_closefork( ofork ) < 0 ) {
- LOG(log_error, logtype_afpd, "afp_closefork(%s): of_closefork: %s", ofork->of_name, strerror(errno) );
+ LOG(log_error, logtype_afpd, "afp_closefork(%s): of_closefork: %s", of_name(ofork), strerror(errno) );
return( AFPERR_PARAM );
}
case ENOSPC :
return( AFPERR_DFULL );
default :
- LOG(log_error, logtype_afpd, "afp_write(%s): ad_write: %s", ofork->of_name, strerror(errno) );
+ LOG(log_error, logtype_afpd, "afp_write(%s): ad_write: %s", of_name(ofork), strerror(errno) );
return( AFPERR_PARAM );
}
}
if ( ad_hfileno( ofork->of_ad ) != -1 ) {
if ( ad_refresh( ofork->of_ad ) < 0 ) {
- LOG(log_error, logtype_afpd, "getforkparams(%s): ad_refresh: %s", ofork->of_name, strerror(errno) );
+ LOG(log_error, logtype_afpd, "getforkparams(%s): ad_refresh: %s", of_name(ofork), strerror(errno) );
return( AFPERR_PARAM );
}
}
/*
- * $Id: ofork.c,v 1.23 2005-07-20 21:23:52 didg Exp $
+ * $Id: ofork.c,v 1.24 2005-09-28 09:46:37 didg Exp $
*
* Copyright (c) 1996 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
for ( ofrefnum = 0; ofrefnum < nforks; ofrefnum++ ) {
if ( oforks[ ofrefnum ] != NULL ) {
- fprintf( f, "%hu <%s>\n", ofrefnum, oforks[ ofrefnum ]->of_name);
+ fprintf( f, "%hu <%s>\n", ofrefnum, of_name(oforks[ ofrefnum ]);
}
}
}
const char *oldpath _U_, *newpath;
{
struct ofork *of, *next, *d_ofork;
+ int done = 0;
if (!s_of)
return AFP_OK;
if (vol == of->of_vol && olddir == of->of_dir &&
s_of->key.dev == of->key.dev &&
s_of->key.inode == of->key.inode ) {
- strlcpy( of->of_name, newpath, of->of_namelen);
+ if (!done) {
+ strlcpy( of_name(of), newpath, of->of_ad->ad_m_namelen);
+ done = 1;
+ }
if (newdir != olddir) {
of->of_d_prev->of_d_next = of->of_d_next;
of->of_d_next->of_d_prev = of->of_d_prev;
int i;
if (!oforks) {
- nforks = (getdtablesize() - 10) / 2;
+ nforks = getdtablesize() - 10;
/* protect against insane ulimit -n */
nforks = min(nforks, 0xffff);
oforks = (struct ofork **) calloc(nforks, sizeof(struct ofork *));
}
of = oforks[of_refnum];
- /* 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 */
- of->of_namelen = 255 +1;
- if (( of->of_name =(char *)malloc( of->of_namelen )) == NULL ) {
- LOG(log_error, logtype_afpd, "of_alloc: malloc: %s", strerror(errno) );
- free(of);
- oforks[ of_refnum ] = NULL;
- return NULL;
- }
-
/* see if we need to allocate space for the adouble struct */
if (!ad) {
ad = malloc( sizeof( struct adouble ) );
if (!ad) {
LOG(log_error, logtype_afpd, "of_alloc: malloc: %s", strerror(errno) );
- free(of->of_name);
free(of);
oforks[ of_refnum ] = NULL;
return NULL;
/* initialize to zero. This is important to ensure that
ad_open really does reinitialize the structure. */
ad_init(ad, vol->v_adouble, vol->v_ad_options);
+
+ ad->ad_m_namelen = 255 +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 ) {
+ 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. */
d_ofork->of_d_prev = of;
}
- strlcpy( of->of_name, path, of->of_namelen);
*ofrefnum = refnum;
of->of_refnum = refnum;
of->key.dev = st->st_dev;
}
oforks[ of->of_refnum % nforks ] = NULL;
- free( of->of_name );
/* decrease refcount */
of->of_ad->ad_refcount--;
if ( of->of_ad->ad_refcount <= 0) {
+ free( of->of_ad->ad_m_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);