]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/util/volinfo.c
Fix ad_open, ad_flush, ad_close, VFS stuff and volinfo for adouble:ea, also deactivat...
[netatalk.git] / libatalk / util / volinfo.c
index aa8ec4ab54421e61ae8d7d62656d2f6762463435..3e639f09ff28837bfcdc37d2d931315b27094658 100644 (file)
@@ -139,16 +139,32 @@ static char * make_path_absolute(char *path, size_t bufsize)
     char       abspath[MAXPATHLEN];
     char       *p;
 
-    if (stat(path, &st) != 0) {
-        return NULL;
-    }
+    strlcpy(abspath, path, sizeof(abspath));
+
+    /* we might be called from `ad cp ...` with non existing target */
+    if (stat(abspath, &st) != 0) {
+        if (errno != ENOENT)
+            return NULL;
+
+        if (NULL == (p = strrchr(abspath, '/')) )
+            /* single component `ad cp SOURCEFILE TARGETFILE`, use "." instead */
+            strcpy(abspath, ".");
+        else
+            /* try without the last path element */
+            *p = '\0';
 
-    strlcpy (abspath, path, sizeof(abspath));
+        if (stat(abspath, &st) != 0) {
+            return NULL;
+        }
+    }
 
-    if (!S_ISDIR(st.st_mode)) {
-        if (NULL == (p=strrchr(abspath, '/')) )
+    if (S_ISREG(st.st_mode)) {
+        /* single file copy SOURCE */
+        if (NULL == (p = strrchr(abspath, '/')) )
+            /* no path, use "." instead */
             strcpy(abspath, ".");
         else
+            /* try without the last path element */
             *p = '\0';
     }
 
@@ -272,7 +288,10 @@ static int parseline ( char *buf, struct volinfo *vol)
         }
         break;
       case CNIDDBDPORT:
-        vol->v_dbd_port = atoi(value);
+        if ((vol->v_dbd_port = strdup(value)) == NULL) {
+           fprintf (stderr, "strdup: %s", strerror(errno));
+            return -1;            
+        }
         break;
       case CNID_DBPATH:
         if ((vol->v_dbpath = strdup(value)) == NULL) {
@@ -281,21 +300,14 @@ static int parseline ( char *buf, struct volinfo *vol)
         }
         break;
       case ADOUBLE_VER:
-        if (strcasecmp(value, "v1") == 0) {
-            vol->v_adouble = AD_VERSION1;
-            vol->ad_path = ad_path;
-        }
-#if AD_VERSION == AD_VERSION2
-        else if (strcasecmp(value, "v2") == 0) {
+        if (strcasecmp(value, "v2") == 0) {
             vol->ad_path = ad_path;
             vol->v_adouble = AD_VERSION2;
-        }
-        else if (strcasecmp(value, "osx") == 0) {
-            vol->v_adouble = AD_VERSION2_OSX;
-            vol->ad_path = ad_path_osx;
-        }
-#endif
-        else  {
+        } else if (strcasecmp(value, "ea") == 0) {
+            vol->ad_path = ad_path_ea;
+            vol->v_adouble = AD_VERSION_EA;
+        } else {
+
            fprintf (stderr, "unknown adouble version: %s, %s", buf, value);
            return -1;
         }
@@ -436,17 +448,11 @@ int savevolinfo(const struct vol *vol, const char *Cnid_srv, const char *Cnid_po
     strlcat(buf, item, sizeof(buf));
 
     switch (vol->v_adouble) {
-        case AD_VERSION1:
-            strlcat(buf, "ADOUBLE_VER:v1\n", sizeof(buf));
-            break;
         case AD_VERSION2:
             strlcat(buf, "ADOUBLE_VER:v2\n", sizeof(buf));
             break;
-        case AD_VERSION2_OSX:
-            strlcat(buf, "ADOUBLE_VER:osx\n", sizeof(buf));
-            break;
-        case AD_VERSION1_SFM:
-            strlcat(buf, "ADOUBLE_VER:sfm\n", sizeof(buf));
+        case AD_VERSION_EA:
+            strlcat(buf, "ADOUBLE_VER:ea\n", sizeof(buf));
             break;
     }
 
@@ -492,14 +498,22 @@ int savevolinfo(const struct vol *vol, const char *Cnid_srv, const char *Cnid_po
     strlcat(item, "\n", sizeof(item));
     strlcat(buf, item, sizeof(buf));
 
-    /* ExtendedAttrbutes */
+    /* ExtendedAttributes */
     strcpy(item, "EXTATTRTYPE:");
-    if (vol->v_vfs_ea & AFPVOL_EA_AD)
-        strlcat(item, "AFPVOL_EA_AD", sizeof(item));
-    else if (vol->v_vfs_ea & AFPVOL_EA_SYS)
-        strlcat(item, "AFPVOL_EA_SYS", sizeof(item));
-    else
-        strlcat(item, "AFPVOL_EA_UNKNOWN", sizeof(item));
+    switch (vol->v_vfs_ea) {
+    case AFPVOL_EA_SYS:
+        strlcat(item, "AFPVOL_EA_SYS\n", sizeof(item));
+        break;
+    case AFPVOL_EA_AD:
+        strlcat(item, "AFPVOL_EA_AD\n", sizeof(item));
+        break;
+    case AFPVOL_EA_NONE:
+        strlcat(item, "AFPVOL_EA_NONE\n", sizeof(item));
+        break;
+    default:
+        strlcat(item, "AFPVOL_EA_UNKNOWN\n", sizeof(item));
+    }
+
     strlcat(buf, item, sizeof(buf));
 
     if (strlen(buf) >= sizeof(buf)-1)