Re: [RFC PATCH v10 03/28] mount: Add mnt_ns_get_root()
From: Jarkko Sakkinen
Date: Sat Dec 05 2026 - 08:48:12 EST
diff --git a/fs/namespace.c b/fs/namespace.c
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -6949,6 +6949,18 @@ static void mntns_put(struct ns_common *ns)
put_mnt_ns(to_mnt_ns(ns));
}
+/**
+ * mnt_ns_get_root - Get the live root of a mount namespace
+ * @mnt_ns: Non-anonymous mount namespace with an active reference held
+ * @root: Storage for the referenced root path
+ *
+ * On success the caller must release @root with path_put(). If no filesystem
+ * covers the initial root, clear @root and return -ENOENT. On lookup failure,
+ * leave @root unchanged.
+ *
+ * Context: Sleepable, without namespace_sem or mount_lock held.
+ * Return: 0 on success or a negative error code.
+ */
int mnt_ns_get_root(struct mnt_namespace *mnt_ns, struct path *root)
{
int err;