r19507: Merge my DSO fixes branch. Building Samba's libraries as shared libraries
[nivanova/samba-autobuild/.git] / source4 / ntvfs / posix / pvfs_xattr.c
index 7c4fa317d67ed31d20e7cbc198da06048bc78ac5..fcc2d351c97914e3452e1108402e8baf74cdefb6 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "includes.h"
 #include "vfs_posix.h"
+#include "lib/util/unix_privs.h"
 #include "librpc/gen_ndr/ndr_xattr.h"
 
 /*
@@ -46,8 +47,10 @@ static NTSTATUS pull_xattr_blob(struct pvfs_state *pvfs,
                                        fd, estimated_size, blob);
 
        /* if the filesystem doesn't support them, then tell pvfs not to try again */
-       if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)) {
-               DEBUG(5,("pvfs_xattr: xattr not supported in filesystem\n"));
+       if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_SUPPORTED)||
+           NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)||
+           NT_STATUS_EQUAL(status, NT_STATUS_INVALID_SYSTEM_SERVICE)) {
+               DEBUG(5,("pvfs_xattr: xattr not supported in filesystem: %s\n", nt_errstr(status)));
                pvfs->flags &= ~PVFS_FLAG_XATTR_ENABLE;
                status = NT_STATUS_NOT_FOUND;
        }
@@ -98,10 +101,10 @@ NTSTATUS pvfs_xattr_unlink_hook(struct pvfs_state *pvfs, const char *fname)
 /*
   load a NDR structure from a xattr
 */
-static NTSTATUS pvfs_xattr_ndr_load(struct pvfs_state *pvfs,
-                                   TALLOC_CTX *mem_ctx,
-                                   const char *fname, int fd, const char *attr_name,
-                                   void *p, ndr_pull_flags_fn_t pull_fn)
+_PUBLIC_ NTSTATUS pvfs_xattr_ndr_load(struct pvfs_state *pvfs,
+                            TALLOC_CTX *mem_ctx,
+                            const char *fname, int fd, const char *attr_name,
+                            void *p, void *pull_fn)
 {
        NTSTATUS status;
        DATA_BLOB blob;
@@ -113,7 +116,7 @@ static NTSTATUS pvfs_xattr_ndr_load(struct pvfs_state *pvfs,
        }
 
        /* pull the blob */
-       status = ndr_pull_struct_blob(&blob, mem_ctx, p, pull_fn);
+       status = ndr_pull_struct_blob(&blob, mem_ctx, p, (ndr_pull_flags_fn_t)pull_fn);
 
        data_blob_free(&blob);
 
@@ -123,15 +126,15 @@ static NTSTATUS pvfs_xattr_ndr_load(struct pvfs_state *pvfs,
 /*
   save a NDR structure into a xattr
 */
-static NTSTATUS pvfs_xattr_ndr_save(struct pvfs_state *pvfs,
-                                   const char *fname, int fd, const char *attr_name, 
-                                   void *p, ndr_push_flags_fn_t push_fn)
+_PUBLIC_ NTSTATUS pvfs_xattr_ndr_save(struct pvfs_state *pvfs,
+                            const char *fname, int fd, const char *attr_name, 
+                            void *p, void *push_fn)
 {
        TALLOC_CTX *mem_ctx = talloc_new(NULL);
        DATA_BLOB blob;
        NTSTATUS status;
 
-       status = ndr_push_struct_blob(&blob, mem_ctx, p, push_fn);
+       status = ndr_push_struct_blob(&blob, mem_ctx, p, (ndr_push_flags_fn_t)push_fn);
        if (!NT_STATUS_IS_OK(status)) {
                talloc_free(mem_ctx);
                return status;
@@ -458,3 +461,17 @@ NTSTATUS pvfs_xattr_save(struct pvfs_state *pvfs,
        return status;
 }
 
+
+/*
+  probe for system support for xattrs
+*/
+void pvfs_xattr_probe(struct pvfs_state *pvfs)
+{
+       TALLOC_CTX *tmp_ctx = talloc_new(pvfs);
+       DATA_BLOB blob;
+       pull_xattr_blob(pvfs, tmp_ctx, "user.XattrProbe", pvfs->base_directory, 
+                       -1, 1, &blob);
+       pull_xattr_blob(pvfs, tmp_ctx, "security.XattrProbe", pvfs->base_directory, 
+                       -1, 1, &blob);
+       talloc_free(tmp_ctx);
+}