diff options
Diffstat (limited to 'fs/9p/acl.c')
-rw-r--r-- | fs/9p/acl.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/fs/9p/acl.c b/fs/9p/acl.c index cad38bc1710e..8f2acde74c05 100644 --- a/fs/9p/acl.c +++ b/fs/9p/acl.c | |||
@@ -97,6 +97,61 @@ int v9fs_check_acl(struct inode *inode, int mask) | |||
97 | return -EAGAIN; | 97 | return -EAGAIN; |
98 | } | 98 | } |
99 | 99 | ||
100 | static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl) | ||
101 | { | ||
102 | int retval; | ||
103 | char *name; | ||
104 | size_t size; | ||
105 | void *buffer; | ||
106 | struct inode *inode = dentry->d_inode; | ||
107 | |||
108 | set_cached_acl(inode, type, acl); | ||
109 | /* Set a setxattr request to server */ | ||
110 | size = posix_acl_xattr_size(acl->a_count); | ||
111 | buffer = kmalloc(size, GFP_KERNEL); | ||
112 | if (!buffer) | ||
113 | return -ENOMEM; | ||
114 | retval = posix_acl_to_xattr(acl, buffer, size); | ||
115 | if (retval < 0) | ||
116 | goto err_free_out; | ||
117 | switch (type) { | ||
118 | case ACL_TYPE_ACCESS: | ||
119 | name = POSIX_ACL_XATTR_ACCESS; | ||
120 | break; | ||
121 | case ACL_TYPE_DEFAULT: | ||
122 | name = POSIX_ACL_XATTR_DEFAULT; | ||
123 | break; | ||
124 | default: | ||
125 | BUG(); | ||
126 | } | ||
127 | retval = v9fs_xattr_set(dentry, name, buffer, size, 0); | ||
128 | err_free_out: | ||
129 | kfree(buffer); | ||
130 | return retval; | ||
131 | } | ||
132 | |||
133 | int v9fs_acl_chmod(struct dentry *dentry) | ||
134 | { | ||
135 | int retval = 0; | ||
136 | struct posix_acl *acl, *clone; | ||
137 | struct inode *inode = dentry->d_inode; | ||
138 | |||
139 | if (S_ISLNK(inode->i_mode)) | ||
140 | return -EOPNOTSUPP; | ||
141 | acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS); | ||
142 | if (acl) { | ||
143 | clone = posix_acl_clone(acl, GFP_KERNEL); | ||
144 | posix_acl_release(acl); | ||
145 | if (!clone) | ||
146 | return -ENOMEM; | ||
147 | retval = posix_acl_chmod_masq(clone, inode->i_mode); | ||
148 | if (!retval) | ||
149 | retval = v9fs_set_acl(dentry, ACL_TYPE_ACCESS, clone); | ||
150 | posix_acl_release(clone); | ||
151 | } | ||
152 | return retval; | ||
153 | } | ||
154 | |||
100 | static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, | 155 | static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, |
101 | void *buffer, size_t size, int type) | 156 | void *buffer, size_t size, int type) |
102 | { | 157 | { |