/*
- * $Id: file.c,v 1.92.2.2.2.25 2004-05-10 18:40:32 didg Exp $
+ * $Id: file.c,v 1.92.2.2.2.31.2.10 2005-02-10 01:23:12 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
*/
const u_char ufinderi[] = {
- 'T', 'E', 'X', 'T', 'U', 'N', 'I', 'X',
0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
void *get_finderinfo(const char *mpath, struct adouble *adp, void *data)
{
struct extmap *em;
- void *ad_finder;
+ void *ad_finder = NULL;
+ int chk_ext = 0;
+
+ if (adp)
+ ad_finder = ad_entry(adp, ADEID_FINDERI);
- if (adp && (ad_finder = ad_entry(adp, ADEID_FINDERI))) {
+ if ((ad_finder != NULL)) {
memcpy(data, ad_finder, 32);
+ /* default type ? */
+ if (!memcmp(ad_finder, ufinderi, 8))
+ chk_ext = 1;
}
else {
memcpy(data, ufinderi, 32);
+ chk_ext = 1;
}
-
- if ((!adp || !memcmp(ad_entry(adp, ADEID_FINDERI),ufinderi , 8 ))
- && (em = getextmap( mpath ))
- ) {
+ /** Only enter if no appledouble information and no finder information found. */
+ if (chk_ext && (em = getextmap( mpath ))) {
memcpy(data, em->em_type, sizeof( em->em_type ));
memcpy((char *)data + 4, em->em_creator, sizeof(em->em_creator));
}
/* -------------------------- */
u_int32_t get_id(struct vol *vol, struct adouble *adp, const struct stat *st,
- const cnid_t did, const char *upath, const int len)
+ const cnid_t did, char *upath, const int len)
{
u_int32_t aint = 0;
#if AD_VERSION > AD_VERSION1
-dev_t dev;
-ino_t ino;
-cnid_t a_did;
-char stamp[ADEDLEN_PRIVSYN];
- /* look in AD v2 header
- * note inode and device are opaques and not in network order
- */
- if (adp
- && sizeof(dev_t) == ad_getentrylen(adp, ADEID_PRIVDEV)
- && sizeof(ino_t) == ad_getentrylen(adp,ADEID_PRIVINO)
- && sizeof(stamp) == ad_getentrylen(adp,ADEID_PRIVSYN)
- && sizeof(cnid_t) == ad_getentrylen(adp, ADEID_DID)
- && sizeof(cnid_t) == ad_getentrylen(adp, ADEID_PRIVID)
-
- ) {
- memcpy(&dev, ad_entry(adp, ADEID_PRIVDEV), sizeof(dev_t));
- memcpy(&ino, ad_entry(adp, ADEID_PRIVINO), sizeof(ino_t));
- memcpy(stamp, ad_entry(adp, ADEID_PRIVSYN), sizeof(stamp));
- memcpy(&a_did, ad_entry(adp, ADEID_DID), sizeof(cnid_t));
-
- if ( ( (vol->v_flags & AFPVOL_NODEV) || dev == st->st_dev)
- && ino == st->st_ino && a_did == did
- && !memcmp(vol->v_stamp, stamp, sizeof(stamp))) {
- memcpy(&aint, ad_entry(adp, ADEID_PRIVID), sizeof(aint));
- return aint;
- }
+
+ if ((aint = ad_getid(adp, st->st_dev, st->st_ino, did, vol->v_stamp))) {
+ return aint;
}
#endif
+
if (vol->v_cdb != NULL) {
aint = cnid_add(vol->v_cdb, st, did, upath, len, aint);
/* Throw errors if cnid_add fails. */
}
}
#if AD_VERSION > AD_VERSION1
- else if (adp && sizeof(dev_t) == ADEDLEN_PRIVDEV && sizeof(ino_t) == ADEDLEN_PRIVINO) {
+ else if (adp ) {
/* update the ressource fork
* for a folder adp is always null
*/
- ad_setid(adp,(vol->v_flags & AFPVOL_NODEV)?0:st->st_dev, st->st_ino, aint, did, vol->v_stamp);
- ad_flush(adp, ADFLAGS_HF);
+ if (ad_setid(adp, st->st_dev, st->st_ino, aint, did, vol->v_stamp)) {
+ ad_flush(adp, ADFLAGS_HF);
+ }
}
#endif
}
attrbits = ((of->of_ad->ad_df.adf_refcount > 0) ? ATTRBIT_DOPEN : 0);
attrbits |= ((of->of_ad->ad_hf.adf_refcount > of->of_ad->ad_df.adf_refcount)? ATTRBIT_ROPEN : 0);
} else {
- ad_init(&ad, vol->v_adouble);
+ ad_init(&ad, vol->v_adouble, vol->v_ad_options);
adp = &ad;
}
if ((of = of_findname(s_path))) {
adp = of->of_ad;
} else {
- ad_init(&ad, vol->v_adouble);
+ ad_init(&ad, vol->v_adouble, vol->v_ad_options);
adp = &ad;
}
if ( creatf) {
struct path *path, u_int16_t f_bitmap, char *buf )
{
struct adouble ad, *adp;
- struct ofork *of;
struct extmap *em;
int bit, isad = 1, err = AFP_OK;
char *upath;
- u_char achar, *fdType, xyy[4];
+ u_char achar, *fdType, xyy[4]; /* uninitialized, OK 310105 */
u_int16_t ashort, bshort;
u_int32_t aint;
u_int32_t upriv;
#endif /* DEBUG */
upath = path->u_name;
- if ((of = of_findname(path))) {
- adp = of->of_ad;
- } else {
- ad_init(&ad, vol->v_adouble);
- adp = &ad;
- }
+ adp = of_ad(vol, path, &ad);
+
if (!vol_unix_priv(vol) && check_access(upath, OPENACC_WR ) < 0) {
return AFPERR_ACCESS;
case FILPBIT_ATTR :
change_mdate = 1;
memcpy(&ashort, buf, sizeof( ashort ));
- if ((ashort & htons(ATTRBIT_INVISIBLE)))
- change_parent_mdate = 1;
buf += sizeof( ashort );
break;
case FILPBIT_CDATE :
switch( bit ) {
case FILPBIT_ATTR :
ad_getattr(adp, &bshort);
+ if ((bshort & htons(ATTRBIT_INVISIBLE)) !=
+ (ashort & htons(ATTRBIT_INVISIBLE) & htons(ATTRBIT_SETCLR)) )
+ change_parent_mdate = 1;
if ( ntohs( ashort ) & ATTRBIT_SETCLR ) {
bshort |= htons( ntohs( ashort ) & ~ATTRBIT_SETCLR );
} else {
)) {
memcpy(finder_buf, ufinderi, 8 );
}
-
memcpy(ad_entry( adp, ADEID_FINDERI ), finder_buf, 32 );
break;
case FILPBIT_UNIXPR :
/* FIXME warning in syslog so admin'd know there's a conflict ?*/
return AFPERR_OLOCK; /* little lie */
}
- if (AFP_OK != ( rc = copyfile(vol, vol, src, dst, newname )) ) {
+ if (AFP_OK != ( rc = copyfile(vol, vol, src, dst, newname, NULL )) ) {
/* on error copyfile delete dest */
return( rc );
}
* create .AppleDouble if the file is already opened, so we
* use a diff one, it's not a pb,ie it's not the same file, yet.
*/
- ad_init(&ad, vol->v_adouble);
+ ad_init(&ad, vol->v_adouble, vol->v_ad_options);
if (!ad_open(dst, ADFLAGS_HF, O_RDWR | O_CREAT, 0666, &ad)) {
ad_close(&ad, ADFLAGS_HF);
if (!unix_rename( adsrc, vol->ad_path( dst, 0 )) )
return( AFP_OK );
}
-int copy_path_name(char *newname, char *ibuf)
+/* ----------------
+ convert a Mac long name to an utf8 name,
+*/
+size_t mtoUTF8(const struct vol *vol, const char *src, size_t srclen, char *dest, size_t destlen)
+{
+size_t outlen;
+
+ if ((size_t)-1 == (outlen = convert_string ( vol->v_maccharset, CH_UTF8_MAC, src, srclen, dest, destlen)) ) {
+ return -1;
+ }
+ return outlen;
+}
+
+/* ---------------- */
+int copy_path_name(const struct vol *vol, char *newname, char *ibuf)
{
char type = *ibuf;
size_t plen = 0;
switch (type) {
case 2:
if (( plen = (unsigned char)*ibuf++ ) != 0 ) {
- strncpy( newname, ibuf, plen );
- newname[ plen ] = '\0';
+ if (afp_version >= 30) {
+ /* convert it to UTF8
+ */
+ if ((plen = mtoUTF8(vol, ibuf, plen, newname, AFPOBJ_TMPSIZ)) == -1)
+ return -1;
+ }
+ else {
+ strncpy( newname, ibuf, plen );
+ newname[ plen ] = '\0';
+ }
if (strlen(newname) != plen) {
/* there's \0 in newname, e.g. it's a pathname not
* only a filename.
int err, retvalue = AFP_OK;
u_int16_t svid, dvid;
+ struct adouble ad, *adp;
+ int denyreadset;
+
#ifdef DEBUG
LOG(log_info, logtype_afpd, "begin afp_copyfile:");
#endif /* DEBUG */
* and locks need to stay coherent. as a result,
* we just balk if the file is opened already. */
- newname = obj->newtmp;
- strcpy( newname, s_path->m_name );
+ adp = of_ad(s_vol, s_path, &ad);
- if (of_findname(s_path))
+ if (ad_open(s_path->u_name , ADFLAGS_DF |ADFLAGS_HF | ADFLAGS_NOHF, O_RDONLY, 0, adp) < 0) {
+ return AFPERR_DENYCONF;
+ }
+ denyreadset = (getforkmode(adp, ADEID_DFORK, AD_FILELOCK_DENY_RD) != 0 ||
+ getforkmode(adp, ADEID_RFORK, AD_FILELOCK_DENY_RD) != 0 );
+ ad_close( adp, ADFLAGS_DF |ADFLAGS_HF );
+ if (denyreadset) {
return AFPERR_DENYCONF;
+ }
+
+ newname = obj->newtmp;
+ strcpy( newname, s_path->m_name );
p = ctoupath( s_vol, curdir, newname );
if (!p) {
}
/* one of the handful of places that knows about the path type */
- if (copy_path_name(newname, ibuf) < 0) {
+ if (copy_path_name(d_vol, newname, ibuf) < 0) {
return( AFPERR_PARAM );
}
/* newname is always only a filename so curdir *is* its
if (NULL == (upath = mtoupath(d_vol, newname, curdir->d_did, utf8_encoding()))) {
return( AFPERR_PARAM );
}
- if ( (err = copyfile(s_vol, d_vol, p, upath , newname)) < 0 ) {
+ if ( (err = copyfile(s_vol, d_vol, p, upath , newname, adp)) < 0 ) {
return err;
}
curdir->offcnt++;
* if newname is NULL (from directory.c) we don't want to copy ressource fork.
* because we are doing it elsewhere.
*/
-int copyfile(s_vol, d_vol, src, dst, newname )
+int copyfile(s_vol, d_vol, src, dst, newname, adp )
const struct vol *s_vol, *d_vol;
char *src, *dst, *newname;
+struct adouble *adp;
{
struct adouble ads, add;
int err = 0;
LOG(log_info, logtype_afpd, "begin copyfile:");
#endif /* DEBUG */
- ad_init(&ads, s_vol->v_adouble);
- ad_init(&add, d_vol->v_adouble);
+ if (adp == NULL) {
+ ad_init(&ads, s_vol->v_adouble, s_vol->v_ad_options);
+ adp = &ads;
+ }
+ ad_init(&add, d_vol->v_adouble, d_vol->v_ad_options);
adflags = ADFLAGS_DF;
if (newname) {
adflags |= ADFLAGS_HF;
}
- if (ad_open(src , adflags | ADFLAGS_NOHF, O_RDONLY, 0, &ads) < 0) {
+ if (ad_open(src , adflags | ADFLAGS_NOHF, O_RDONLY, 0, adp) < 0) {
ret_err = errno;
goto done;
}
+ if (ad_hfileno(adp) == -1) {
+ /* no resource fork, don't create one for dst file */
+ adflags &= ~ADFLAGS_HF;
+ }
+
if (ad_open(dst , adflags | noadouble, O_RDWR|O_CREAT|O_EXCL, 0666, &add) < 0) {
ret_err = errno;
- ad_close( &ads, adflags );
+ ad_close( adp, adflags );
if (EEXIST != ret_err) {
deletefile(d_vol, dst, 0);
goto done;
}
return AFPERR_EXIST;
}
- if (ad_hfileno(&ads) == -1 || 0 == (err = copy_fd(ad_hfileno(&add), ad_hfileno(&ads)))){
+ if (ad_hfileno(adp) == -1 || 0 == (err = copy_fd(ad_hfileno(&add), ad_hfileno(adp)))){
/* copy the data fork */
- err = copy_fd(ad_dfileno(&add), ad_dfileno(&ads));
+ err = copy_fd(ad_dfileno(&add), ad_dfileno(adp));
}
/* Now, reopen destination file */
if (err < 0) {
ret_err = errno;
}
- ad_close( &ads, adflags );
+ ad_close( adp, adflags );
if (ad_close( &add, adflags ) <0) {
deletefile(d_vol, dst, 0);
goto done;
}
else {
- ad_init(&add, d_vol->v_adouble);
+ ad_init(&add, d_vol->v_adouble, d_vol->v_ad_options);
if (ad_open(dst , adflags | noadouble, O_RDWR, 0666, &add) < 0) {
ret_err = errno;
}
if (ret_err) {
deletefile(d_vol, dst, 0);
}
-
- /* set dest modification date to src date */
- if (!stat(src, &st)) {
+ else if (!stat(src, &st)) {
+ /* set dest modification date to src date */
struct utimbuf ut;
ut.actime = ut.modtime = st.st_mtime;
utime(dst, &ut);
+ /* FIXME netatalk doesn't use resource fork file date
+ * but maybe we should set its modtime too.
+ */
}
#ifdef DEBUG
/* try to open both forks at once */
adflags = ADFLAGS_DF|ADFLAGS_HF;
+ ad_init(&ad, vol->v_adouble, vol->v_ad_options); /* OK */
while(1) {
- ad_init(&ad, vol->v_adouble); /* OK */
if ( ad_open( file, adflags, O_RDONLY, 0, &ad ) < 0 ) {
switch (errno) {
case ENOENT:
}
else if (!adp) {
/* was EACCESS error try to get only metadata */
- ad_init(&ad, vol->v_adouble); /* OK */
+ ad_init(&ad, vol->v_adouble, vol->v_ad_options); /* OK */
if ( ad_metadata( file , 0, &ad) == 0 ) {
ad_getattr(&ad, &bshort);
ad_close( &ad, ADFLAGS_HF );
DIR *dp;
struct dirent *de;
int ret;
- struct stat st;
cnid_t aint;
- struct adouble ad;
-
-
+ struct path path;
+
+ memset(&path, 0, sizeof(path));
if (vol->v_cdb == NULL) {
return -1;
}
if (NULL == check_dirent(vol, de->d_name))
continue;
- if ( stat(de->d_name, &st)<0 )
+ if ( stat(de->d_name, &path.st)<0 )
continue;
/* update or add to cnid */
- aint = cnid_add(vol->v_cdb, &st, did, de->d_name, strlen(de->d_name), 0); /* ignore errors */
+ aint = cnid_add(vol->v_cdb, &path.st, did, de->d_name, strlen(de->d_name), 0); /* ignore errors */
#if AD_VERSION > AD_VERSION1
- if (aint != CNID_INVALID && !S_ISDIR(st.st_mode)) {
- ad_init(&ad, 0); /* OK */
- if ( ad_open( de->d_name, ADFLAGS_HF, O_RDWR, 0, &ad ) < 0 ) {
+ if (aint != CNID_INVALID && !S_ISDIR(path.st.st_mode)) {
+ struct adouble ad, *adp;
+
+ path.st_errno = 0;
+ path.st_valid = 1;
+ path.u_name = de->d_name;
+
+ adp = of_ad(vol, &path, &ad);
+
+ if ( ad_open( de->d_name, ADFLAGS_HF, O_RDWR, 0, adp ) < 0 ) {
continue;
}
- else {
- ad_setid(&ad,(vol->v_flags & AFPVOL_NODEV)?0:st.st_dev, st.st_ino, aint, did, vol->v_stamp);
- ad_flush(&ad, ADFLAGS_HF);
- ad_close(&ad, ADFLAGS_HF);
- }
+ if (ad_setid(adp, path.st.st_dev, path.st.st_ino, aint, did, vol->v_stamp)) {
+ ad_flush(adp, ADFLAGS_HF);
+ }
+ ad_close(adp, ADFLAGS_HF);
}
#endif /* AD_VERSION > AD_VERSION1 */
}
if ( of_stat(&path) < 0 ) {
+#ifdef ESTALE
+ /* with nfs and our working directory is deleted */
+ if (errno == ESTALE) {
+ errno = ENOENT;
+ }
+#endif
if ( errno == ENOENT && !retry) {
/* cnid db is out of sync, reenumerate the directory and updated ids */
reenumerate_id(vol, ".", id);
case EACCES:
case EPERM:
return AFPERR_ACCESS;
+#ifdef ESTALE
+ case ESTALE:
+#endif
case ENOENT:
/* still try to delete the id */
err = AFPERR_NOOBJ;
/* ------------------------------ */
static struct adouble *find_adouble(struct path *path, struct ofork **of, struct adouble *adp)
{
+ int ret;
+
if (path->st_errno) {
switch (path->st_errno) {
case ENOENT:
}
return NULL;
}
-
+ /* we use file_access both for legacy Mac perm and
+ * for unix privilege, rename will take care of folder perms
+ */
+ if (file_access(path, OPENACC_WR ) < 0) {
+ afp_errno = AFPERR_ACCESS;
+ return NULL;
+ }
+
if ((*of = of_findname(path))) {
- /* reuse struct adouble so it won't break locks */
- adp = (*of)->of_ad;
+ /* reuse struct adouble so it won't break locks */
+ adp = (*of)->of_ad;
}
else {
- ad_open( path->u_name, ADFLAGS_HF, O_RDONLY, 0, adp);
- }
- if ( ad_hfileno( adp ) != -1
- && !(adp->ad_hf.adf_flags & ( O_RDWR | O_WRONLY))
- && sizeof(dev_t) == ad_getentrylen(adp, ADEID_PRIVDEV)
- && sizeof(ino_t) == ad_getentrylen(adp,ADEID_PRIVINO)
- ) {
- /* it's an adouble version 2 with cached resource fork
- * but the file is not open RW so we can't update cnid
- */
- afp_errno = AFPERR_ACCESS;
- return NULL;
+ ret = ad_open( path->u_name, ADFLAGS_HF, O_RDONLY, 0, adp);
+ if ( !ret && ad_hfileno(adp) != -1 && !(adp->ad_hf.adf_flags & ( O_RDWR | O_WRONLY))) {
+ /* from AFP spec.
+ * The user must have the Read & Write privilege for both files in order to use this command.
+ */
+ ad_close(adp, ADFLAGS_HF);
+ afp_errno = AFPERR_ACCESS;
+ return NULL;
+ }
}
return adp;
}
int err;
struct adouble ads;
struct adouble add;
- struct adouble *adsp;
- struct adouble *addp;
- struct ofork *s_of;
- struct ofork *d_of;
+ struct adouble *adsp = NULL;
+ struct adouble *addp = NULL;
+ struct ofork *s_of = NULL;
+ struct ofork *d_of = NULL;
int crossdev;
int slen, dlen;
return AFPERR_BADTYPE; /* it's a dir */
}
- /* XXX
- * here do we need to switch to root ?
- */
-
- ad_init(&ads, vol->v_adouble);
- if (!(adsp = find_adouble( path, &s_of, &ads))) {
- return afp_errno;
- }
-
/* save some stuff */
srcst = path->st;
sdir = curdir;
spath = obj->oldtmp;
supath = obj->newtmp;
strcpy(spath, path->m_name);
- upath = path->u_name;
- strcpy(supath, upath); /* this is for the cnid changing */
- p = absupath( vol, sdir, upath);
+ strcpy(supath, path->u_name); /* this is for the cnid changing */
+ p = absupath( vol, sdir, supath);
if (!p) {
/* pathname too long */
return AFPERR_PARAM ;
}
+
+ ad_init(&ads, vol->v_adouble, vol->v_ad_options);
+ if (!(adsp = find_adouble( path, &s_of, &ads))) {
+ return afp_errno;
+ }
+ /* ***** from here we may have resource fork open **** */
+
/* look for the source cnid. if it doesn't exist, don't worry about
* it. */
sid = cnid_lookup(vol->v_cdb, &srcst, sdir->d_did, supath,slen = strlen(supath));
if (NULL == ( dir = dirlookup( vol, did )) ) {
- return afp_errno; /* was AFPERR_PARAM */
+ err = afp_errno; /* was AFPERR_PARAM */
+ goto err_exchangefile;
}
if (NULL == ( path = cname( vol, dir, &ibuf )) ) {
- return get_afp_errno(AFPERR_NOOBJ);
+ err = get_afp_errno(AFPERR_NOOBJ);
+ goto err_exchangefile;
}
if ( path_isadir(path) ) {
- return AFPERR_BADTYPE;
+ err = AFPERR_BADTYPE;
+ goto err_exchangefile;
}
/* FPExchangeFiles is the only call that can return the SameObj
* error */
- if ((curdir == sdir) && strcmp(spath, path->m_name) == 0)
- return AFPERR_SAMEOBJ;
+ if ((curdir == sdir) && strcmp(spath, path->m_name) == 0) {
+ err = AFPERR_SAMEOBJ;
+ goto err_exchangefile;
+ }
- ad_init(&add, vol->v_adouble);
+ ad_init(&add, vol->v_adouble, vol->v_ad_options);
if (!(addp = find_adouble( path, &d_of, &add))) {
- return afp_errno;
+ err = afp_errno;
+ goto err_exchangefile;
}
destst = path->st;
/* they are not on the same device and at least one is open
+ * FIXME broken for for crossdev and adouble v2
+ * return an error
*/
crossdev = (srcst.st_dev != destst.st_dev);
- if ((d_of || s_of) && crossdev)
- return AFPERR_MISC;
+ if (/* (d_of || s_of) && */ crossdev) {
+ err = AFPERR_MISC;
+ goto err_exchangefile;
+ }
/* look for destination id. */
upath = path->u_name;
* NOTE: the temp file will be in the dest file's directory. it
* will also be inaccessible from AFP. */
memcpy(temp, APPLETEMP, sizeof(APPLETEMP));
- if (!mktemp(temp))
- return AFPERR_MISC;
+ if (!mktemp(temp)) {
+ err = AFPERR_MISC;
+ goto err_exchangefile;
+ }
+
+ if (crossdev) {
+ /* FIXME we need to close fork for copy, both s_of and d_of are null */
+ ad_close(adsp, ADFLAGS_HF);
+ ad_close(addp, ADFLAGS_HF);
+ }
/* now, quickly rename the file. we error if we can't. */
if ((err = renamefile(vol, p, temp, temp, adsp)) != AFP_OK)
}
goto err_temp_to_dest;
}
- if (sid)
- ad_setid(addp,(vol->v_flags & AFPVOL_NODEV)?0:destst.st_dev, destst.st_ino, sid, sdir->d_did, vol->v_stamp);
- if (did)
- ad_setid(adsp,(vol->v_flags & AFPVOL_NODEV)?0:srcst.st_dev, srcst.st_ino, did, curdir->d_did, vol->v_stamp);
-
- if ( !s_of ) {
- ad_flush( adsp, ADFLAGS_HF );
- ad_close(adsp, ADFLAGS_HF);
- }
- if ( !d_of ) {
+
+ /* here we need to reopen if crossdev */
+ if (sid && ad_setid(addp, destst.st_dev, destst.st_ino, sid, sdir->d_did, vol->v_stamp))
+ {
ad_flush( addp, ADFLAGS_HF );
- ad_close(addp, ADFLAGS_HF);
+ }
+
+ if (did && ad_setid(adsp, srcst.st_dev, srcst.st_ino, did, curdir->d_did, vol->v_stamp))
+ {
+ ad_flush( adsp, ADFLAGS_HF );
}
/* change perms, src gets dest perm and vice versa */
gid = getegid();
if (seteuid(0)) {
LOG(log_error, logtype_afpd, "seteuid failed %s", strerror(errno));
- return AFP_OK; /* ignore error */
+ err = AFP_OK; /* ignore error */
+ goto err_temp_to_dest;
}
/*
LOG(log_info, logtype_afpd, "ending afp_exchangefiles:");
#endif /* DEBUG */
- return AFP_OK;
+ err = AFP_OK;
+ goto err_exchangefile;
/* all this stuff is so that we can unwind a failed operation
* properly. */
of_rename(vol, s_of, curdir, temp, sdir, spath);
err_exchangefile:
+ if ( !s_of && adsp && ad_hfileno(adsp) != -1 ) {
+ ad_close(adsp, ADFLAGS_HF);
+ }
+ if ( !d_of && addp && ad_hfileno(addp) != -1 ) {
+ ad_close(addp, ADFLAGS_HF);
+ }
+
return err;
}