[PATCH 1/3] fs: Makes functions used by pivot_root accessible
From: bosrsf04
Date: Fri Feb 24 2017 - 19:22:52 EST
From: Brian Ashworth <bosrsf04@xxxxxxxxx>
add/remove: 1/0 grow/shrink: 0/2 up/down: 19/-44 (-25)
function old new delta
detach_mnt - 19 +19
attach_recursive_mnt 349 331 -18
sys_pivot_root 636 610 -26
Total: Before=1899598, After=1899573, chg -0.00%
Signed-off-by: Brian Ashworth <bosrsf04@xxxxxxxxx>
---
fs/mount.h | 24 ++++++++++++++++++++++++
fs/namespace.c | 27 ++++++---------------------
2 files changed, 30 insertions(+), 21 deletions(-)
diff --git a/fs/mount.h b/fs/mount.h
index 2c856fc47ae3..c228d0c233e8 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -3,6 +3,7 @@
#include <linux/poll.h>
#include <linux/ns_common.h>
#include <linux/fs_pin.h>
+#include <linux/nsproxy.h>
struct mnt_namespace {
atomic_t count;
@@ -145,3 +146,26 @@ static inline bool is_local_mountpoint(struct dentry *dentry)
return __is_local_mountpoint(dentry);
}
+
+/*
+ * Is the caller allowed to modify his namespace?
+ */
+static inline bool may_mount(void)
+{
+ return ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN);
+}
+
+static inline int check_mnt(struct mount *mnt)
+{
+ return mnt->mnt_ns == current->nsproxy->mnt_ns;
+}
+
+struct mountpoint *lock_mount(struct path *path);
+void unlock_mount(struct mountpoint *where);
+
+void detach_mnt(struct mount *mnt, struct path *old_path);
+void attach_mnt(struct mount *mnt, struct mount *parent, struct mountpoint *mp);
+
+void touch_mnt_namespace(struct mnt_namespace *ns);
+
+void put_mountpoint(struct mountpoint *mp);
diff --git a/fs/namespace.c b/fs/namespace.c
index 487ba30bb5c6..d49d615e30a1 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -789,7 +789,7 @@ static struct mountpoint *get_mountpoint(struct dentry *dentry)
return mp;
}
-static void put_mountpoint(struct mountpoint *mp)
+void put_mountpoint(struct mountpoint *mp)
{
if (!--mp->m_count) {
struct dentry *dentry = mp->m_dentry;
@@ -802,15 +802,10 @@ static void put_mountpoint(struct mountpoint *mp)
}
}
-static inline int check_mnt(struct mount *mnt)
-{
- return mnt->mnt_ns == current->nsproxy->mnt_ns;
-}
-
/*
* vfsmount lock must be held for write
*/
-static void touch_mnt_namespace(struct mnt_namespace *ns)
+void touch_mnt_namespace(struct mnt_namespace *ns)
{
if (ns) {
ns->event = ++event;
@@ -846,7 +841,7 @@ static void unhash_mnt(struct mount *mnt)
/*
* vfsmount lock must be held for write
*/
-static void detach_mnt(struct mount *mnt, struct path *old_path)
+void detach_mnt(struct mount *mnt, struct path *old_path)
{
old_path->dentry = mnt->mnt_mountpoint;
old_path->mnt = &mnt->mnt_parent->mnt;
@@ -881,9 +876,7 @@ void mnt_set_mountpoint(struct mount *mnt,
/*
* vfsmount lock must be held for write
*/
-static void attach_mnt(struct mount *mnt,
- struct mount *parent,
- struct mountpoint *mp)
+void attach_mnt(struct mount *mnt, struct mount *parent, struct mountpoint *mp)
{
mnt_set_mountpoint(parent, mp, mnt);
hlist_add_head_rcu(&mnt->mnt_hash, m_hash(&parent->mnt, mp->m_dentry));
@@ -1639,14 +1632,6 @@ void __detach_mounts(struct dentry *dentry)
namespace_unlock();
}
-/*
- * Is the caller allowed to modify his namespace?
- */
-static inline bool may_mount(void)
-{
- return ns_capable(current->nsproxy->mnt_ns->user_ns, CAP_SYS_ADMIN);
-}
-
static inline bool may_mandlock(void)
{
#ifndef CONFIG_MANDATORY_FILE_LOCKING
@@ -2049,7 +2034,7 @@ static int attach_recursive_mnt(struct mount *source_mnt,
return err;
}
-static struct mountpoint *lock_mount(struct path *path)
+struct mountpoint *lock_mount(struct path *path)
{
struct vfsmount *mnt;
struct dentry *dentry = path->dentry;
@@ -2078,7 +2063,7 @@ static struct mountpoint *lock_mount(struct path *path)
goto retry;
}
-static void unlock_mount(struct mountpoint *where)
+void unlock_mount(struct mountpoint *where)
{
struct dentry *dentry = where->m_dentry;
--
2.11.1