-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
53 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- a/fs/namespace.c | ||
+++ b/fs/namespace.c | ||
@@ -1739,6 +1739,39 @@ static inline bool may_mandlock(void) | ||
} | ||
#endif | ||
|
||
+static int can_umount(const struct path *path, int flags) | ||
+{ | ||
+ struct mount *mnt = real_mount(path->mnt); | ||
+ | ||
+ if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW)) | ||
+ return -EINVAL; | ||
+ if (!may_mount()) | ||
+ return -EPERM; | ||
+ if (path->dentry != path->mnt->mnt_root) | ||
+ return -EINVAL; | ||
+ if (!check_mnt(mnt)) | ||
+ return -EINVAL; | ||
+ if (mnt->mnt.mnt_flags & MNT_LOCKED) /* Check optimistically */ | ||
+ return -EINVAL; | ||
+ if (flags & MNT_FORCE && !capable(CAP_SYS_ADMIN)) | ||
+ return -EPERM; | ||
+ return 0; | ||
+} | ||
+ | ||
+int path_umount(struct path *path, int flags) | ||
+{ | ||
+ struct mount *mnt = real_mount(path->mnt); | ||
+ int ret; | ||
+ | ||
+ ret = can_umount(path, flags); | ||
+ if (!ret) | ||
+ ret = do_umount(mnt, flags); | ||
+ | ||
+ /* we mustn't call path_put() as that would clear mnt_expiry_mark */ | ||
+ dput(path->dentry); | ||
+ mntput_no_expire(mnt); | ||
+ return ret; | ||
+} | ||
/* | ||
* Now umount can handle mount points as well as block devices. | ||
* This is important for filesystems which use unnamed block devices. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.