]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/filedir.c
IPC for disasociated afpd processes via UNIX domain sockets
[netatalk.git] / etc / afpd / filedir.c
index 0e9c367023a7161dcb2f4c3dfff7c30b7577bbcd..d10c635955668950a6496d57b7e4bca838849d9f 100644 (file)
@@ -351,22 +351,24 @@ static int moveandrename(const struct vol *vol,
     if (!isdir) {
         if ((oldunixname = strdup(mtoupath(vol, oldname, sdir->d_did, utf8_encoding()))) == NULL)
             return AFPERR_PARAM; /* can't convert */
+        id = cnid_get(vol->v_cdb, sdir->d_did, oldunixname, strlen(oldunixname));
 
 #ifndef HAVE_ATFUNCS
         /* Need full path */
-        id = cnid_get(vol->v_cdb, sdir->d_did, p, strlen(p));
-        p = ctoupath( vol, sdir, oldname );
-        if (!p)
+        free(oldunixname);
+        if ((oldunixname = strdup(ctoupath(vol, sdir, oldname))) == NULL)
             return AFPERR_PARAM; /* pathname too long */
 #endif /* HAVE_ATFUNCS */
 
         path.st_valid = 0;
         path.u_name = oldunixname;
+
 #ifdef HAVE_ATFUNCS
         opened = of_findnameat(sdir_fd, &path);
 #else
         opened = of_findname(&path);
 #endif /* HAVE_ATFUNCS */
+
         if (opened) {
             /* reuse struct adouble so it won't break locks */
             adp = opened->of_ad;
@@ -378,8 +380,6 @@ static int moveandrename(const struct vol *vol,
         adflags = ADFLAGS_DIR;
     }
 
-    LOG(log_debug, logtype_afpd, "oldunixname: \"%s\"", oldunixname);
-
     /*
      * oldunixname now points to either
      *   a) full pathname of the source fs object (if renameat is not available)
@@ -445,8 +445,6 @@ static int moveandrename(const struct vol *vol,
         goto exit;
     }
 
-    LOG(log_debug, logtype_afpd, "oldunixname: \"%s\"", oldunixname);
-
     if ( !isdir ) {
         path.st_valid = 1;
         path.st_errno = errno;
@@ -474,6 +472,13 @@ static int moveandrename(const struct vol *vol,
             (void)dir_remove(vol, cacheddir);
         }
 
+        /* Fixup adouble info */
+        if (!ad_metadata(upath, adflags, adp)) {
+            ad_setid(adp, st->st_dev, st->st_ino, id, curdir->d_did, vol->v_stamp);
+            ad_flush(adp);
+            ad_close_metadata(adp);
+        }
+
         /* fix up the catalog entry */
         cnid_update(vol->v_cdb, id, st, curdir->d_did, upath, strlen(upath));
     }
@@ -614,14 +619,14 @@ int afp_delete(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, size
             rc = deletefile(vol, -1, upath, 1);
 
             struct dir *cachedfile;
-            if ((cachedfile = dircache_search_by_name(vol, dir, upath, strlen(upath), s_path->st.st_ctime))) {
+            if ((cachedfile = dircache_search_by_name(vol, dir, upath, strlen(upath)))) {
                 dircache_remove(vol, cachedfile, DIRCACHE | DIDNAME_INDEX | QUEUE_INDEX);
                 dir_free(cachedfile);
             }
         }
     }
     if ( rc == AFP_OK ) {
-        curdir->offcnt--;
+        curdir->d_offcnt--;
         setvoltime(obj, vol );
     }
 
@@ -762,8 +767,8 @@ int afp_moveandrename(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U
             rc = AFPERR_PARAM;
             goto exit;
         }
-        curdir->offcnt++;
-        sdir->offcnt--;
+        curdir->d_offcnt++;
+        sdir->d_offcnt--;
 #ifdef DROPKLUDGE
         if (vol->v_flags & AFPVOL_DROPBOX) {
             /* FIXME did is not always the source id */