summaryrefslogtreecommitdiffstats
path: root/module/spl
diff options
context:
space:
mode:
Diffstat (limited to 'module/spl')
-rw-r--r--module/spl/spl-generic.c26
-rw-r--r--module/spl/spl-vnode.c86
2 files changed, 109 insertions, 3 deletions
diff --git a/module/spl/spl-generic.c b/module/spl/spl-generic.c
index 8bf97e0cf..dc0ac21d0 100644
--- a/module/spl/spl-generic.c
+++ b/module/spl/spl-generic.c
@@ -358,7 +358,8 @@ set_kallsyms_lookup_name(void)
}
#endif
-static int __init spl_init(void)
+static int
+__init spl_init(void)
{
int rc = 0;
@@ -421,7 +422,8 @@ out1:
return rc;
}
-static void spl_fini(void)
+static void
+spl_fini(void)
{
ENTRY;
@@ -436,6 +438,26 @@ static void spl_fini(void)
debug_fini();
}
+/* Called when a dependent module is loaded */
+void
+spl_setup(void)
+{
+ /*
+ * At module load time the pwd is set to '/' on a Solaris system.
+ * On a Linux system will be set to whatever directory the caller
+ * was in when executing insmod/modprobe.
+ */
+ vn_set_pwd("/");
+}
+EXPORT_SYMBOL(spl_setup);
+
+/* Called when a dependent module is unloaded */
+void
+spl_cleanup(void)
+{
+}
+EXPORT_SYMBOL(spl_cleanup);
+
module_init(spl_init);
module_exit(spl_fini);
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)
{