]> arthur.barton.de Git - netatalk.git/commitdiff
Write EA mode to volinfo file
authorfranklahm <franklahm>
Thu, 3 Dec 2009 12:47:36 +0000 (12:47 +0000)
committerfranklahm <franklahm>
Thu, 3 Dec 2009 12:47:36 +0000 (12:47 +0000)
etc/cnid_dbd/cmd_dbd.c
include/atalk/volinfo.h
include/atalk/volume.h
libatalk/util/volinfo.c

index 2579ac952c2a12f98676924287fd155d58c59e59..8ad6e5ad5e53d6bcef3d93ce2d88b4adee53252d 100644 (file)
@@ -1,5 +1,5 @@
 /* 
-   $Id: cmd_dbd.c,v 1.18 2009-12-01 13:37:20 franklahm Exp $
+   $Id: cmd_dbd.c,v 1.19 2009-12-03 12:47:36 franklahm Exp $
 
    Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
    
@@ -367,6 +367,12 @@ int main(int argc, char **argv)
         exit(EXIT_FAILURE);
     }
 
+    /* Sanity checks to ensure we can touch this volume */
+    if (volinfo.v_vfs_ea != AFPVOL_EA_AD && volinfo.v_vfs_ea != AFPVOL_EA_SYS) {
+        dbd_log( LOGSTD, "Unknown Extended Attributes option: %u", volinfo.v_vfs_ea);
+        exit(EXIT_FAILURE);        
+    }
+
     /* Put "/.AppleDB" at end of volpath, get path from volinfo file */
     if ( (strlen(volinfo.v_dbpath) + strlen("/.AppleDB")) > (PATH_MAX - 1) ) {
         dbd_log( LOGSTD, "Volume pathname too long");
index 5c7a59974b357663d356dadd856f42c96537cb89..410b6b2aa0ddb10c1b22dfc25b2f96d46ceb7573 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volinfo.h,v 1.9 2009-12-01 16:36:14 franklahm Exp $
+ * $Id: volinfo.h,v 1.10 2009-12-03 12:47:37 franklahm Exp $
  */
 
 #ifndef _ATALK_VOLINFO_H
@@ -30,14 +30,12 @@ struct volinfo {
     charset_t           v_maccharset;
     int                 v_adouble;  /* default adouble format */
     int                 v_ad_options;
+    int                 v_vfs_ea;
     char                *(*ad_path)(const char *, int);
     char                *v_dbd_host;
     int                 v_dbd_port;
 };
 
-extern const vol_opt_name_t vol_opt_names[];
-extern const vol_opt_name_t vol_opt_casefold[];
-
 extern int loadvolinfo(char *path, struct volinfo *vol);
 extern int savevolinfo(const struct vol *vol, const char *Cnid_srv, const char *Cnid_port);
 extern int vol_load_charsets(struct volinfo *vol);
index cc6f0d98612c72b70ae9ae17c0568a3e200fb650..f8b00c192d589570603170d36295d713bf0241ab 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: volume.h,v 1.7 2009-11-17 12:33:30 franklahm Exp $
+ * $Id: volume.h,v 1.8 2009-12-03 12:47:37 franklahm Exp $
  *
  * Copyright (c) 1990,1994 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -157,8 +157,8 @@ this is going away. */
 #define AFPVOL_ACLS      (1 << 25)   /* Volume supports ACLS */
 
 /* Extended Attributes vfs indirection  */
-#define AFPVOL_EA_AD             0   /* Store them in adouble files. Default. */
-#define AFPVOL_EA_SYS            1   /* Store them in native EAs */
+#define AFPVOL_EA_AD             1   /* Store them in adouble files. Default. */
+#define AFPVOL_EA_SYS            2   /* Store them in native EAs */
 
 /* FPGetSrvrParms options */
 #define AFPSRVR_CONFIGINFO     (1 << 0)
index 0c56f6f4125ebd7553ee3a79f9604d465a4a304e..aa8ec4ab54421e61ae8d7d62656d2f6762463435 100644 (file)
@@ -44,9 +44,7 @@
 #include <atalk/cnid.h>
 #endif /* CNID_DB*/
 
-/* Global: eg volume.c needs em */
-
-const vol_opt_name_t vol_opt_names[] = {
+static const vol_opt_name_t vol_opt_names[] = {
     {AFPVOL_A2VOL,      "PRODOS"},      /* prodos volume */
     {AFPVOL_CRLF,       "CRLF"},        /* cr/lf translation */
     {AFPVOL_NOADOUBLE,  "NOADOUBLE"},   /* don't create .AppleDouble by default */
@@ -71,7 +69,7 @@ const vol_opt_name_t vol_opt_names[] = {
     {0, NULL}
 };
 
-const vol_opt_name_t vol_opt_casefold[] = {
+static const vol_opt_name_t vol_opt_casefold[] = {
     {AFPVOL_MTOUUPPER,  "MTOULOWER"},
     {AFPVOL_MTOULOWER,  "MTOULOWER"},
     {AFPVOL_UTOMUPPER,  "UTOMUPPER"},
@@ -93,6 +91,7 @@ typedef struct {
 #define CNID_DBPATH 6
 #define VOLUME_OPTS 7
 #define VOLCASEFOLD 8
+#define EXTATTRTYPE 9
 
 static const info_option_t info_options[] = {
     {"MAC_CHARSET", MAC_CHARSET},
@@ -104,7 +103,8 @@ static const info_option_t info_options[] = {
     {"CNID_DBPATH", CNID_DBPATH},
     {"VOLUME_OPTS", VOLUME_OPTS},
     {"VOLCASEFOLD", VOLCASEFOLD},
-    {NULL, 0}
+    {"EXTATTRTYPE", EXTATTRTYPE},
+   {NULL, 0}
 };
 
 static char* find_in_path( char *path, char *subdir, size_t maxlen)
@@ -306,6 +306,12 @@ static int parseline ( char *buf, struct volinfo *vol)
       case VOLCASEFOLD:
         parse_options(value, &vol->v_casefold, &vol_opt_casefold[0]);
         break;
+    case EXTATTRTYPE:
+        if (strcasecmp(value, "AFPVOL_EA_AD") == 0)    
+            vol->v_vfs_ea = AFPVOL_EA_AD;
+        else if (strcasecmp(value, "AFPVOL_EA_SYS") == 0)
+            vol->v_vfs_ea = AFPVOL_EA_SYS;
+        break;
       default:
        fprintf (stderr, "unknown volume information: %s, %s", buf, value);
        return (-1);
@@ -486,10 +492,18 @@ 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 */
+    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));
+    strlcat(buf, item, sizeof(buf));
+
     if (strlen(buf) >= sizeof(buf)-1)
         LOG(log_debug, logtype_afpd,"Error writing .volinfo file: buffer too small, %s", buf);
-
-
    if (write( fd, buf, strlen(buf)) < 0 || ftruncate(fd, strlen(buf)) < 0 ) {
        LOG(log_debug, logtype_afpd,"Error writing .volinfo file: %s", strerror(errno));
    }