aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2009-03-29 19:00:13 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2009-03-31 23:00:26 -0400
commit3e93cd671813e204c258f1e6c797959920cf7772 (patch)
treea1e0b2d2da7d296cc1c53be9cd6efa5b94b01b5c /fs/namespace.c
parentf8ef3ed2bebd2c4cb9ece92efa185d7aead8831a (diff)
Take fs_struct handling to new file (fs/fs_struct.c)
Pure code move; two new helper functions for nfsd and daemonize (unshare_fs_struct() and daemonize_fs_struct() resp.; for now - the same code as used to be in callers). unshare_fs_struct() exported (for nfsd, as copy_fs_struct()/exit_fs() used to be), copy_fs_struct() and exit_fs() don't need exports anymore. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c68
1 files changed, 0 insertions, 68 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index f7ec283ccfbb..1e56303c718e 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2093,74 +2093,6 @@ out1:
2093} 2093}
2094 2094
2095/* 2095/*
2096 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
2097 * It can block. Requires the big lock held.
2098 */
2099void 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 */
2116void 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
2130static 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 int count = 0;
2135
2136 read_lock(&tasklist_lock);
2137 do_each_thread(g, p) {
2138 task_lock(p);
2139 fs = p->fs;
2140 if (fs) {
2141 write_lock(&fs->lock);
2142 if (fs->root.dentry == old_root->dentry
2143 && fs->root.mnt == old_root->mnt) {
2144 path_get(new_root);
2145 fs->root = *new_root;
2146 count++;
2147 }
2148 if (fs->pwd.dentry == old_root->dentry
2149 && fs->pwd.mnt == old_root->mnt) {
2150 path_get(new_root);
2151 fs->pwd = *new_root;
2152 count++;
2153 }
2154 write_unlock(&fs->lock);
2155 }
2156 task_unlock(p);
2157 } while_each_thread(g, p);
2158 read_unlock(&tasklist_lock);
2159 while (count--)
2160 path_put(old_root);
2161}
2162
2163/*
2164 * pivot_root Semantics: 2096 * pivot_root Semantics:
2165 * Moves the root file system of the current process to the directory put_old, 2097 * Moves the root file system of the current process to the directory put_old,
2166 * makes new_root as the new root file system of the current process, and sets 2098 * makes new_root as the new root file system of the current process, and sets