]> arthur.barton.de Git - netatalk.git/commitdiff
EA bug fixes
authorfranklahm <franklahm>
Fri, 2 Oct 2009 14:57:57 +0000 (14:57 +0000)
committerfranklahm <franklahm>
Fri, 2 Oct 2009 14:57:57 +0000 (14:57 +0000)
libatalk/vfs/ea.c
libatalk/vfs/vfs.c

index e776ec672fe40aec83d777fbc9af71137c3d99bf..9d92d7c9951cd92df80fc0301d99d74ae3a61191 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  $Id: ea.c,v 1.1 2009-10-02 09:32:41 franklahm Exp $
+  $Id: ea.c,v 1.2 2009-10-02 14:57:57 franklahm Exp $
   Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
@@ -271,6 +271,7 @@ static char * ea_path(const struct ea * restrict ea,
  *    uname         (r) name of file
  *    attruname     (r) name of EA
  *    attrsize      (r) size of ea
+ *    bitmap        (r) bitmap from FP func
  *
  * Returns: new number of EA entries, -1 on error
  *
@@ -282,10 +283,29 @@ static char * ea_path(const struct ea * restrict ea,
 static int ea_addentry(struct ea * restrict ea,
                        const char * restrict uname,
                        const char * restrict attruname,
-                       size_t attrsize)
+                       size_t attrsize,
+                       int bitmap)
 {
+    int count = 0;
     void *tmprealloc;
 
+    /* First check if an EA of the requested name already exist */
+    if (ea->ea_count > 0) {
+        while (count < ea->ea_count) {
+            if (strcmp(attruname, (*ea->ea_entries)[count].ea_name) == 0) {
+                LOG(log_debug, logtype_afpd, "ea_addentry('%s'): exists", attruname);
+                if (bitmap & kXAttrCreate)
+                    /* its like O_CREAT|O_EXCL -> fail */
+                    return -1;
+                if ( ! (bitmap & kXAttrReplace))
+                    /* replace was not requested, then its an error */
+                    return -1;
+                break;
+            }
+            count++;
+        }
+    }
+
     if (ea->ea_count == 0) {
         ea->ea_entries = malloc(sizeof(struct ea_entry));
         if ( ! ea->ea_entries) {
@@ -1015,7 +1035,7 @@ int list_eas(const struct vol * restrict vol,
     }
 
 exit:
-    *buflen += attrbuflen;
+    *buflen = attrbuflen;
 
     if ((ea_close(&ea)) != 0) {
         LOG(log_error, logtype_afpd, "list_eas: error closing ea handle for file: %s", uname);
@@ -1063,7 +1083,7 @@ int set_ea(const struct vol * restrict vol,
         return AFPERR_MISC;
     }
 
-    if ((ea_addentry(&ea, uname, attruname, attrsize)) == -1) {
+    if ((ea_addentry(&ea, uname, attruname, attrsize, oflag)) == -1) {
         LOG(log_error, logtype_afpd, "set_ea('%s'): ea_addentry error", uname);
         ret = AFPERR_MISC;
         goto exit;
index b9b4f50587bcaa0beac94342974688269adaa035..d8e01804180056f50bd4ae48f384df233335b325 100644 (file)
 #include <atalk/volume.h>
 #include <atalk/directory.h>
 
-#if 0
-#include "extattrs.h"
-#endif
-
 #ifdef HAVE_NFSv4_ACLS
 extern int remove_acl(const char *name);
 #endif