X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=etc%2Fafpd%2Ffile.c;h=050046422bbf3633dac17cbe4bbb7e1b4ffe39f1;hb=b01f5d40bb4e03ba7d40238fe58317df0e2f76d2;hp=f2b97209cfb820a557687568295b6b768da7d2c9;hpb=6dcaba1d633e3cfa96243c62ad8399f7e5558c48;p=netatalk.git diff --git a/etc/afpd/file.c b/etc/afpd/file.c index f2b97209..05004642 100644 --- a/etc/afpd/file.c +++ b/etc/afpd/file.c @@ -1,5 +1,5 @@ /* - * $Id: file.c,v 1.111 2009-10-02 09:32:40 franklahm Exp $ + * $Id: file.c,v 1.118 2009-10-29 13:17:28 didg Exp $ * * Copyright (c) 1990,1993 Regents of The University of Michigan. * All Rights Reserved. See COPYRIGHT. @@ -29,7 +29,6 @@ char *strchr (), *strrchr (); #endif /* STDC_HEADERS */ #include -#include #include #include @@ -39,6 +38,8 @@ char *strchr (), *strrchr (); #include #include #include +#include + #include "directory.h" #include "desktop.h" #include "volume.h" @@ -238,7 +239,7 @@ u_int32_t aint = 0; int getmetadata(struct vol *vol, u_int16_t bitmap, struct path *path, struct dir *dir, - char *buf, int *buflen, struct adouble *adp) + char *buf, size_t *buflen, struct adouble *adp) { char *data, *l_nameoff = NULL, *upath; char *utf_nameoff = NULL; @@ -252,7 +253,7 @@ int getmetadata(struct vol *vol, struct maccess ma; #ifdef DEBUG - LOG(log_info, logtype_afpd, "begin getmetadata:"); + LOG(log_debug, logtype_afpd, "begin getmetadata:"); #endif /* DEBUG */ upath = path->u_name; @@ -510,7 +511,7 @@ int getmetadata(struct vol *vol, int getfilparams(struct vol *vol, u_int16_t bitmap, struct path *path, struct dir *dir, - char *buf, int *buflen ) + char *buf, size_t *buflen ) { struct adouble ad, *adp; struct ofork *of; @@ -519,7 +520,7 @@ int getfilparams(struct vol *vol, int rc; #ifdef DEBUG - LOG(log_info, logtype_default, "begin getfilparams:"); + LOG(log_debug, logtype_default, "begin getfilparams:"); #endif /* DEBUG */ opened = PARAM_NEED_ADP(bitmap); @@ -556,17 +557,14 @@ int getfilparams(struct vol *vol, ad_close_metadata( adp); } #ifdef DEBUG - LOG(log_info, logtype_afpd, "end getfilparams:"); + LOG(log_debug, logtype_afpd, "end getfilparams:"); #endif /* DEBUG */ return( rc ); } /* ----------------------------- */ -int afp_createfile(obj, ibuf, ibuflen, rbuf, rbuflen ) -AFPObj *obj; -char *ibuf, *rbuf _U_; -int ibuflen _U_, *rbuflen; +int afp_createfile(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) { struct adouble ad, *adp; struct vol *vol; @@ -577,10 +575,6 @@ int ibuflen _U_, *rbuflen; u_int16_t vid; struct path *s_path; -#ifdef DEBUG - LOG(log_info, logtype_afpd, "begin afp_createfile:"); -#endif /* DEBUG */ - *rbuflen = 0; ibuf++; creatf = (unsigned char) *ibuf++; @@ -682,17 +676,10 @@ createfile_done: setvoltime(obj, vol ); -#ifdef DEBUG - LOG(log_info, logtype_afpd, "end afp_createfile"); -#endif /* DEBUG */ - return (retvalue); } -int afp_setfilparams(obj, ibuf, ibuflen, rbuf, rbuflen ) -AFPObj *obj; -char *ibuf, *rbuf _U_; -int ibuflen _U_, *rbuflen; +int afp_setfilparams(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) { struct vol *vol; struct dir *dir; @@ -700,10 +687,6 @@ int ibuflen _U_, *rbuflen; int did, rc; u_int16_t vid, bitmap; -#ifdef DEBUG - LOG(log_info, logtype_afpd, "begin afp_setfilparams:"); -#endif /* DEBUG */ - *rbuflen = 0; ibuf += 2; @@ -746,10 +729,6 @@ int ibuflen _U_, *rbuflen; setvoltime(obj, vol ); } -#ifdef DEBUG - LOG(log_info, logtype_afpd, "end afp_setfilparams:"); -#endif /* DEBUG */ - return( rc ); } @@ -785,7 +764,7 @@ int setfilparams(struct vol *vol, u_char finder_buf[32]; #ifdef DEBUG - LOG(log_info, logtype_afpd, "begin setfilparams:"); + LOG(log_debug, logtype_afpd, "begin setfilparams:"); #endif /* DEBUG */ upath = path->u_name; @@ -992,7 +971,7 @@ setfilparam_done: } #ifdef DEBUG - LOG(log_info, logtype_afpd, "end setfilparams:"); + LOG(log_debug, logtype_afpd, "end setfilparams:"); #endif /* DEBUG */ return err; } @@ -1007,15 +986,12 @@ setfilparam_done: * adp adouble struct of src file, if open, or & zeroed one * */ -int renamefile(vol, src, dst, newname, adp ) -const struct vol *vol; -char *src, *dst, *newname; -struct adouble *adp; +int renamefile(const struct vol *vol, char *src, char *dst, char *newname, struct adouble *adp) { int rc; #ifdef DEBUG - LOG(log_info, logtype_afpd, "begin renamefile:"); + LOG(log_debug, logtype_afpd, "begin renamefile:"); #endif /* DEBUG */ if ( unix_rename( src, dst ) < 0 ) { @@ -1046,7 +1022,7 @@ struct adouble *adp; } } - if (vol->vfs->rf_renamefile(vol, src, dst) < 0 ) { + if (vol->vfs->vfs_renamefile(vol, src, dst) < 0 ) { int err; err = errno; @@ -1078,7 +1054,7 @@ struct adouble *adp; ad_close( adp, ADFLAGS_HF ); } #ifdef DEBUG - LOG(log_info, logtype_afpd, "end renamefile:"); + LOG(log_debug, logtype_afpd, "end renamefile:"); #endif /* DEBUG */ return( AFP_OK ); @@ -1155,10 +1131,7 @@ u_int32_t hint; /* ----------------------------------- */ -int afp_copyfile(obj, ibuf, ibuflen, rbuf, rbuflen ) -AFPObj *obj; -char *ibuf, *rbuf _U_; -int ibuflen _U_, *rbuflen; +int afp_copyfile(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) { struct vol *s_vol, *d_vol; struct dir *dir; @@ -1171,10 +1144,6 @@ int ibuflen _U_, *rbuflen; struct adouble ad, *adp; int denyreadset; -#ifdef DEBUG - LOG(log_info, logtype_afpd, "begin afp_copyfile:"); -#endif /* DEBUG */ - *rbuflen = 0; ibuf += 2; @@ -1272,10 +1241,6 @@ int ibuflen _U_, *rbuflen; setvoltime(obj, d_vol ); -#ifdef DEBUG - LOG(log_info, logtype_afpd, "end afp_copyfile:"); -#endif /* DEBUG */ - return( retvalue ); } @@ -1286,7 +1251,7 @@ static int copy_all(const int dfd, const void *buf, ssize_t cc; #ifdef DEBUG - LOG(log_info, logtype_afpd, "begin copy_all:"); + LOG(log_debug, logtype_afpd, "begin copy_all:"); #endif /* DEBUG */ while (buflen > 0) { @@ -1302,7 +1267,7 @@ static int copy_all(const int dfd, const void *buf, } #ifdef DEBUG - LOG(log_info, logtype_afpd, "end copy_all:"); + LOG(log_debug, logtype_afpd, "end copy_all:"); #endif /* DEBUG */ return 0; @@ -1382,10 +1347,8 @@ static int copy_fork(int eid, struct adouble *add, struct adouble *ads) * because we are doing it elsewhere. * currently if newname is NULL then adp is NULL. */ -int copyfile(s_vol, d_vol, src, dst, newname, adp ) -const struct vol *s_vol, *d_vol; -char *src, *dst, *newname; -struct adouble *adp; +int copyfile(const struct vol *s_vol, const struct vol*d_vol, + char *src, char *dst, char *newname, struct adouble *adp) { struct adouble ads, add; int err = 0; @@ -1395,7 +1358,7 @@ struct adouble *adp; struct stat st; #ifdef DEBUG - LOG(log_info, logtype_afpd, "begin copyfile:"); + LOG(log_debug, logtype_afpd, "begin copyfile:"); #endif /* DEBUG */ if (adp == NULL) { @@ -1434,11 +1397,15 @@ struct adouble *adp; } return AFPERR_EXIST; } - /* XXX if the source and the dest don't use the same resource type it's broken - */ + + /* + * XXX if the source and the dest don't use the same resource type it's broken + */ if (ad_reso_fileno(adp) == -1 || 0 == (err = copy_fork(ADEID_RFORK, &add, adp))){ /* copy the data fork */ - err = copy_fork(ADEID_DFORK, &add, adp); + if ((err = copy_fork(ADEID_DFORK, &add, adp)) == 0) { + err = d_vol->vfs->vfs_copyfile(d_vol, src, dst); + } } if (err < 0) { @@ -1472,7 +1439,7 @@ struct adouble *adp; } #ifdef DEBUG - LOG(log_info, logtype_afpd, "end copyfile:"); + LOG(log_debug, logtype_afpd, "end copyfile:"); #endif /* DEBUG */ done: @@ -1522,17 +1489,14 @@ u_int16_t bshort = 0; return 0; } -int deletefile( vol, file, checkAttrib ) -const struct vol *vol; -char *file; -int checkAttrib; +int deletefile(const struct vol *vol, char *file, int checkAttrib) { struct adouble ad; struct adouble *adp = &ad; int adflags, err = AFP_OK; #ifdef DEBUG - LOG(log_info, logtype_afpd, "begin deletefile:"); + LOG(log_debug, logtype_afpd, "begin deletefile:"); #endif /* DEBUG */ /* try to open both forks at once */ @@ -1591,7 +1555,7 @@ int checkAttrib; if (adp && ad_tmplock( &ad, ADEID_DFORK, ADLOCK_WR, 0, 0, 0 ) < 0) { err = AFPERR_BUSY; } - else if (!(err = vol->vfs->rf_deletefile(vol, file)) && !(err = netatalk_unlink( file )) ) { + else if (!(err = vol->vfs->vfs_deletefile(vol, file)) && !(err = netatalk_unlink( file )) ) { cnid_t id; if (checkAttrib && (id = cnid_get(vol->v_cdb, curdir->d_did, file, strlen(file)))) { @@ -1602,7 +1566,7 @@ int checkAttrib; ad_close( &ad, adflags ); /* ad_close removes locks if any */ #ifdef DEBUG - LOG(log_info, logtype_afpd, "end deletefile:"); + LOG(log_debug, logtype_afpd, "end deletefile:"); #endif /* DEBUG */ return err; @@ -1610,10 +1574,7 @@ int checkAttrib; /* ------------------------------------ */ /* return a file id */ -int afp_createid(obj, ibuf, ibuflen, rbuf, rbuflen ) -AFPObj *obj _U_; -char *ibuf, *rbuf; -int ibuflen _U_, *rbuflen; +int afp_createid(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen) { struct stat *st; struct vol *vol; @@ -1624,10 +1585,6 @@ int ibuflen _U_, *rbuflen; u_short vid; struct path *s_path; -#ifdef DEBUG - LOG(log_info, logtype_afpd, "begin afp_createid:"); -#endif /* DEBUG */ - *rbuflen = 0; ibuf += 2; @@ -1686,9 +1643,6 @@ int ibuflen _U_, *rbuflen; return AFP_OK; } -#ifdef DEBUG - LOG(log_info, logtype_afpd, "ending afp_createid...:"); -#endif /* DEBUG */ return afp_errno; } @@ -1774,26 +1728,20 @@ reenumerate_id(struct vol *vol, char *name, struct dir *dir) /* ------------------------------ resolve a file id */ -int afp_resolveid(obj, ibuf, ibuflen, rbuf, rbuflen ) -AFPObj *obj _U_; -char *ibuf, *rbuf; -int ibuflen _U_, *rbuflen; +int afp_resolveid(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen) { struct vol *vol; struct dir *dir; char *upath; struct path path; - int err, buflen, retry=0; + int err, retry=0; + size_t buflen; cnid_t id, cnid; u_int16_t vid, bitmap; static char buffer[12 + MAXPATHLEN + 1]; int len = 12 + MAXPATHLEN + 1; -#ifdef DEBUG - LOG(log_info, logtype_afpd, "begin afp_resolveid:"); -#endif /* DEBUG */ - *rbuflen = 0; ibuf += 2; @@ -1882,18 +1830,11 @@ retry: *rbuflen = buflen + sizeof(bitmap); memcpy(rbuf, ibuf, sizeof(bitmap)); -#ifdef DEBUG - LOG(log_info, logtype_afpd, "end afp_resolveid:"); -#endif /* DEBUG */ - return AFP_OK; } /* ------------------------------ */ -int afp_deleteid(obj, ibuf, ibuflen, rbuf, rbuflen ) -AFPObj *obj _U_; -char *ibuf, *rbuf _U_; -int ibuflen _U_, *rbuflen; +int afp_deleteid(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) { struct stat st; struct vol *vol; @@ -1906,10 +1847,6 @@ int ibuflen _U_, *rbuflen; static char buffer[12 + MAXPATHLEN + 1]; int len = 12 + MAXPATHLEN + 1; -#ifdef DEBUG - LOG(log_info, logtype_afpd, "begin afp_deleteid:"); -#endif /* DEBUG */ - *rbuflen = 0; ibuf += 2; @@ -1971,10 +1908,6 @@ int ibuflen _U_, *rbuflen; } } -#ifdef DEBUG - LOG(log_info, logtype_afpd, "end afp_deleteid:"); -#endif /* DEBUG */ - return err; } @@ -2027,10 +1960,7 @@ static struct adouble *find_adouble(struct path *path, struct ofork **of, struct #define APPLETEMP ".AppleTempXXXXXX" -int afp_exchangefiles(obj, ibuf, ibuflen, rbuf, rbuflen ) -AFPObj *obj; -char *ibuf, *rbuf _U_ ; -int ibuflen _U_, *rbuflen; +int afp_exchangefiles(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen) { struct stat srcst, destst; struct vol *vol; @@ -2054,10 +1984,6 @@ int ibuflen _U_, *rbuflen; uid_t uid; gid_t gid; -#ifdef DEBUG - LOG(log_info, logtype_afpd, "begin afp_exchangefiles:"); -#endif /* DEBUG */ - *rbuflen = 0; ibuf += 2; @@ -2261,10 +2187,6 @@ int ibuflen _U_, *rbuflen; exit(EXITERR_SYS); } -#ifdef DEBUG - LOG(log_info, logtype_afpd, "ending afp_exchangefiles:"); -#endif /* DEBUG */ - err = AFP_OK; goto err_exchangefile;