/*
- * $Id: filedir.c,v 1.56 2009-10-13 22:55:37 didg Exp $
+ * $Id: filedir.c,v 1.62 2009-10-29 12:58:11 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
-#include <dirent.h>
#include <errno.h>
#include <sys/param.h>
#include <atalk/util.h>
#include <atalk/cnid.h>
#include <atalk/logger.h>
+#include <atalk/unix.h>
#include "directory.h"
#include "desktop.h"
}
#endif
-int afp_getfildirparams(AFPObj *obj _U_, char *ibuf, int ibuflen _U_, char *rbuf, int *rbuflen)
+int afp_getfildirparams(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf, size_t *rbuflen)
{
struct stat *st;
struct vol *vol;
struct dir *dir;
u_int32_t did;
- int buflen, ret;
+ int ret;
+ size_t buflen;
u_int16_t fbitmap, dbitmap, vid;
struct path *s_path;
-#ifdef DEBUG
- LOG(log_info, logtype_afpd, "begin afp_getfildirparams:");
-#endif /* DEBUG */
-
*rbuflen = 0;
ibuf += 2;
rbuf += sizeof( dbitmap ) + sizeof( u_char );
*rbuf = 0;
-#ifdef DEBUG
- LOG(log_info, logtype_afpd, "end afp_getfildirparams:");
-#endif /* DEBUG */
-
return( AFP_OK );
}
-int afp_setfildirparams(AFPObj *obj, char *ibuf, int ibuflen _U_, char *rbuf _U_, int *rbuflen)
+int afp_setfildirparams(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen)
{
struct stat *st;
struct vol *vol;
u_int16_t vid, bitmap;
int did, rc;
-#ifdef DEBUG
- LOG(log_info, logtype_afpd, "begin afp_setfildirparams:");
-#endif /* DEBUG */
-
*rbuflen = 0;
ibuf += 2;
memcpy( &vid, ibuf, sizeof(vid));
setvoltime(obj, vol );
}
-#ifdef DEBUG
- LOG(log_info, logtype_afpd, "end afp_setfildirparams:");
-#endif /* DEBUG */
-
return( rc );
}
if ((vol->v_flags & AFPVOL_NOHEX) && strchr(name, '/'))
return AFPERR_PARAM;
- if (!vol->vfs->validupath(vol, name)) {
+ if (!vol->vfs->vfs_validupath(vol, name)) {
LOG(log_info, logtype_afpd, "check_name: illegal name: '%s'", name);
return AFPERR_EXIST;
}
}
/* -------------------------------------------- */
-int afp_rename(AFPObj *obj, char *ibuf, int ibuflen _U_, char *rbuf _U_, int *rbuflen)
+int afp_rename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen)
{
struct vol *vol;
struct dir *sdir;
u_int16_t vid;
int isdir = 0;
int rc;
-#ifdef DEBUG
- LOG(log_info, logtype_afpd, "begin afp_rename:");
-#endif /* DEBUG */
*rbuflen = 0;
ibuf += 2;
setvoltime(obj, vol );
}
-#ifdef DEBUG
- LOG(log_info, logtype_afpd, "end afp_rename:");
-#endif /* DEBUG */
-
return( rc );
}
/* ------------------------------- */
-int afp_delete(AFPObj *obj, char *ibuf, int ibuflen _U_, char *rbuf _U_, int *rbuflen)
+int afp_delete(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen)
{
struct vol *vol;
struct dir *dir;
int did, rc;
u_int16_t vid;
-#ifdef DEBUG
- LOG(log_info, logtype_afpd, "begin afp_delete:");
-#endif /* DEBUG */
-
*rbuflen = 0;
ibuf += 2;
} else if (of_findname(s_path)) {
rc = AFPERR_BUSY;
} else {
- rc = deletefile(vol, upath, 1);
+ /* it's a file st_valid should always be true
+ * only test for ENOENT because EACCES needs
+ * to read meta data in deletefile
+ */
+ if (s_path->st_valid && s_path->st_errno == ENOENT) {
+ rc = AFPERR_NOOBJ;
+ }
+ else {
+ rc = deletefile(vol, upath, 1);
+ }
}
if ( rc == AFP_OK ) {
curdir->offcnt--;
setvoltime(obj, vol );
}
-#ifdef DEBUG
- LOG(log_info, logtype_afpd, "end afp_delete:");
-#endif /* DEBUG */
-
return( rc );
}
/* ------------------------ */
}
/* ------------------------- */
-int afp_moveandrename(AFPObj *obj, char *ibuf, int ibuflen _U_, char *rbuf _U_, int *rbuflen)
+int afp_moveandrename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size_t *rbuflen)
{
struct vol *vol;
struct dir *sdir, *ddir;
int retvalue;
#endif /* DROPKLUDGE */
-#ifdef DEBUG
- LOG(log_info, logtype_afpd, "begin afp_moveandrename:");
-#endif /* DEBUG */
-
*rbuflen = 0;
ibuf += 2;
int admode = ad_mode("", 0777) | vol->v_fperm;
setfilmode(upath, admode, NULL, vol->v_umask);
- vol->vfs->rf_setfilmode(vol, upath, admode, NULL);
+ vol->vfs->vfs_setfilmode(vol, upath, admode, NULL);
}
setvoltime(obj, vol );
}
-#ifdef DEBUG
- LOG(log_info, logtype_afpd, "end afp_moveandrename:");
-#endif /* DEBUG */
-
return( rc );
}