diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /fs/gfs2/acl.c | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'fs/gfs2/acl.c')
-rw-r--r-- | fs/gfs2/acl.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c index f850020ad90..34501b64bc4 100644 --- a/fs/gfs2/acl.c +++ b/fs/gfs2/acl.c | |||
@@ -38,9 +38,8 @@ static const char *gfs2_acl_name(int type) | |||
38 | return NULL; | 38 | return NULL; |
39 | } | 39 | } |
40 | 40 | ||
41 | struct posix_acl *gfs2_get_acl(struct inode *inode, int type) | 41 | static struct posix_acl *gfs2_acl_get(struct gfs2_inode *ip, int type) |
42 | { | 42 | { |
43 | struct gfs2_inode *ip = GFS2_I(inode); | ||
44 | struct posix_acl *acl; | 43 | struct posix_acl *acl; |
45 | const char *name; | 44 | const char *name; |
46 | char *data; | 45 | char *data; |
@@ -63,18 +62,27 @@ struct posix_acl *gfs2_get_acl(struct inode *inode, int type) | |||
63 | if (len == 0) | 62 | if (len == 0) |
64 | return NULL; | 63 | return NULL; |
65 | 64 | ||
66 | acl = posix_acl_from_xattr(&init_user_ns, data, len); | 65 | acl = posix_acl_from_xattr(data, len); |
67 | kfree(data); | 66 | kfree(data); |
68 | return acl; | 67 | return acl; |
69 | } | 68 | } |
70 | 69 | ||
70 | struct posix_acl *gfs2_get_acl(struct inode *inode, int type) | ||
71 | { | ||
72 | return gfs2_acl_get(GFS2_I(inode), type); | ||
73 | } | ||
74 | |||
71 | static int gfs2_set_mode(struct inode *inode, umode_t mode) | 75 | static int gfs2_set_mode(struct inode *inode, umode_t mode) |
72 | { | 76 | { |
73 | int error = 0; | 77 | int error = 0; |
74 | 78 | ||
75 | if (mode != inode->i_mode) { | 79 | if (mode != inode->i_mode) { |
76 | inode->i_mode = mode; | 80 | struct iattr iattr; |
77 | mark_inode_dirty(inode); | 81 | |
82 | iattr.ia_valid = ATTR_MODE; | ||
83 | iattr.ia_mode = mode; | ||
84 | |||
85 | error = gfs2_setattr_simple(GFS2_I(inode), &iattr); | ||
78 | } | 86 | } |
79 | 87 | ||
80 | return error; | 88 | return error; |
@@ -88,13 +96,13 @@ static int gfs2_acl_set(struct inode *inode, int type, struct posix_acl *acl) | |||
88 | const char *name = gfs2_acl_name(type); | 96 | const char *name = gfs2_acl_name(type); |
89 | 97 | ||
90 | BUG_ON(name == NULL); | 98 | BUG_ON(name == NULL); |
91 | len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0); | 99 | len = posix_acl_to_xattr(acl, NULL, 0); |
92 | if (len == 0) | 100 | if (len == 0) |
93 | return 0; | 101 | return 0; |
94 | data = kmalloc(len, GFP_NOFS); | 102 | data = kmalloc(len, GFP_NOFS); |
95 | if (data == NULL) | 103 | if (data == NULL) |
96 | return -ENOMEM; | 104 | return -ENOMEM; |
97 | error = posix_acl_to_xattr(&init_user_ns, acl, data, len); | 105 | error = posix_acl_to_xattr(acl, data, len); |
98 | if (error < 0) | 106 | if (error < 0) |
99 | goto out; | 107 | goto out; |
100 | error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS); | 108 | error = __gfs2_xattr_set(inode, name, data, len, 0, GFS2_EATYPE_SYS); |
@@ -117,12 +125,14 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct inode *inode) | |||
117 | if (S_ISLNK(inode->i_mode)) | 125 | if (S_ISLNK(inode->i_mode)) |
118 | return 0; | 126 | return 0; |
119 | 127 | ||
120 | acl = gfs2_get_acl(&dip->i_inode, ACL_TYPE_DEFAULT); | 128 | acl = gfs2_acl_get(dip, ACL_TYPE_DEFAULT); |
121 | if (IS_ERR(acl)) | 129 | if (IS_ERR(acl)) |
122 | return PTR_ERR(acl); | 130 | return PTR_ERR(acl); |
123 | if (!acl) { | 131 | if (!acl) { |
124 | mode &= ~current_umask(); | 132 | mode &= ~current_umask(); |
125 | return gfs2_set_mode(inode, mode); | 133 | if (mode != inode->i_mode) |
134 | error = gfs2_set_mode(inode, mode); | ||
135 | return error; | ||
126 | } | 136 | } |
127 | 137 | ||
128 | if (S_ISDIR(inode->i_mode)) { | 138 | if (S_ISDIR(inode->i_mode)) { |
@@ -150,28 +160,27 @@ out: | |||
150 | 160 | ||
151 | int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr) | 161 | int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr) |
152 | { | 162 | { |
153 | struct inode *inode = &ip->i_inode; | ||
154 | struct posix_acl *acl; | 163 | struct posix_acl *acl; |
155 | char *data; | 164 | char *data; |
156 | unsigned int len; | 165 | unsigned int len; |
157 | int error; | 166 | int error; |
158 | 167 | ||
159 | acl = gfs2_get_acl(&ip->i_inode, ACL_TYPE_ACCESS); | 168 | acl = gfs2_acl_get(ip, ACL_TYPE_ACCESS); |
160 | if (IS_ERR(acl)) | 169 | if (IS_ERR(acl)) |
161 | return PTR_ERR(acl); | 170 | return PTR_ERR(acl); |
162 | if (!acl) | 171 | if (!acl) |
163 | return gfs2_setattr_simple(inode, attr); | 172 | return gfs2_setattr_simple(ip, attr); |
164 | 173 | ||
165 | error = posix_acl_chmod(&acl, GFP_NOFS, attr->ia_mode); | 174 | error = posix_acl_chmod(&acl, GFP_NOFS, attr->ia_mode); |
166 | if (error) | 175 | if (error) |
167 | return error; | 176 | return error; |
168 | 177 | ||
169 | len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0); | 178 | len = posix_acl_to_xattr(acl, NULL, 0); |
170 | data = kmalloc(len, GFP_NOFS); | 179 | data = kmalloc(len, GFP_NOFS); |
171 | error = -ENOMEM; | 180 | error = -ENOMEM; |
172 | if (data == NULL) | 181 | if (data == NULL) |
173 | goto out; | 182 | goto out; |
174 | posix_acl_to_xattr(&init_user_ns, acl, data, len); | 183 | posix_acl_to_xattr(acl, data, len); |
175 | error = gfs2_xattr_acl_chmod(ip, attr, data); | 184 | error = gfs2_xattr_acl_chmod(ip, attr, data); |
176 | kfree(data); | 185 | kfree(data); |
177 | set_cached_acl(&ip->i_inode, ACL_TYPE_ACCESS, acl); | 186 | set_cached_acl(&ip->i_inode, ACL_TYPE_ACCESS, acl); |
@@ -206,13 +215,13 @@ static int gfs2_xattr_system_get(struct dentry *dentry, const char *name, | |||
206 | if (type < 0) | 215 | if (type < 0) |
207 | return type; | 216 | return type; |
208 | 217 | ||
209 | acl = gfs2_get_acl(inode, type); | 218 | acl = gfs2_acl_get(GFS2_I(inode), type); |
210 | if (IS_ERR(acl)) | 219 | if (IS_ERR(acl)) |
211 | return PTR_ERR(acl); | 220 | return PTR_ERR(acl); |
212 | if (acl == NULL) | 221 | if (acl == NULL) |
213 | return -ENODATA; | 222 | return -ENODATA; |
214 | 223 | ||
215 | error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); | 224 | error = posix_acl_to_xattr(acl, buffer, size); |
216 | posix_acl_release(acl); | 225 | posix_acl_release(acl); |
217 | 226 | ||
218 | return error; | 227 | return error; |
@@ -245,7 +254,7 @@ static int gfs2_xattr_system_set(struct dentry *dentry, const char *name, | |||
245 | if (!value) | 254 | if (!value) |
246 | goto set_acl; | 255 | goto set_acl; |
247 | 256 | ||
248 | acl = posix_acl_from_xattr(&init_user_ns, value, size); | 257 | acl = posix_acl_from_xattr(value, size); |
249 | if (!acl) { | 258 | if (!acl) { |
250 | /* | 259 | /* |
251 | * acl_set_file(3) may request that we set default ACLs with | 260 | * acl_set_file(3) may request that we set default ACLs with |