]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/vfs/ea_sys.c
Remove all Appletalk stuff
[netatalk.git] / libatalk / vfs / ea_sys.c
index 079458562933ced7a034a56cb05d03792eb9ef4a..a4fa75b5c97291f3a88d56665b27b68c4c8d1553 100644 (file)
@@ -1,5 +1,4 @@
 /*
-  $Id: ea_sys.c,v 1.6 2010-03-12 15:16:49 franklahm Exp $
   Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
 
   This program is free software; you can redistribute it and/or modify
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <dirent.h>
-
-#if HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
-#elif HAVE_SYS_XATTR_H
-#include <sys/xattr.h>
-#endif
-
-#ifdef HAVE_SYS_EA_H
-#include <sys/ea.h>
-#endif
-
-#ifdef HAVE_SYS_EXTATTR_H
-#include <sys/extattr.h>
-#endif
+#include <arpa/inet.h>
 
 #include <atalk/adouble.h>
 #include <atalk/ea.h>
 #include <atalk/vfs.h>
 #include <atalk/util.h>
 #include <atalk/unix.h>
-
-#ifndef ENOATTR
-#define ENOATTR ENODATA
-#endif
-
+#include <atalk/compat.h>
 
 /**********************************************************************************
  * EA VFS funcs for storing EAs in nativa filesystem EAs
@@ -97,7 +79,7 @@ int sys_get_easize(VFS_FUNC_ARGS_EA_GETSIZE)
         memset(rbuf, 0, 4);
         *rbuflen += 4;
         switch(errno) {
-        case ELOOP:
+        case OPEN_NOFOLLOW_ERRNO:
             /* 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;
@@ -172,7 +154,7 @@ int sys_get_eacontent(VFS_FUNC_ARGS_EA_GETCONTENT)
         memset(rbuf, 0, 4);
         *rbuflen += 4;
         switch(errno) {
-        case ELOOP:
+        case OPEN_NOFOLLOW_ERRNO:
             /* 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;
@@ -214,6 +196,8 @@ int sys_get_eacontent(VFS_FUNC_ARGS_EA_GETCONTENT)
  *
  * Copies names of all EAs of uname as consecutive C strings into rbuf.
  * Increments *rbuflen accordingly.
+ * We hide the adouble:ea extended attributes here, but we currently
+ * allow reading, writing and deleteting them.
  */
 int sys_list_eas(VFS_FUNC_ARGS_EA_LIST)
 {
@@ -234,37 +218,45 @@ int sys_list_eas(VFS_FUNC_ARGS_EA_LIST)
     }
 
     if (ret == -1) switch(errno) {
-        case ELOOP:
+        case OPEN_NOFOLLOW_ERRNO:
             /* its a symlink and client requested O_NOFOLLOW */
             ret = AFPERR_BADTYPE;
+            goto exit;
+#ifdef HAVE_ATTROPEN            /* Solaris */
+        case ENOATTR:
+            ret = AFP_OK;
+            goto exit;
+#endif
         default:
             LOG(log_error, logtype_afpd, "sys_list_extattr(%s): error opening atttribute dir: %s", uname, strerror(errno));
             ret= AFPERR_MISC;
+            goto exit;
     }
     
     ptr = buf;
     while (ret > 0)  {
         len = strlen(ptr);
+        if (NOT_NETATALK_EA(ptr)) {
+            /* Convert name to CH_UTF8_MAC and directly store in in the reply buffer */
+            if ( 0 >= ( nlen = convert_string(vol->v_volcharset, CH_UTF8_MAC, ptr, len, attrnamebuf + attrbuflen, 256)) ) {
+                ret = AFPERR_MISC;
+                goto exit;
+            }
 
-        /* Convert name to CH_UTF8_MAC and directly store in in the reply buffer */
-        if ( 0 >= ( nlen = convert_string(vol->v_volcharset, CH_UTF8_MAC, ptr, len, attrnamebuf + attrbuflen, 256)) ) {
-            ret = AFPERR_MISC;
-            goto exit;
-        }
-
-        LOG(log_debug7, logtype_afpd, "sys_list_extattr(%s): attribute: %s", uname, ptr);
+            LOG(log_debug7, logtype_afpd, "sys_list_extattr(%s): attribute: %s", uname, ptr);
 
-        attrbuflen += nlen + 1;
-        if (attrbuflen > (ATTRNAMEBUFSIZ - 256)) {
-            /* Next EA name could overflow, so bail out with error.
-               FIXME: evantually malloc/memcpy/realloc whatever.
-               Is it worth it ? */
-            LOG(log_warning, logtype_afpd, "sys_list_extattr(%s): running out of buffer for EA names", uname);
-            ret = AFPERR_MISC;
-            goto exit;
+            attrbuflen += nlen + 1;
+            if (attrbuflen > (ATTRNAMEBUFSIZ - 256)) {
+                /* Next EA name could overflow, so bail out with error.
+                   FIXME: evantually malloc/memcpy/realloc whatever.
+                   Is it worth it ? */
+                LOG(log_warning, logtype_afpd, "sys_list_extattr(%s): running out of buffer for EA names", uname);
+                ret = AFPERR_MISC;
+                goto exit;
+            }
         }
-        ret -= len +1;
-        ptr += len +1;
+        ret -= len + 1;
+        ptr += len + 1;
     }
 
     ret = AFP_OK;
@@ -315,7 +307,7 @@ int sys_set_ea(VFS_FUNC_ARGS_EA_SET)
 
     if (ret == -1) {
         switch(errno) {
-        case ELOOP:
+        case OPEN_NOFOLLOW_ERRNO:
             /* its a symlink and client requested O_NOFOLLOW  */
             LOG(log_debug, logtype_afpd, "sys_set_ea(%s/%s): encountered symlink with kXAttrNoFollow",
                 uname, attruname);
@@ -364,7 +356,7 @@ int sys_remove_ea(VFS_FUNC_ARGS_EA_REMOVE)
 
     if (ret == -1) {
         switch(errno) {
-        case ELOOP:
+        case OPEN_NOFOLLOW_ERRNO:
             /* its a symlink and client requested O_NOFOLLOW  */
             LOG(log_debug, logtype_afpd, "sys_remove_ea(%s/%s): encountered symlink with kXAttrNoFollow", uname);
             return AFP_OK;