diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2011-02-28 06:34:11 -0500 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2011-03-15 10:57:42 -0400 |
commit | 7c9e592e1f6a994d2903c9b055e488ec90f58159 (patch) | |
tree | 8bd7843d04764915a375fbc9080f608ced7b1a00 /fs/9p/fid.c | |
parent | 3dc5436aa5719be029bbc2bef0e5cb0312e4ff88 (diff) |
fs/9p: Make the writeback_fid owned by root
Changes to make sure writeback fid is owned by root
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p/fid.c')
-rw-r--r-- | fs/9p/fid.c | 92 |
1 files changed, 56 insertions, 36 deletions
diff --git a/fs/9p/fid.c b/fs/9p/fid.c index 9d6a5d3bfe15..cd63e002d826 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c | |||
@@ -125,46 +125,17 @@ err_out: | |||
125 | return -ENOMEM; | 125 | return -ENOMEM; |
126 | } | 126 | } |
127 | 127 | ||
128 | /** | 128 | static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, |
129 | * v9fs_fid_lookup - lookup for a fid, try to walk if not found | 129 | uid_t uid, int any) |
130 | * @dentry: dentry to look for fid in | ||
131 | * | ||
132 | * Look for a fid in the specified dentry for the current user. | ||
133 | * If no fid is found, try to create one walking from a fid from the parent | ||
134 | * dentry (if it has one), or the root dentry. If the user haven't accessed | ||
135 | * the fs yet, attach now and walk from the root. | ||
136 | */ | ||
137 | |||
138 | struct p9_fid *v9fs_fid_lookup(struct dentry *dentry) | ||
139 | { | 130 | { |
140 | int i, n, l, clone, any, access; | ||
141 | u32 uid; | ||
142 | struct p9_fid *fid, *old_fid = NULL; | ||
143 | struct dentry *ds; | 131 | struct dentry *ds; |
144 | struct v9fs_session_info *v9ses; | ||
145 | char **wnames, *uname; | 132 | char **wnames, *uname; |
133 | int i, n, l, clone, access; | ||
134 | struct v9fs_session_info *v9ses; | ||
135 | struct p9_fid *fid, *old_fid = NULL; | ||
146 | 136 | ||
147 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | 137 | v9ses = v9fs_inode2v9ses(dentry->d_inode); |
148 | access = v9ses->flags & V9FS_ACCESS_MASK; | 138 | access = v9ses->flags & V9FS_ACCESS_MASK; |
149 | switch (access) { | ||
150 | case V9FS_ACCESS_SINGLE: | ||
151 | case V9FS_ACCESS_USER: | ||
152 | case V9FS_ACCESS_CLIENT: | ||
153 | uid = current_fsuid(); | ||
154 | any = 0; | ||
155 | break; | ||
156 | |||
157 | case V9FS_ACCESS_ANY: | ||
158 | uid = v9ses->uid; | ||
159 | any = 1; | ||
160 | break; | ||
161 | |||
162 | default: | ||
163 | uid = ~0; | ||
164 | any = 0; | ||
165 | break; | ||
166 | } | ||
167 | |||
168 | fid = v9fs_fid_find(dentry, uid, any); | 139 | fid = v9fs_fid_find(dentry, uid, any); |
169 | if (fid) | 140 | if (fid) |
170 | return fid; | 141 | return fid; |
@@ -250,6 +221,45 @@ err_out: | |||
250 | return fid; | 221 | return fid; |
251 | } | 222 | } |
252 | 223 | ||
224 | /** | ||
225 | * v9fs_fid_lookup - lookup for a fid, try to walk if not found | ||
226 | * @dentry: dentry to look for fid in | ||
227 | * | ||
228 | * Look for a fid in the specified dentry for the current user. | ||
229 | * If no fid is found, try to create one walking from a fid from the parent | ||
230 | * dentry (if it has one), or the root dentry. If the user haven't accessed | ||
231 | * the fs yet, attach now and walk from the root. | ||
232 | */ | ||
233 | |||
234 | struct p9_fid *v9fs_fid_lookup(struct dentry *dentry) | ||
235 | { | ||
236 | uid_t uid; | ||
237 | int any, access; | ||
238 | struct v9fs_session_info *v9ses; | ||
239 | |||
240 | v9ses = v9fs_inode2v9ses(dentry->d_inode); | ||
241 | access = v9ses->flags & V9FS_ACCESS_MASK; | ||
242 | switch (access) { | ||
243 | case V9FS_ACCESS_SINGLE: | ||
244 | case V9FS_ACCESS_USER: | ||
245 | case V9FS_ACCESS_CLIENT: | ||
246 | uid = current_fsuid(); | ||
247 | any = 0; | ||
248 | break; | ||
249 | |||
250 | case V9FS_ACCESS_ANY: | ||
251 | uid = v9ses->uid; | ||
252 | any = 1; | ||
253 | break; | ||
254 | |||
255 | default: | ||
256 | uid = ~0; | ||
257 | any = 0; | ||
258 | break; | ||
259 | } | ||
260 | return v9fs_fid_lookup_with_uid(dentry, uid, any); | ||
261 | } | ||
262 | |||
253 | struct p9_fid *v9fs_fid_clone(struct dentry *dentry) | 263 | struct p9_fid *v9fs_fid_clone(struct dentry *dentry) |
254 | { | 264 | { |
255 | struct p9_fid *fid, *ret; | 265 | struct p9_fid *fid, *ret; |
@@ -262,13 +272,24 @@ struct p9_fid *v9fs_fid_clone(struct dentry *dentry) | |||
262 | return ret; | 272 | return ret; |
263 | } | 273 | } |
264 | 274 | ||
275 | static struct p9_fid *v9fs_fid_clone_with_uid(struct dentry *dentry, uid_t uid) | ||
276 | { | ||
277 | struct p9_fid *fid, *ret; | ||
278 | |||
279 | fid = v9fs_fid_lookup_with_uid(dentry, uid, 0); | ||
280 | if (IS_ERR(fid)) | ||
281 | return fid; | ||
282 | |||
283 | ret = p9_client_walk(fid, 0, NULL, 1); | ||
284 | return ret; | ||
285 | } | ||
265 | 286 | ||
266 | struct p9_fid *v9fs_writeback_fid(struct dentry *dentry) | 287 | struct p9_fid *v9fs_writeback_fid(struct dentry *dentry) |
267 | { | 288 | { |
268 | int err; | 289 | int err; |
269 | struct p9_fid *fid; | 290 | struct p9_fid *fid; |
270 | 291 | ||
271 | fid = v9fs_fid_clone(dentry); | 292 | fid = v9fs_fid_clone_with_uid(dentry, 0); |
272 | if (IS_ERR(fid)) | 293 | if (IS_ERR(fid)) |
273 | goto error_out; | 294 | goto error_out; |
274 | /* | 295 | /* |
@@ -276,7 +297,6 @@ struct p9_fid *v9fs_writeback_fid(struct dentry *dentry) | |||
276 | * dirty pages. We always request for the open fid in read-write | 297 | * dirty pages. We always request for the open fid in read-write |
277 | * mode so that a partial page write which result in page | 298 | * mode so that a partial page write which result in page |
278 | * read can work. | 299 | * read can work. |
279 | * FIXME!!: we should make the fid owned by uid = 0 | ||
280 | */ | 300 | */ |
281 | err = p9_client_open(fid, O_RDWR); | 301 | err = p9_client_open(fid, O_RDWR); |
282 | if (err < 0) { | 302 | if (err < 0) { |