/*
- * $Id: filedir.c,v 1.45.2.2.2.11 2004-05-10 18:40:32 didg Exp $
+ * $Id: filedir.c,v 1.45.2.2.2.14.2.5 2008-11-25 15:16:33 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
#endif
int afp_getfildirparams(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj *obj;
+AFPObj *obj _U_;
char *ibuf, *rbuf;
-int ibuflen, *rbuflen;
+int ibuflen _U_, *rbuflen;
{
struct stat *st;
struct vol *vol;
}
int afp_setfildirparams(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj *obj;
-char *ibuf, *rbuf;
-int ibuflen, *rbuflen;
+AFPObj *obj;
+char *ibuf, *rbuf _U_;
+int ibuflen _U_, *rbuflen;
{
struct stat *st;
struct vol *vol;
char *p;
char *upath;
int rc;
- struct stat *st;
+ struct stat *st, nst;
int adflags;
struct adouble ad;
struct adouble *adp;
struct ofork *opened = NULL;
struct path path;
cnid_t id;
- ucs2_t *oldname_w, *newname_w;
- ad_init(&ad, vol->v_adouble);
+ ad_init(&ad, vol->v_adouble, vol->v_ad_options);
adp = &ad;
adflags = 0;
}
/* source == destination. we just silently accept this. */
- if (curdir == sdir) {
+ if ((!isdir && curdir == sdir) || (isdir && curdir == sdir->d_parent)) {
if (strcmp(oldname, newname) == 0)
return AFP_OK;
- /* deal with case insensitive, case-preserving filesystems. */
- if ((stat(upath, st) == 0)) {
- if ((size_t)-1 == (convert_string_allocate(vol->v_volcharset, CH_UCS2, oldname,
- strlen(oldname), (char**) &oldname_w)) ) {
- return AFPERR_MISC; /* conversion error has already been logged */
- }
- if ((size_t)-1 == (convert_string_allocate(vol->v_volcharset, CH_UCS2, newname,
- strlen(newname), (char**) &newname_w)) ) {
- free(oldname_w);
- return AFPERR_MISC; /* conversion error has already been logged */
- }
- if (!strcasecmp_w(oldname_w, newname_w)) {
- free(oldname_w);
- free(newname_w);
+ if (stat(upath, st) == 0) {
+ if (!stat(p, &nst) && !(nst.st_dev == st->st_dev && nst.st_ino == st->st_ino) ) {
+ /* not the same file */
return AFPERR_EXIST;
- }
- free (oldname_w);
- free (newname_w);
+ }
+ errno = 0;
}
} else if (stat(upath, st ) == 0)
return AFPERR_EXIST;
/* -------------------------------------------- */
int afp_rename(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj *obj;
-char *ibuf, *rbuf;
-int ibuflen, *rbuflen;
+AFPObj *obj;
+char *ibuf, *rbuf _U_;
+int ibuflen _U_, *rbuflen;
{
struct vol *vol;
struct dir *sdir;
}
/* another place where we know about the path type */
- if ((plen = copy_path_name(newname, ibuf)) < 0) {
+ if ((plen = copy_path_name(vol, newname, ibuf)) < 0) {
return( AFPERR_PARAM );
}
/* ------------------------------- */
int afp_delete(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj *obj;
-char *ibuf, *rbuf;
-int ibuflen, *rbuflen;
+AFPObj *obj;
+char *ibuf, *rbuf _U_;
+int ibuflen _U_, *rbuflen;
{
struct vol *vol;
struct dir *dir;
rc = AFPERR_ACCESS;
}
else {
- rc = deletecurdir( vol, obj->oldtmp, AFPOBJ_TMPSIZ);
+ rc = deletecurdir( vol, obj->oldtmp);
}
} else if (of_findname(s_path)) {
rc = AFPERR_BUSY;
/* ------------------------- */
int afp_moveandrename(obj, ibuf, ibuflen, rbuf, rbuflen )
-AFPObj *obj;
-char *ibuf, *rbuf;
-int ibuflen, *rbuflen;
+AFPObj *obj;
+char *ibuf, *rbuf _U_;
+int ibuflen _U_, *rbuflen;
{
struct vol *vol;
struct dir *sdir, *ddir;
}
/* one more place where we know about path type */
- if ((plen = copy_path_name(newname, ibuf)) < 0) {
+ if ((plen = copy_path_name(vol, newname, ibuf)) < 0) {
return( AFPERR_PARAM );
}
#endif /* DROPKLUDGE */
/* if unix priv don't try to match perm with dest folder */
if (!isdir && !vol_unix_priv(vol)) {
- int admode = ad_mode("", 0777);
+ int admode = ad_mode("", 0777) | vol->v_perm;
setfilmode(upath, admode, NULL);
setfilmode(vol->ad_path( upath, ADFLAGS_HF ), ad_hf_mode(admode), NULL);