SPL_AC_GET_ZONE_COUNTS
SPL_AC_USER_PATH_DIR
SPL_AC_SET_FS_PWD
- SPL_AC_2ARGS_SET_FS_PWD
SPL_AC_SET_FS_PWD_WITH_CONST
SPL_AC_2ARGS_VFS_UNLINK
SPL_AC_4ARGS_VFS_RENAME
])
])
-dnl #
-dnl # 2.6.25 API change,
-dnl # Simplied API by replacing mnt+dentry args with a single path arg.
-dnl #
-AC_DEFUN([SPL_AC_2ARGS_SET_FS_PWD],
- [AC_MSG_CHECKING([whether set_fs_pwd() wants 2 args])
- SPL_LINUX_TRY_COMPILE([
- #include <linux/sched.h>
- #include <linux/fs_struct.h>
- ],[
- set_fs_pwd(NULL, NULL);
- ],[
- AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_2ARGS_SET_FS_PWD, 1,
- [set_fs_pwd() wants 2 args])
- HAVE_2ARGS_SET_FS_PWD=yes
- ],[
- AC_MSG_RESULT(no)
- ])
-])
-
dnl #
dnl # 3.9 API change
dnl # set_fs_pwd takes const struct path *
dnl #
AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
-if test "x$HAVE_2ARGS_SET_FS_PWD" = xyes; then
tmp_flags="$EXTRA_KCFLAGS"
EXTRA_KCFLAGS="-Werror"
[AC_MSG_CHECKING([whether set_fs_pwd() requires const struct path *])
])
])
EXTRA_KCFLAGS="$tmp_flags"
-fi
])
dnl #
EXPORT_SYMBOL(releasef);
#ifndef HAVE_SET_FS_PWD
-# ifdef HAVE_2ARGS_SET_FS_PWD
-/* Used from 2.6.25 - 2.6.31+ */
void
# ifdef HAVE_SET_FS_PWD_WITH_CONST
set_fs_pwd(struct fs_struct *fs, const struct path *path)
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)
{
-#if defined(HAVE_2ARGS_SET_FS_PWD) && defined(HAVE_USER_PATH_DIR)
+#ifdef HAVE_USER_PATH_DIR
struct path path;
#else
struct nameidata nd;
-#endif /* HAVE_2ARGS_SET_FS_PWD */
+#endif /* HAVE_USER_PATH_DIR */
mm_segment_t saved_fs;
int rc;
SENTRY;
saved_fs = get_fs();
set_fs(get_ds());
-#ifdef HAVE_2ARGS_SET_FS_PWD
# ifdef HAVE_USER_PATH_DIR
rc = user_path_dir(filename, &path);
if (rc)
dput_and_out:
path_put(&nd.path);
# endif /* HAVE_USER_PATH_DIR */
-#else
- rc = __user_walk(filename,
- LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_CHDIR, &nd);
- if (rc)
- SGOTO(out, rc);
-
- rc = vfs_permission(&nd, MAY_EXEC);
- if (rc)
- SGOTO(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:
set_fs(saved_fs);