From: Rafał Miłecki Date: Tue, 4 Jan 2022 22:17:29 +0000 (+0100) Subject: libfstools: get rid of "extroot_prefix" global variable X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=8a0ba3b13152e162c968faf5002c13c11ac58b74;p=project%2Ffstools.git libfstools: get rid of "extroot_prefix" global variable Replace it with mount_extroot() argument. It's cleaner than a global var. Signed-off-by: Rafał Miłecki --- diff --git a/libfstools/extroot.c b/libfstools/extroot.c index 418df94..7cc0b19 100644 --- a/libfstools/extroot.c +++ b/libfstools/extroot.c @@ -23,13 +23,11 @@ #include "libfstools.h" -char const *extroot_prefix = NULL; - /* * This will execute "block extroot" and make use of mounted extroot or return * an error. */ -int mount_extroot(void) +int mount_extroot(char const *extroot_prefix) { char ldlib_path[32]; char block_path[32]; @@ -37,9 +35,6 @@ int mount_extroot(void) struct stat s; pid_t pid; - if (!extroot_prefix) - return -1; - /* try finding the library directory */ snprintf(ldlib_path, sizeof(ldlib_path), "%s/upper/lib", extroot_prefix); diff --git a/libfstools/libfstools.h b/libfstools/libfstools.h index 6aa0e41..340e2dc 100644 --- a/libfstools/libfstools.h +++ b/libfstools/libfstools.h @@ -39,8 +39,7 @@ enum fs_state { __FS_STATE_LAST = FS_STATE_READY, }; -extern char const *extroot_prefix; -extern int mount_extroot(void); +extern int mount_extroot(char const *extroot_prefix); extern int mount_snapshot(struct volume *v); extern int mount_overlay(struct volume *v); diff --git a/libfstools/overlay.c b/libfstools/overlay.c index 352f0f2..26f0d6e 100644 --- a/libfstools/overlay.c +++ b/libfstools/overlay.c @@ -435,8 +435,7 @@ int mount_overlay(struct volume *v) * Check for extroot config in overlay (rootfs_data) and if present then * prefer it over rootfs_data. */ - extroot_prefix = "/tmp/overlay"; - if (!mount_extroot()) { + if (!mount_extroot("/tmp/overlay")) { ULOG_INFO("switched to extroot\n"); return 0; } diff --git a/mount_root.c b/mount_root.c index ca2c31c..d343909 100644 --- a/mount_root.c +++ b/mount_root.c @@ -45,8 +45,7 @@ start(int argc, char *argv[1]) } /* Check for extroot config in rootfs before even trying rootfs_data */ - extroot_prefix = ""; - if (!mount_extroot()) { + if (!mount_extroot("")) { ULOG_NOTE("switched to extroot\n"); return 0; }