]> arthur.barton.de Git - netatalk.git/blobdiff - bin/ad/ad_mv.c
Support for using $u username variable in AFP volume definitions
[netatalk.git] / bin / ad / ad_mv.c
index 7dab6c6fc35102cb7118414e0e13a352deb61b7a..3fdf1ea97ed052418913759c26b19168ad899be2 100644 (file)
@@ -34,7 +34,6 @@
 #include <atalk/util.h>
 #include <atalk/unix.h>
 #include <atalk/volume.h>
-#include <atalk/volinfo.h>
 #include <atalk/bstrlib.h>
 #include <atalk/bstradd.h>
 #include <atalk/queue.h>
@@ -51,31 +50,9 @@ static int fflg, iflg, nflg, vflg;
 static afpvol_t svolume, dvolume;
 static cnid_t did, pdid;
 static volatile sig_atomic_t alarmed;
-static char           *netatalk_dirs[] = {
-    ".AppleDouble",
-    ".AppleDB",
-    ".AppleDesktop",
-    NULL
-};
 
 static int copy(const char *, const char *);
 static int do_move(const char *, const char *);
-static void preserve_fd_acls(int source_fd, int dest_fd, const char *source_path,
-                             const char *dest_path);
-/*
-  Check for netatalk special folders e.g. ".AppleDB" or ".AppleDesktop"
-  Returns pointer to name or NULL.
-*/
-static const char *check_netatalk_dirs(const char *name)
-{
-    int c;
-
-    for (c=0; netatalk_dirs[c]; c++) {
-        if ((strcmp(name, netatalk_dirs[c])) == 0)
-            return netatalk_dirs[c];
-    }
-    return NULL;
-}
 
 /*
   SIGNAL handling:
@@ -140,7 +117,7 @@ static void usage_mv(void)
     exit(EXIT_FAILURE);
 }
 
-int ad_mv(int argc, char *argv[])
+int ad_mv(int argc, char *argv[], AFPObj *obj)
 {
     size_t baselen, len;
     int rval;
@@ -185,7 +162,7 @@ int ad_mv(int argc, char *argv[])
 
     set_signal();
     cnid_init();
-    if (openvol(argv[argc - 1], &dvolume) != 0) {
+    if (openvol(obj, argv[argc - 1], &dvolume) != 0) {
         SLOG("Error opening CNID database for source \"%s\": ", argv[argc - 1]);
         return 1;
     }
@@ -197,7 +174,7 @@ int ad_mv(int argc, char *argv[])
     if (stat(argv[argc - 1], &sb) || !S_ISDIR(sb.st_mode)) {
         if (argc > 2)
             usage_mv();
-        if (openvol(argv[0], &svolume) != 0) {
+        if (openvol(obj, argv[0], &svolume) != 0) {
             SLOG("Error opening CNID database for destination \"%s\": ", argv[0]);
             return 1;
         }
@@ -235,7 +212,7 @@ int ad_mv(int argc, char *argv[])
             rval = 1;
         } else {
             memmove(endp, p, (size_t)len + 1);
-            openvol(*argv, &svolume);
+            openvol(obj, *argv, &svolume);
 
             if (do_move(*argv, path))
                 rval = 1;
@@ -243,7 +220,6 @@ int ad_mv(int argc, char *argv[])
         }
     }
 
-exit:
     closevol(&dvolume);
     return rval;
 }
@@ -295,14 +271,14 @@ static int do_move(const char *from, const char *to)
      * 1) source AFP volume != dest AFP volume
      * 2) either source or dest isn't even an AFP volume
      */
-    if (!svolume.volinfo.v_path
-        || !dvolume.volinfo.v_path
-        || strcmp(svolume.volinfo.v_path, dvolume.volinfo.v_path) != 0)
+    if (!svolume.vol->v_path
+        || !dvolume.vol->v_path
+        || strcmp(svolume.vol->v_path, dvolume.vol->v_path) != 0)
         mustcopy = 1;
     
     cnid_t cnid = 0;
     if (!mustcopy) {
-        if ((cnid = cnid_for_path(&svolume, from, &did)) == CNID_INVALID) {
+        if ((cnid = cnid_for_path(svolume.vol->v_cdb, svolume.vol->v_path, from, &did)) == CNID_INVALID) {
             SLOG("Couldn't resolve CNID for %s", from);
             return -1;
         }
@@ -340,7 +316,7 @@ static int do_move(const char *from, const char *to)
         
         switch (sb.st_mode & S_IFMT) {
         case S_IFREG:
-            if (dvolume.volume.vfs->vfs_renamefile(&dvolume.volume, -1, from, to) != 0) {
+            if (dvolume.vol->vfs->vfs_renamefile(dvolume.vol, -1, from, to) != 0) {
                 SLOG("Error moving adouble file for %s", from);
                 return -1;
             }
@@ -366,14 +342,14 @@ static int do_move(const char *from, const char *to)
 
         char *p = strdup(to);
         char *name = basename(p);
-        if (cnid_update(dvolume.volume.v_cdb, cnid, &sb, newdid, name, strlen(name)) != 0) {
+        if (cnid_update(dvolume.vol->v_cdb, cnid, &sb, newdid, name, strlen(name)) != 0) {
             SLOG("Cant update CNID for: %s", to);
             return 1;
         }
         free(p);
 
         struct adouble ad;
-        ad_init_old(&ad, dvolume.volinfo.v_adouble, dvolume.volinfo.v_ad_options);
+        ad_init(&ad, dvolume.vol);
         if (ad_open(&ad, to, S_ISDIR(sb.st_mode) ? (ADFLAGS_DIR | ADFLAGS_HF | ADFLAGS_RDWR) : ADFLAGS_HF | ADFLAGS_RDWR) != 0) {
             SLOG("Error opening adouble for: %s", to);
             return 1;
@@ -466,12 +442,3 @@ static int copy(const char *from, const char *to)
     }
     return 0;
 }
-
-static void
-preserve_fd_acls(int source_fd,
-                 int dest_fd,
-                 const char *source_path,
-                 const char *dest_path)
-{
-    ;
-}