]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[CIFS] Allow to set extended attribute cifs_acl (try #2)
authorSteve French <sfrench@us.ibm.com>
Tue, 19 Apr 2011 18:27:10 +0000 (18:27 +0000)
committerSteve French <sfrench@us.ibm.com>
Thu, 19 May 2011 14:10:49 +0000 (14:10 +0000)
Allow setting cifs_acl on the server.
Pass on to the server the ACL blob generated by an application.
cifs is just a pass-through, it does not monitor or inspect the contents
of the blob, server decides whether to enforce/apply the ACL blob composed
by an application.
If setting of ACL is succeessful, mark the inode for revalidation.

Signed-off-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
fs/cifs/cifsacl.c
fs/cifs/cifsproto.h
fs/cifs/xattr.c

index beeebf194234c4532341eaea45c316fe6cb58c3f..a0d11eab14e53a2dc303a0dc44b07f7a88226d3c 100644 (file)
@@ -688,7 +688,7 @@ out:
 }
 
 /* Set an ACL on the server */
-static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
+int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
                                struct inode *inode, const char *path)
 {
        struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
index e94526949677e8a728de8b3896ab05348abe954a..0e4e057e289105f9c44798b8b738ba0a40cdb265 100644 (file)
@@ -143,6 +143,8 @@ extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
 extern int mode_to_cifs_acl(struct inode *inode, const char *path, __u64);
 extern struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *, struct inode *,
                                        const char *, u32 *);
+extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *,
+                               const char *);
 
 extern int cifs_mount(struct super_block *, struct cifs_sb_info *, char *,
                        const char *);
index eae2a14916080160c4723868dd69d9c3496c99fa..912995e013ecb8414b3058543237bc19f8b5e903 100644 (file)
@@ -112,6 +112,7 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
        struct cifsTconInfo *pTcon;
        struct super_block *sb;
        char *full_path;
+       struct cifs_ntsd *pacl;
 
        if (direntry == NULL)
                return -EIO;
@@ -166,6 +167,25 @@ int cifs_setxattr(struct dentry *direntry, const char *ea_name,
                rc = CIFSSMBSetEA(xid, pTcon, full_path, ea_name, ea_value,
                        (__u16)value_size, cifs_sb->local_nls,
                        cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
+       } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL,
+                       strlen(CIFS_XATTR_CIFS_ACL)) == 0) {
+               pacl = kmalloc(value_size, GFP_KERNEL);
+               if (!pacl) {
+                       cFYI(1, "%s: Can't allocate memory for ACL",
+                                       __func__);
+                       rc = -ENOMEM;
+               } else {
+#ifdef CONFIG_CIFS_ACL
+                       memcpy(pacl, ea_value, value_size);
+                       rc = set_cifs_acl(pacl, value_size,
+                               direntry->d_inode, full_path);
+                       if (rc == 0) /* force revalidate of the inode */
+                               CIFS_I(direntry->d_inode)->time = 0;
+                       kfree(pacl);
+#else
+                       cFYI(1, "Set CIFS ACL not supported yet");
+#endif /* CONFIG_CIFS_ACL */
+               }
        } else {
                int temp;
                temp = strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,