]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/filedir.c
remove gcc warnings and cleanup inline mess
[netatalk.git] / etc / afpd / filedir.c
index f5d2367b282deb3c9e0143d72656f7c7c9b85ea0..93a9c9940c90afdcbf60a9e58289f5dc5556f13c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $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.
@@ -130,9 +130,9 @@ more information */
 #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;
@@ -225,9 +225,9 @@ int         ibuflen, *rbuflen;
 }
 
 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;
@@ -337,16 +337,15 @@ int         isdir;
     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;
     
@@ -400,28 +399,16 @@ int         isdir;
     }
 
     /* 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;
@@ -453,9 +440,9 @@ int         isdir;
 
 /* -------------------------------------------- */
 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;
@@ -516,7 +503,7 @@ int         ibuflen, *rbuflen;
     }
 
     /* 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 );
     }
 
@@ -539,9 +526,9 @@ int         ibuflen, *rbuflen;
 
 /* ------------------------------- */
 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;
@@ -582,7 +569,7 @@ int         ibuflen, *rbuflen;
            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;
@@ -656,9 +643,9 @@ char        *name;
 
 /* ------------------------- */
 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;
@@ -732,7 +719,7 @@ int         ibuflen, *rbuflen;
     }
 
     /* 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 );
     }
 
@@ -761,7 +748,7 @@ int         ibuflen, *rbuflen;
 #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);