diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2024-03-04 19:59:19 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-03-05 16:28:05 +0100 |
commit | abb3a37a503110e0818b2d933ff7e80b62f3f3b7 (patch) | |
tree | 1cf6a05d9dbc7a7d4cef9724f43a5a82f404d774 | |
parent | a9020bdff31ab263958fd513f8582938a39d5526 (diff) | |
download | barebox-abb3a37a5031.tar.gz barebox-abb3a37a5031.tar.xz |
fs: set current working dir directly when mounting root
The default current working directory is the root directory, but this
can't be initialized statically, because the root directory is only
mounted at runtime. Therefore, the get_pwd accessor initializes the
current working directory on first access.
Instead we could just initialize them when we mount the root directory
and simplify the code a tiny bit.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20240304190038.3486881-35-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | fs/fs.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -1651,11 +1651,6 @@ static inline void get_root(struct path *root) static inline void get_pwd(struct path *pwd) { - if (!cwd_dentry) { - cwd_dentry = d_root; - cwd_mnt = mnt_root; - } - pwd->dentry = cwd_dentry; pwd->mnt = cwd_mnt; @@ -3211,6 +3206,9 @@ int mount(const char *device, const char *fsname, const char *pathname, fsdev->vfsmount.mountpoint = d_root; fsdev->vfsmount.parent = &fsdev->vfsmount; fsdev->path = xstrdup("/"); + + cwd_dentry = d_root; + cwd_mnt = mnt_root; } fsdev->vfsmount.mnt_root = fsdev->sb.s_root; |