diff options
Diffstat (limited to 'fs/namespace.c')
-rw-r--r-- | fs/namespace.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 50ca17d3cb45..a3035223d421 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -2732,6 +2732,30 @@ bool our_mnt(struct vfsmount *mnt) | |||
2732 | return check_mnt(real_mount(mnt)); | 2732 | return check_mnt(real_mount(mnt)); |
2733 | } | 2733 | } |
2734 | 2734 | ||
2735 | bool current_chrooted(void) | ||
2736 | { | ||
2737 | /* Does the current process have a non-standard root */ | ||
2738 | struct path ns_root; | ||
2739 | struct path fs_root; | ||
2740 | bool chrooted; | ||
2741 | |||
2742 | /* Find the namespace root */ | ||
2743 | ns_root.mnt = ¤t->nsproxy->mnt_ns->root->mnt; | ||
2744 | ns_root.dentry = ns_root.mnt->mnt_root; | ||
2745 | path_get(&ns_root); | ||
2746 | while (d_mountpoint(ns_root.dentry) && follow_down_one(&ns_root)) | ||
2747 | ; | ||
2748 | |||
2749 | get_fs_root(current->fs, &fs_root); | ||
2750 | |||
2751 | chrooted = !path_equal(&fs_root, &ns_root); | ||
2752 | |||
2753 | path_put(&fs_root); | ||
2754 | path_put(&ns_root); | ||
2755 | |||
2756 | return chrooted; | ||
2757 | } | ||
2758 | |||
2735 | static void *mntns_get(struct task_struct *task) | 2759 | static void *mntns_get(struct task_struct *task) |
2736 | { | 2760 | { |
2737 | struct mnt_namespace *ns = NULL; | 2761 | struct mnt_namespace *ns = NULL; |