]> arthur.barton.de Git - netatalk.git/commitdiff
Fix ad rm
authorFrank Lahm <franklahm@googlemail.com>
Sat, 16 Apr 2011 19:39:32 +0000 (21:39 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Sat, 16 Apr 2011 19:39:32 +0000 (21:39 +0200)
bin/ad/ad_util.c
libatalk/util/cnid.c

index 8aafd667c61f947bd96f23fc2a995d02712281ed..4a8ff11b62ecee83730290246975aa2ee597fa8c 100644 (file)
@@ -274,15 +274,16 @@ cnid_t cnid_for_path(const afpvol_t *vol,
     struct bstrList *l = NULL;
     struct stat st;
 
-    *did = htonl(1);
     cnid = htonl(2);
 
     EC_NULL(rpath = rel_path_in_vol(path, vol->volinfo.v_path));
     EC_NULL(statpath = bfromcstr(vol->volinfo.v_path));
+    EC_ZERO(bcatcstr(statpath, "/"));
 
     l = bsplit(rpath, '/');
     for (int i = 0; i < l->qty ; i++) {
         *did = cnid;
+
         EC_ZERO(bconcat(statpath, l->entry[i]));
         EC_ZERO_LOGSTR(lstat(cfrombstr(statpath), &st),
                        "lstat(rpath: %s, elem: %s): %s: %s",
index 8870224aee5d6cb47a1623fdc5403711e2c9ef8b..375309071d57bce7f5fd5317a69231069d343d52 100644 (file)
@@ -119,7 +119,11 @@ bstring rel_path_in_vol(const char *path, const char *volpath)
      *   volpath: /Volume/netatalk/
      * we want: "dir/bla"
      */
-    EC_ZERO(bdelete(fpath, 0, strlen(volpath)));
+    int len = strlen(volpath);
+    if (volpath[len-1] != '/')
+        /* in case volpath has no trailing slash */
+        len ++;
+    EC_ZERO(bdelete(fpath, 0, len));
 
 EC_CLEANUP:
     if (dname) free(dname);