Commit 1310a881 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[PATCH] move mount.h out of fs_struct.h

It's only need for the two monster-inlines set_fs_root and set_fs_pwd
that should better be out of line anyway.  Some additional cleanup like
named initializers as extra bonus.
parent fe406442
...@@ -881,6 +881,54 @@ asmlinkage long sys_mount(char * dev_name, char * dir_name, char * type, ...@@ -881,6 +881,54 @@ asmlinkage long sys_mount(char * dev_name, char * dir_name, char * type,
return retval; return retval;
} }
/*
* Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
* It can block. Requires the big lock held.
*/
void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt,
struct dentry *dentry)
{
struct dentry *old_root;
struct vfsmount *old_rootmnt;
write_lock(&fs->lock);
spin_lock(&dcache_lock);
old_root = fs->root;
old_rootmnt = fs->rootmnt;
fs->rootmnt = mntget(mnt);
fs->root = dget(dentry);
spin_unlock(&dcache_lock);
write_unlock(&fs->lock);
if (old_root) {
dput(old_root);
mntput(old_rootmnt);
}
}
/*
* Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values.
* It can block. Requires the big lock held.
*/
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);
spin_lock(&dcache_lock);
old_pwd = fs->pwd;
old_pwdmnt = fs->pwdmnt;
fs->pwdmnt = mntget(mnt);
fs->pwd = dget(dentry);
spin_unlock(&dcache_lock);
write_unlock(&fs->lock);
if (old_pwd) {
dput(old_pwd);
mntput(old_pwdmnt);
}
}
static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd) static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
{ {
struct task_struct *g, *p; struct task_struct *g, *p;
......
#ifndef _LINUX_FS_STRUCT_H #ifndef _LINUX_FS_STRUCT_H
#define _LINUX_FS_STRUCT_H #define _LINUX_FS_STRUCT_H
#ifdef __KERNEL__
#include <linux/mount.h> struct dentry;
#include <linux/dcache.h> struct vfsmount;
struct fs_struct { struct fs_struct {
atomic_t count; atomic_t count;
...@@ -14,67 +13,16 @@ struct fs_struct { ...@@ -14,67 +13,16 @@ struct fs_struct {
}; };
#define INIT_FS { \ #define INIT_FS { \
ATOMIC_INIT(1), \ .count = ATOMIC_INIT(1), \
RW_LOCK_UNLOCKED, \ .lock = RW_LOCK_UNLOCKED, \
0022, \ .umask = 0022, \
NULL, NULL, NULL, NULL, NULL, NULL \
} }
extern void exit_fs(struct task_struct *); extern void exit_fs(struct task_struct *);
extern void set_fs_altroot(void); extern void set_fs_altroot(void);
extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *);
extern void set_fs_pwd(struct fs_struct *, struct vfsmount *, struct dentry *);
extern struct fs_struct *copy_fs_struct(struct fs_struct *);
extern void put_fs_struct(struct fs_struct *);
/* #endif /* _LINUX_FS_STRUCT_H */
* Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
* It can block. Requires the big lock held.
*/
static inline void set_fs_root(struct fs_struct *fs,
struct vfsmount *mnt,
struct dentry *dentry)
{
struct dentry *old_root;
struct vfsmount *old_rootmnt;
write_lock(&fs->lock);
spin_lock(&dcache_lock);
old_root = fs->root;
old_rootmnt = fs->rootmnt;
fs->rootmnt = mntget(mnt);
fs->root = dget(dentry);
spin_unlock(&dcache_lock);
write_unlock(&fs->lock);
if (old_root) {
dput(old_root);
mntput(old_rootmnt);
}
}
/*
* Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values.
* It can block. Requires the big lock held.
*/
static inline 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);
spin_lock(&dcache_lock);
old_pwd = fs->pwd;
old_pwdmnt = fs->pwdmnt;
fs->pwdmnt = mntget(mnt);
fs->pwd = dget(dentry);
spin_unlock(&dcache_lock);
write_unlock(&fs->lock);
if (old_pwd) {
dput(old_pwd);
mntput(old_pwdmnt);
}
}
struct fs_struct *copy_fs_struct(struct fs_struct *old);
void put_fs_struct(struct fs_struct *fs);
#endif
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment