]> arthur.barton.de Git - netatalk.git/commitdiff
Return right error for requested but non-existing EA.
authorfranklahm <franklahm>
Fri, 4 Dec 2009 10:26:10 +0000 (10:26 +0000)
committerfranklahm <franklahm>
Fri, 4 Dec 2009 10:26:10 +0000 (10:26 +0000)
Thanks to Stephan Budach for reporting this.

libatalk/vfs/ea.c
libatalk/vfs/ea_sys.c
libatalk/vfs/sys_ea.c

index 8d3c1ae8ab9964956a2393b31bf6dee0f3128f44..89ffc90fe601550f3060782af230e6a6e964ed93 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  $Id: ea.c,v 1.16 2009-11-18 10:52:00 franklahm Exp $
+  $Id: ea.c,v 1.17 2009-12-04 10:26:10 franklahm Exp $
   Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
@@ -915,8 +915,12 @@ int get_easize(VFS_FUNC_ARGS_EA_GETSIZE)
     LOG(log_debug, logtype_afpd, "get_easize: file: %s", uname);
 
     if ((ea_open(vol, uname, EA_RDONLY, &ea)) != 0) {
-        LOG(log_error, logtype_afpd, "get_easize: error calling ea_open for file: %s", uname);
-        return AFPERR_MISC;
+        if (errno != ENOENT)
+            LOG(log_error, logtype_afpd, "get_easize: error calling ea_open for file: %s", uname);
+
+        memset(rbuf, 0, 4);
+        *rbuflen += 4;
+        return ret;
     }
 
     while (count < ea.ea_count) {
@@ -974,8 +978,11 @@ int get_eacontent(VFS_FUNC_ARGS_EA_GETCONTENT)
     LOG(log_debug, logtype_afpd, "get_eacontent('%s/%s')", uname, attruname);
 
     if ((ea_open(vol, uname, EA_RDONLY, &ea)) != 0) {
-        LOG(log_error, logtype_afpd, "get_eacontent('%s'): ea_open error", uname);
-        return AFPERR_MISC;
+        if (errno != ENOENT)
+            LOG(log_error, logtype_afpd, "get_eacontent('%s'): ea_open error", uname);
+        memset(rbuf, 0, 4);
+        *rbuflen += 4;
+        return ret;
     }
 
     while (count < ea.ea_count) {
index 7c7f8e312d1372af73994e883f32c393a51286b5..e94956c21d44ce2e5c2f75f87133c201c7d81543 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  $Id: ea_sys.c,v 1.3 2009-11-20 16:26:23 franklahm Exp $
+  $Id: ea_sys.c,v 1.4 2009-12-04 10:26:10 franklahm Exp $
   Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
 #include <atalk/util.h>
 #include <atalk/unix.h>
 
+#ifndef ENOATTR
+#define ENOATTR ENODATA
+#endif
+
 
 /**********************************************************************************
  * EA VFS funcs for storing EAs in nativa filesystem EAs
@@ -90,15 +94,17 @@ int sys_get_easize(VFS_FUNC_ARGS_EA_GETSIZE)
     }
     
     if (ret == -1) {
+        memset(rbuf, 0, 4);
+        *rbuflen += 4;
         switch(errno) {
         case ELOOP:
             /* its a symlink and client requested O_NOFOLLOW  */
             LOG(log_debug, logtype_afpd, "sys_getextattr_size(%s): encountered symlink with kXAttrNoFollow", uname);
+            return AFP_OK;
 
-            memset(rbuf, 0, 4);
-            *rbuflen += 4;
+        case ENOATTR:
+            return AFPERR_MISC;
 
-            return AFP_OK;
         default:
             LOG(log_error, logtype_afpd, "sys_getextattr_size: error: %s", strerror(errno));
             return AFPERR_MISC;
@@ -162,18 +168,22 @@ int sys_get_eacontent(VFS_FUNC_ARGS_EA_GETCONTENT)
         ret = sys_getxattr(uname, attruname,  rbuf +4, maxreply);
     }
     
-    if (ret == -1) switch(errno) {
-    case ELOOP:
-        /* its a symlink and client requested O_NOFOLLOW  */
-        LOG(log_debug, logtype_afpd, "sys_getextattr_content(%s): encountered symlink with kXAttrNoFollow", uname);
-
+    if (ret == -1) {
         memset(rbuf, 0, 4);
         *rbuflen += 4;
+        switch(errno) {
+        case ELOOP:
+            /* its a symlink and client requested O_NOFOLLOW  */
+            LOG(log_debug, logtype_afpd, "sys_getextattr_content(%s): encountered symlink with kXAttrNoFollow", uname);
+            return AFP_OK;
 
-        return AFP_OK;
-    default:
-        LOG(log_error, logtype_afpd, "sys_getextattr_content(%s): error: %s", attruname, strerror(errno));
-        return AFPERR_MISC;
+        case ENOATTR:
+            return AFPERR_MISC;
+
+        default:
+            LOG(log_error, logtype_afpd, "sys_getextattr_content(%s): error: %s", attruname, strerror(errno));
+            return AFPERR_MISC;
+        }
     }
 
     /* remember where we must store length of attribute data in rbuf */
index 88b9e645762f0526f11c7107c1330c76cb75bbfa..44037a15f11a1e7ea6925c568a4b8b4be94b33ac 100644 (file)
@@ -25,7 +25,7 @@
    Copyright (C) 2001 Andreas Gruenbacher.
       
    Samba 3.0.28, modified for netatalk.
-   $Id: sys_ea.c,v 1.5 2009-11-23 19:04:15 franklahm Exp $
+   $Id: sys_ea.c,v 1.6 2009-12-04 10:26:10 franklahm Exp $
    
 */
 
 #include <atalk/logger.h>
 #include <atalk/ea.h>
 
+#ifndef ENOATTR
+#define ENOATTR ENODATA
+#endif
+
 /******** Solaris EA helper function prototypes ********/
 #ifdef HAVE_ATTROPEN
 #define SOLARIS_ATTRMODE S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP
@@ -755,6 +759,7 @@ static int solaris_attropen(const char *path, const char *attrpath, int oflag, m
        int filedes = attropen(path, attrpath, oflag, mode);
        if (filedes == -1) {
                LOG(log_maxdebug, logtype_default, "attropen FAILED: path: %s, name: %s, errno: %s\n",path,attrpath,strerror(errno));
+        errno = ENOATTR;
        }
        return filedes;
 }