[PATCH RFC DRAFT POC 09/11] fs: add init_root()

From: Christian Brauner

Date: Tue Mar 03 2026 - 08:55:16 EST


Add a init_root() helper that allows to grab init's current filesystem
root. This can be used by callers to perform tasks relative to init's
current filesystem root.

Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>
---
fs/fs_struct.c | 6 ++++++
include/linux/fs_struct.h | 2 ++
2 files changed, 8 insertions(+)

diff --git a/fs/fs_struct.c b/fs/fs_struct.c
index ab6826d7a6a9..64b5840131cb 100644
--- a/fs/fs_struct.c
+++ b/fs/fs_struct.c
@@ -196,3 +196,9 @@ struct fs_struct init_fs = {
.seq = __SEQLOCK_UNLOCKED(init_fs.seq),
.umask = 0022,
};
+
+void init_root(struct path *root)
+{
+ get_fs_root(&init_fs, root);
+}
+EXPORT_SYMBOL_GPL(init_root);
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
index ade459383f92..8ff1acd8389d 100644
--- a/include/linux/fs_struct.h
+++ b/include/linux/fs_struct.h
@@ -49,4 +49,6 @@ static inline int current_umask(void)
return current->fs->umask;
}

+void init_root(struct path *root);
+
#endif /* _LINUX_FS_STRUCT_H */

--
2.47.3