From 24ef932a612d75c0e692bd1f17b44db3aba437eb Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 26 Oct 2010 11:37:48 -0600 Subject: s3: Make gpfs winattrs work again Autobuild-User: Volker Lendecke Autobuild-Date: Wed Oct 27 15:32:00 UTC 2010 on sn-devel-104 --- source3/modules/vfs_gpfs.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 8fbfbdfa9b..694bde7da0 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -22,6 +22,7 @@ */ #include "includes.h" +#include "librpc/gen_ndr/ndr_xattr.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS @@ -926,6 +927,9 @@ static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags){ + struct xattr_DOSATTRIB dosattrib; + enum ndr_err_code ndr_err; + DATA_BLOB blob; const char *attrstr = value; unsigned int dosmode=0; struct gpfs_winattr attrs; @@ -939,11 +943,31 @@ static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path, return SMB_VFS_NEXT_SETXATTR(handle,path,name,value,size,flags); } - if (size < 2 || attrstr[0] != '0' || attrstr[1] != 'x' || - sscanf(attrstr, "%x", &dosmode) != 1) { - DEBUG(1,("gpfs_set_xattr: Trying to set badly formed DOSATTRIB on file %s - %s\n", path, attrstr)); - return False; - } + blob.data = (uint8_t *)attrstr; + blob.length = size; + + ndr_err = ndr_pull_struct_blob(&blob, talloc_tos(), &dosattrib, + (ndr_pull_flags_fn_t)ndr_pull_xattr_DOSATTRIB); + + if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + DEBUG(1, ("gpfs_set_xattr: bad ndr decode " + "from EA on file %s: Error = %s\n", + path, ndr_errstr(ndr_err))); + return false; + } + + if (dosattrib.version != 3) { + DEBUG(1, ("gpfs_set_xattr: expected dosattrib version 3, got " + "%d\n", (int)dosattrib.version)); + return false; + } + if (!(dosattrib.info.info3.valid_flags & XATTR_DOSINFO_ATTRIB)) { + DEBUG(10, ("gpfs_set_xattr: XATTR_DOSINFO_ATTRIB not " + "valid, ignoring\n")); + return true; + } + + dosmode = dosattrib.info.info3.attrib; attrs.winAttrs = 0; /*Just map RD_ONLY, ARCHIVE, SYSTEM and HIDDEN. Ignore the others*/ @@ -1009,9 +1033,9 @@ static ssize_t gpfs_get_xattr(struct vfs_handle_struct *handle, const char *pat dosmode |= FILE_ATTRIBUTE_READONLY; } - snprintf(attrstr, size, "0x%x", dosmode & SAMBA_ATTRIBUTES_MASK); + snprintf(attrstr, size, "0x%2.2x", dosmode & SAMBA_ATTRIBUTES_MASK); DEBUG(10, ("gpfs_get_xattr: returning %s\n",attrstr)); - return size; + return 4; } static int vfs_gpfs_stat(struct vfs_handle_struct *handle, -- cgit