summaryrefslogtreecommitdiffstats
path: root/module/spl/spl-vnode.c
diff options
context:
space:
mode:
Diffstat (limited to 'module/spl/spl-vnode.c')
-rw-r--r--module/spl/spl-vnode.c86
1 files changed, 85 insertions, 1 deletions
diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c
index 08c339a5a..7d2080022 100644
--- a/module/spl/spl-vnode.c
+++ b/module/spl/spl-vnode.c
@@ -34,7 +34,7 @@
#define DEBUG_SUBSYSTEM S_VNODE
-void *rootdir = NULL;
+vnode_t *rootdir = (vnode_t *)0xabcd1234;
EXPORT_SYMBOL(rootdir);
static spl_kmem_cache_t *vn_cache;
@@ -602,6 +602,90 @@ vn_releasef(int fd)
} /* releasef() */
EXPORT_SYMBOL(releasef);
+#ifndef HAVE_SET_FS_PWD
+# ifdef HAVE_2ARGS_SET_FS_PWD
+/* Used from 2.6.25 - 2.6.31+ */
+void
+set_fs_pwd(struct fs_struct *fs, struct path *path)
+{
+ struct path old_pwd;
+
+ write_lock(&fs->lock);
+ old_pwd = fs->pwd;
+ fs->pwd = *path;
+ path_get(path);
+ write_unlock(&fs->lock);
+
+ if (old_pwd.dentry)
+ path_put(&old_pwd);
+}
+# else
+/* Used from 2.6.11 - 2.6.24 */
+void
+set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, struct dentry *dentry)
+{
+ struct dentry *old_pwd;
+ struct vfsmount *old_pwdmnt;
+
+ write_lock(&fs->lock);
+ old_pwd = fs->pwd;
+ old_pwdmnt = fs->pwdmnt;
+ fs->pwdmnt = mntget(mnt);
+ fs->pwd = dget(dentry);
+ write_unlock(&fs->lock);
+
+ if (old_pwd) {
+ dput(old_pwd);
+ mntput(old_pwdmnt);
+ }
+}
+# endif /* HAVE_2ARGS_SET_FS_PWD */
+#endif /* HAVE_SET_FS_PWD */
+
+int
+vn_set_pwd(const char *filename)
+{
+#ifdef HAVE_2ARGS_SET_FS_PWD
+ struct path path;
+ int rc;
+ ENTRY;
+
+ rc = user_path_dir(filename, &path);
+ if (rc)
+ GOTO(out, rc);
+
+ rc = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_ACCESS);
+ if (rc)
+ GOTO(dput_and_out, rc);
+
+ set_fs_pwd(current->fs, &path);
+
+dput_and_out:
+ path_put(&path);
+#else
+ struct nameidata nd;
+ int rc;
+ ENTRY;
+
+ rc = __user_walk(filename,
+ LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_CHDIR, &nd);
+ if (rc)
+ GOTO(out, rc);
+
+ rc = vfs_permission(&nd, MAY_EXEC);
+ if (rc)
+ GOTO(dput_and_out, rc);
+
+ set_fs_pwd(current->fs, nd.nd_mnt, nd.nd_dentry);
+
+dput_and_out:
+ vn_path_release(&nd);
+#endif /* HAVE_2ARGS_SET_FS_PWD */
+out:
+ RETURN(-rc);
+} /* vn_set_pwd() */
+EXPORT_SYMBOL(vn_set_pwd);
+
static int
vn_cache_constructor(void *buf, void *cdrarg, int kmflags)
{