summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Dietz <mdietz@de.ibm.com>2009-05-27 12:03:12 +0200
committerVolker Lendecke <vl@samba.org>2009-06-02 17:03:59 +0200
commit15e10c6a84c450fd5bc1b50a45bb1cfa049fb00d (patch)
treeef1804ad452a64e5071098255ac85a293107b332
parent011a5058005554b977f9eaaefbbd5bd50b3109bc (diff)
downloadsamba-15e10c6a84c450fd5bc1b50a45bb1cfa049fb00d.tar.gz
samba-15e10c6a84c450fd5bc1b50a45bb1cfa049fb00d.tar.bz2
samba-15e10c6a84c450fd5bc1b50a45bb1cfa049fb00d.zip
Store winattrs in GPFS
1. Store win attributes in gpfs instead of posix bits. 2. use of path based winattr calls of gpfs. Signed-off-by: Mathias Dietz <mdietz@de.ibm.com>
-rw-r--r--source3/modules/gpfs.c41
-rw-r--r--source3/modules/vfs_gpfs.c99
-rw-r--r--source3/modules/vfs_gpfs.h2
3 files changed, 142 insertions, 0 deletions
diff --git a/source3/modules/gpfs.c b/source3/modules/gpfs.c
index 9fc4524654..d20c024ccd 100644
--- a/source3/modules/gpfs.c
+++ b/source3/modules/gpfs.c
@@ -27,6 +27,7 @@
static bool gpfs_share_modes;
static bool gpfs_leases;
static bool gpfs_getrealfilename;
+static bool gpfs_winattr;
static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
static int (*gpfs_set_lease_fn)(int fd, unsigned int leaseType);
@@ -34,6 +35,8 @@ static int (*gpfs_getacl_fn)(char *pathname, int flags, void *acl);
static int (*gpfs_putacl_fn)(char *pathname, int flags, void *acl);
static int (*gpfs_get_realfilename_path_fn)(char *pathname, char *filenamep,
int *buflen);
+static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags, struct gpfs_winattr *attrs);
+static int (*gpfs_get_winattrs_path_fn)(char *pathname, struct gpfs_winattr *attrs);
bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
@@ -149,6 +152,28 @@ int smbd_gpfs_get_realfilename_path(char *pathname, char *filenamep,
return gpfs_get_realfilename_path_fn(pathname, filenamep, buflen);
}
+int get_gpfs_winattrs(char *pathname,struct gpfs_winattr *attrs)
+{
+
+ if ((!gpfs_winattr) || (gpfs_get_winattrs_path_fn == NULL)) {
+ errno = ENOSYS;
+ return -1;
+ }
+ DEBUG(0, ("gpfs_get_winattrs_path:open call %s\n",pathname));
+ return gpfs_get_winattrs_path_fn(pathname, attrs);
+}
+
+int set_gpfs_winattrs(char *pathname,int flags,struct gpfs_winattr *attrs)
+{
+ if ((!gpfs_winattr) || (gpfs_set_winattrs_path_fn == NULL)) {
+ errno = ENOSYS;
+ return -1;
+ }
+
+ DEBUG(0, ("gpfs_set_winattrs_path:open call %s\n",pathname));
+ return gpfs_set_winattrs_path_fn(pathname,flags, attrs);
+}
+
static bool init_gpfs_function_lib(void *plibhandle_pointer,
const char *libname,
void *pfn_pointer, const char *fn_name)
@@ -207,11 +232,15 @@ void init_gpfs(void)
init_gpfs_function(&gpfs_putacl_fn, "gpfs_putacl");
init_gpfs_function(&gpfs_get_realfilename_path_fn,
"gpfs_get_realfilename_path");
+ init_gpfs_function(&gpfs_get_winattrs_path_fn,"gpfs_get_winattrs_path");
+ init_gpfs_function(&gpfs_set_winattrs_path_fn,"gpfs_set_winattrs_path");
+
gpfs_share_modes = lp_parm_bool(-1, "gpfs", "sharemodes", True);
gpfs_leases = lp_parm_bool(-1, "gpfs", "leases", True);
gpfs_getrealfilename = lp_parm_bool(-1, "gpfs", "getrealfilename",
True);
+ gpfs_winattr = lp_parm_bool(-1, "gpfs", "winattr", False);
return;
}
@@ -255,6 +284,18 @@ int smbd_gpfs_get_realfilename_path(char *pathname, char *fileamep,
return -1;
}
+int set_gpfs_winattrs(char *pathname,int flags,struct gpfs_winattr *attrs)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
+int get_gpfs_winattrs(char *pathname,struct gpfs_winattr *attrs)
+{
+ errno = ENOSYS;
+ return -1;
+}
+
void init_gpfs(void)
{
return;
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 2e4e7ede55..4215e13200 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -876,6 +876,97 @@ static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t
return rc;
}
+static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path,
+ const char *name, const void *value, size_t size, int flags){
+ const char *attrstr = value;
+ unsigned int dosmode=0;
+ struct gpfs_winattr attrs;
+ int ret = 0;
+
+ DEBUG(10, ("gpfs_set_xattr: %s \n",path));
+
+ /* Only handle DOS Attributes */
+ if (strcmp(name,SAMBA_XATTR_DOS_ATTRIB) != 0){
+ DEBUG(1, ("gpfs_set_xattr:name is %s\n",name));
+ 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;
+ }
+
+ attrs.winAttrs = 0;
+ /*Just map RD_ONLY, ARCHIVE, SYSTEM and HIDDEN. Ignore the others*/
+ if (dosmode & FILE_ATTRIBUTE_ARCHIVE){
+ attrs.winAttrs |= GPFS_WINATTR_ARCHIVE;
+ }
+ if (dosmode & FILE_ATTRIBUTE_HIDDEN){
+ attrs.winAttrs |= GPFS_WINATTR_HIDDEN;
+ }
+ if (dosmode & FILE_ATTRIBUTE_SYSTEM){
+ attrs.winAttrs |= GPFS_WINATTR_SYSTEM;
+ }
+ if (dosmode & FILE_ATTRIBUTE_READONLY){
+ attrs.winAttrs |= GPFS_WINATTR_READONLY;
+ }
+
+
+ ret = set_gpfs_winattrs(CONST_DISCARD(char *, path),
+ GPFS_WINATTR_SET_ATTRS, &attrs);
+ if ( ret == -1){
+ DEBUG(1, ("gpfs_set_xattr:Set GPFS attributes failed %d\n",ret));
+ return -1;
+ }
+
+ DEBUG(10, ("gpfs_set_xattr:Set attributes: 0x%x\n",attrs.winAttrs));
+ return 0;
+}
+
+static size_t gpfs_get_xattr(struct vfs_handle_struct *handle, const char *path,
+ const char *name, void *value, size_t size){
+ char *attrstr = value;
+ unsigned int dosmode = 0;
+ struct gpfs_winattr attrs;
+ int ret = 0;
+
+ DEBUG(10, ("gpfs_get_xattr: %s \n",path));
+
+ /* Only handle DOS Attributes */
+ if (strcmp(name,SAMBA_XATTR_DOS_ATTRIB) != 0){
+ DEBUG(1, ("gpfs_get_xattr:name is %s\n",name));
+ return SMB_VFS_NEXT_GETXATTR(handle,path,name,value,size);
+ }
+
+ ret = get_gpfs_winattrs(CONST_DISCARD(char *, path), &attrs);
+ if ( ret == -1){
+ DEBUG(1, ("gpfs_get_xattr: Get GPFS attributes failed: %d\n",ret));
+ return -1;
+ }
+
+ DEBUG(10, ("gpfs_get_xattr:Got attributes: 0x%x\n",attrs.winAttrs));
+
+ /*Just map RD_ONLY, ARCHIVE, SYSTEM and HIDDEN. Ignore the others*/
+ if (attrs.winAttrs & GPFS_WINATTR_ARCHIVE){
+ dosmode |= FILE_ATTRIBUTE_ARCHIVE;
+ }
+ if (attrs.winAttrs & GPFS_WINATTR_HIDDEN){
+ dosmode |= FILE_ATTRIBUTE_HIDDEN;
+ }
+ if (attrs.winAttrs & GPFS_WINATTR_SYSTEM){
+ dosmode |= FILE_ATTRIBUTE_SYSTEM;
+ }
+ if (attrs.winAttrs & GPFS_WINATTR_READONLY){
+ dosmode |= FILE_ATTRIBUTE_READONLY;
+ }
+
+ snprintf(attrstr, size, "0x%x", dosmode & SAMBA_ATTRIBUTES_MASK);
+ DEBUG(10, ("gpfs_get_xattr: returning %s\n",attrstr));
+ return size;
+}
+
+
/* VFS operations structure */
static vfs_op_tuple gpfs_op_tuples[] = {
@@ -936,6 +1027,14 @@ static vfs_op_tuple gpfs_op_tuples[] = {
SMB_VFS_OP_CLOSE,
SMB_VFS_LAYER_TRANSPARENT },
+ { SMB_VFS_OP(gpfs_set_xattr),
+ SMB_VFS_OP_SETXATTR,
+ SMB_VFS_LAYER_TRANSPARENT },
+
+ { SMB_VFS_OP(gpfs_get_xattr),
+ SMB_VFS_OP_GETXATTR,
+ SMB_VFS_LAYER_TRANSPARENT },
+
{ SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP }
};
diff --git a/source3/modules/vfs_gpfs.h b/source3/modules/vfs_gpfs.h
index efca5603aa..e0c23dc8cc 100644
--- a/source3/modules/vfs_gpfs.h
+++ b/source3/modules/vfs_gpfs.h
@@ -31,4 +31,6 @@ int smbd_gpfs_getacl(char *pathname, int flags, void *acl);
int smbd_gpfs_putacl(char *pathname, int flags, void *acl);
int smbd_gpfs_get_realfilename_path(char *pathname, char *filenamep,
int *buflen);
+int get_gpfs_winattrs(char * pathname,struct gpfs_winattr *attrs);
+int set_gpfs_winattrs(char * pathname,int flags,struct gpfs_winattr *attrs);
void init_gpfs(void);