diff options
Diffstat (limited to 'fs/namespace.c')
-rw-r--r-- | fs/namespace.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 22ae06ad751d..120b8a6b99ed 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -265,6 +265,46 @@ out: | |||
265 | EXPORT_SYMBOL_GPL(mnt_want_write); | 265 | EXPORT_SYMBOL_GPL(mnt_want_write); |
266 | 266 | ||
267 | /** | 267 | /** |
268 | * mnt_clone_write - get write access to a mount | ||
269 | * @mnt: the mount on which to take a write | ||
270 | * | ||
271 | * This is effectively like mnt_want_write, except | ||
272 | * it must only be used to take an extra write reference | ||
273 | * on a mountpoint that we already know has a write reference | ||
274 | * on it. This allows some optimisation. | ||
275 | * | ||
276 | * After finished, mnt_drop_write must be called as usual to | ||
277 | * drop the reference. | ||
278 | */ | ||
279 | int mnt_clone_write(struct vfsmount *mnt) | ||
280 | { | ||
281 | /* superblock may be r/o */ | ||
282 | if (__mnt_is_readonly(mnt)) | ||
283 | return -EROFS; | ||
284 | preempt_disable(); | ||
285 | inc_mnt_writers(mnt); | ||
286 | preempt_enable(); | ||
287 | return 0; | ||
288 | } | ||
289 | EXPORT_SYMBOL_GPL(mnt_clone_write); | ||
290 | |||
291 | /** | ||
292 | * mnt_want_write_file - get write access to a file's mount | ||
293 | * @file: the file who's mount on which to take a write | ||
294 | * | ||
295 | * This is like mnt_want_write, but it takes a file and can | ||
296 | * do some optimisations if the file is open for write already | ||
297 | */ | ||
298 | int mnt_want_write_file(struct file *file) | ||
299 | { | ||
300 | if (!(file->f_mode & FMODE_WRITE)) | ||
301 | return mnt_want_write(file->f_path.mnt); | ||
302 | else | ||
303 | return mnt_clone_write(file->f_path.mnt); | ||
304 | } | ||
305 | EXPORT_SYMBOL_GPL(mnt_want_write_file); | ||
306 | |||
307 | /** | ||
268 | * mnt_drop_write - give up write access to a mount | 308 | * mnt_drop_write - give up write access to a mount |
269 | * @mnt: the mount on which to give up write access | 309 | * @mnt: the mount on which to give up write access |
270 | * | 310 | * |