diff options
Diffstat (limited to 'fs/namespace.c')
-rw-r--r-- | fs/namespace.c | 61 |
1 files changed, 1 insertions, 60 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 0a42e0e9602..c6f54e4c429 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/ramfs.h> | 27 | #include <linux/ramfs.h> |
28 | #include <linux/log2.h> | 28 | #include <linux/log2.h> |
29 | #include <linux/idr.h> | 29 | #include <linux/idr.h> |
30 | #include <linux/fs_struct.h> | ||
30 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
31 | #include <asm/unistd.h> | 32 | #include <asm/unistd.h> |
32 | #include "pnode.h" | 33 | #include "pnode.h" |
@@ -2093,66 +2094,6 @@ out1: | |||
2093 | } | 2094 | } |
2094 | 2095 | ||
2095 | /* | 2096 | /* |
2096 | * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. | ||
2097 | * It can block. Requires the big lock held. | ||
2098 | */ | ||
2099 | void set_fs_root(struct fs_struct *fs, struct path *path) | ||
2100 | { | ||
2101 | struct path old_root; | ||
2102 | |||
2103 | write_lock(&fs->lock); | ||
2104 | old_root = fs->root; | ||
2105 | fs->root = *path; | ||
2106 | path_get(path); | ||
2107 | write_unlock(&fs->lock); | ||
2108 | if (old_root.dentry) | ||
2109 | path_put(&old_root); | ||
2110 | } | ||
2111 | |||
2112 | /* | ||
2113 | * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values. | ||
2114 | * It can block. Requires the big lock held. | ||
2115 | */ | ||
2116 | void set_fs_pwd(struct fs_struct *fs, struct path *path) | ||
2117 | { | ||
2118 | struct path old_pwd; | ||
2119 | |||
2120 | write_lock(&fs->lock); | ||
2121 | old_pwd = fs->pwd; | ||
2122 | fs->pwd = *path; | ||
2123 | path_get(path); | ||
2124 | write_unlock(&fs->lock); | ||
2125 | |||
2126 | if (old_pwd.dentry) | ||
2127 | path_put(&old_pwd); | ||
2128 | } | ||
2129 | |||
2130 | static void chroot_fs_refs(struct path *old_root, struct path *new_root) | ||
2131 | { | ||
2132 | struct task_struct *g, *p; | ||
2133 | struct fs_struct *fs; | ||
2134 | |||
2135 | read_lock(&tasklist_lock); | ||
2136 | do_each_thread(g, p) { | ||
2137 | task_lock(p); | ||
2138 | fs = p->fs; | ||
2139 | if (fs) { | ||
2140 | atomic_inc(&fs->count); | ||
2141 | task_unlock(p); | ||
2142 | if (fs->root.dentry == old_root->dentry | ||
2143 | && fs->root.mnt == old_root->mnt) | ||
2144 | set_fs_root(fs, new_root); | ||
2145 | if (fs->pwd.dentry == old_root->dentry | ||
2146 | && fs->pwd.mnt == old_root->mnt) | ||
2147 | set_fs_pwd(fs, new_root); | ||
2148 | put_fs_struct(fs); | ||
2149 | } else | ||
2150 | task_unlock(p); | ||
2151 | } while_each_thread(g, p); | ||
2152 | read_unlock(&tasklist_lock); | ||
2153 | } | ||
2154 | |||
2155 | /* | ||
2156 | * pivot_root Semantics: | 2097 | * pivot_root Semantics: |
2157 | * Moves the root file system of the current process to the directory put_old, | 2098 | * Moves the root file system of the current process to the directory put_old, |
2158 | * makes new_root as the new root file system of the current process, and sets | 2099 | * makes new_root as the new root file system of the current process, and sets |