summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2022-01-04 23:17:29 +0100
committerRafał Miłecki <rafal@milecki.pl>2022-01-11 18:52:54 +0100
commit8a0ba3b13152e162c968faf5002c13c11ac58b74 (patch)
tree3ad8c2e1d0ea458906e2c8225fba9fd89523f59e
parent128ecaf8da9887b3a1fe35ed95d352a9b64b6342 (diff)
downloadfstools-8a0ba3b13152e162c968faf5002c13c11ac58b74.tar.gz
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 <rafal@milecki.pl>
-rw-r--r--libfstools/extroot.c7
-rw-r--r--libfstools/libfstools.h3
-rw-r--r--libfstools/overlay.c3
-rw-r--r--mount_root.c3
4 files changed, 4 insertions, 12 deletions
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;
}