[PATCH RFC v3 22/90] nsfs: make open_namespace() available outside of fs/

From: Josef Bacik

Date: Thu Nov 05 2026 - 10:06:19 EST


While a cell is being built it hands out nsfs file descriptors for its
network and pid namespaces. That code lives in kernel/cell/ and needs
open_namespace(). Move the declaration from fs/internal.h to linux/nsfs.h.

The name is too generic for a function that is visible everywhere. Rename
it to ns_open_namespace(), in line with the other functions that are
declared in that header.

Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
---
fs/internal.h | 1 -
fs/nsfs.c | 6 +++---
fs/pidfs.c | 4 ++--
include/linux/nsfs.h | 1 +
4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/internal.h b/fs/internal.h
index 2ce49dff6ee1..8446aed78466 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -251,7 +251,6 @@ extern void mnt_pin_kill(struct mount *m);
* fs/nsfs.c
*/
extern const struct dentry_operations ns_dentry_operations;
-int open_namespace(struct ns_common *ns);
struct file *open_namespace_file(struct ns_common *ns);

/*
diff --git a/fs/nsfs.c b/fs/nsfs.c
index 8179d69da038..2c7165bb6739 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -113,14 +113,14 @@ struct file *open_namespace_file(struct ns_common *ns)
}

/**
- * open_namespace - open a namespace
+ * ns_open_namespace - open a namespace
* @ns: the namespace to open
*
* This will consume a reference to @ns indendent of success or failure.
*
* Return: A file descriptor on success or a negative error code on failure.
*/
-int open_namespace(struct ns_common *ns)
+int ns_open_namespace(struct ns_common *ns)
{
struct path path __free(path_put) = {};
int err;
@@ -142,7 +142,7 @@ int open_related_ns(struct ns_common *ns,
if (IS_ERR(relative))
return PTR_ERR(relative);

- return open_namespace(relative);
+ return ns_open_namespace(relative);
}
EXPORT_SYMBOL_GPL(open_related_ns);

diff --git a/fs/pidfs.c b/fs/pidfs.c
index 114d2713a79e..ef305cc359eb 100644
--- a/fs/pidfs.c
+++ b/fs/pidfs.c
@@ -709,8 +709,8 @@ static long pidfd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (error)
return error;

- /* open_namespace() unconditionally consumes the reference */
- return open_namespace(ns_common);
+ /* ns_open_namespace() unconditionally consumes the reference */
+ return ns_open_namespace(ns_common);
}

#ifdef CONFIG_COMPAT
diff --git a/include/linux/nsfs.h b/include/linux/nsfs.h
index 731b67fc2fec..4cb87c7644a2 100644
--- a/include/linux/nsfs.h
+++ b/include/linux/nsfs.h
@@ -23,6 +23,7 @@ bool ns_match(const struct ns_common *ns, dev_t dev, ino_t ino);
int ns_get_name(char *buf, size_t size, struct task_struct *task,
const struct proc_ns_operations *ns_ops);
void nsfs_init(void);
+int ns_open_namespace(struct ns_common *ns);

#define __current_namespace_from_type(__ns) \
_Generic((__ns), \

--
2.55.0