aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2/acl.c')
-rw-r--r--fs/gfs2/acl.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index 5f959b8ce406..6e80844367ee 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -74,11 +74,11 @@ int gfs2_acl_validate_remove(struct gfs2_inode *ip, int access)
74{ 74{
75 if (!GFS2_SB(&ip->i_inode)->sd_args.ar_posix_acl) 75 if (!GFS2_SB(&ip->i_inode)->sd_args.ar_posix_acl)
76 return -EOPNOTSUPP; 76 return -EOPNOTSUPP;
77 if (current->fsuid != ip->i_di.di_uid && !capable(CAP_FOWNER)) 77 if (current->fsuid != ip->i_inode.i_uid && !capable(CAP_FOWNER))
78 return -EPERM; 78 return -EPERM;
79 if (S_ISLNK(ip->i_di.di_mode)) 79 if (S_ISLNK(ip->i_inode.i_mode))
80 return -EOPNOTSUPP; 80 return -EOPNOTSUPP;
81 if (!access && !S_ISDIR(ip->i_di.di_mode)) 81 if (!access && !S_ISDIR(ip->i_inode.i_mode))
82 return -EACCES; 82 return -EACCES;
83 83
84 return 0; 84 return 0;
@@ -145,14 +145,14 @@ out:
145} 145}
146 146
147/** 147/**
148 * gfs2_check_acl_locked - Check an ACL to see if we're allowed to do something 148 * gfs2_check_acl - Check an ACL to see if we're allowed to do something
149 * @inode: the file we want to do something to 149 * @inode: the file we want to do something to
150 * @mask: what we want to do 150 * @mask: what we want to do
151 * 151 *
152 * Returns: errno 152 * Returns: errno
153 */ 153 */
154 154
155int gfs2_check_acl_locked(struct inode *inode, int mask) 155int gfs2_check_acl(struct inode *inode, int mask)
156{ 156{
157 struct posix_acl *acl = NULL; 157 struct posix_acl *acl = NULL;
158 int error; 158 int error;
@@ -170,21 +170,6 @@ int gfs2_check_acl_locked(struct inode *inode, int mask)
170 return -EAGAIN; 170 return -EAGAIN;
171} 171}
172 172
173int gfs2_check_acl(struct inode *inode, int mask)
174{
175 struct gfs2_inode *ip = GFS2_I(inode);
176 struct gfs2_holder i_gh;
177 int error;
178
179 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
180 if (!error) {
181 error = gfs2_check_acl_locked(inode, mask);
182 gfs2_glock_dq_uninit(&i_gh);
183 }
184
185 return error;
186}
187
188static int munge_mode(struct gfs2_inode *ip, mode_t mode) 173static int munge_mode(struct gfs2_inode *ip, mode_t mode)
189{ 174{
190 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 175 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
@@ -198,10 +183,10 @@ static int munge_mode(struct gfs2_inode *ip, mode_t mode)
198 error = gfs2_meta_inode_buffer(ip, &dibh); 183 error = gfs2_meta_inode_buffer(ip, &dibh);
199 if (!error) { 184 if (!error) {
200 gfs2_assert_withdraw(sdp, 185 gfs2_assert_withdraw(sdp,
201 (ip->i_di.di_mode & S_IFMT) == (mode & S_IFMT)); 186 (ip->i_inode.i_mode & S_IFMT) == (mode & S_IFMT));
202 ip->i_di.di_mode = mode; 187 ip->i_inode.i_mode = mode;
203 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 188 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
204 gfs2_dinode_out(&ip->i_di, dibh->b_data); 189 gfs2_dinode_out(ip, dibh->b_data);
205 brelse(dibh); 190 brelse(dibh);
206 } 191 }
207 192
@@ -215,12 +200,12 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip)
215 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 200 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
216 struct posix_acl *acl = NULL, *clone; 201 struct posix_acl *acl = NULL, *clone;
217 struct gfs2_ea_request er; 202 struct gfs2_ea_request er;
218 mode_t mode = ip->i_di.di_mode; 203 mode_t mode = ip->i_inode.i_mode;
219 int error; 204 int error;
220 205
221 if (!sdp->sd_args.ar_posix_acl) 206 if (!sdp->sd_args.ar_posix_acl)
222 return 0; 207 return 0;
223 if (S_ISLNK(ip->i_di.di_mode)) 208 if (S_ISLNK(ip->i_inode.i_mode))
224 return 0; 209 return 0;
225 210
226 memset(&er, 0, sizeof(struct gfs2_ea_request)); 211 memset(&er, 0, sizeof(struct gfs2_ea_request));
@@ -232,7 +217,7 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip)
232 return error; 217 return error;
233 if (!acl) { 218 if (!acl) {
234 mode &= ~current->fs->umask; 219 mode &= ~current->fs->umask;
235 if (mode != ip->i_di.di_mode) 220 if (mode != ip->i_inode.i_mode)
236 error = munge_mode(ip, mode); 221 error = munge_mode(ip, mode);
237 return error; 222 return error;
238 } 223 }
@@ -244,7 +229,7 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip)
244 posix_acl_release(acl); 229 posix_acl_release(acl);
245 acl = clone; 230 acl = clone;
246 231
247 if (S_ISDIR(ip->i_di.di_mode)) { 232 if (S_ISDIR(ip->i_inode.i_mode)) {
248 er.er_name = GFS2_POSIX_ACL_DEFAULT; 233 er.er_name = GFS2_POSIX_ACL_DEFAULT;
249 er.er_name_len = GFS2_POSIX_ACL_DEFAULT_LEN; 234 er.er_name_len = GFS2_POSIX_ACL_DEFAULT_LEN;
250 error = gfs2_system_eaops.eo_set(ip, &er); 235 error = gfs2_system_eaops.eo_set(ip, &er);