You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
6.7 KiB
148 lines
6.7 KiB
1 year ago
|
From a6a19f42916248badbc087d75c28e9c96a8ddb28 Mon Sep 17 00:00:00 2001
|
||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||
|
Date: Wed, 26 Jul 2023 03:17:01 +0900
|
||
|
Subject: [PATCH] fstab-generator: rename 'initrd' flag to 'prefix_sysroot'
|
||
|
|
||
|
The name 'initrd' is confusing with 'in_initrd()'.
|
||
|
|
||
|
(cherry picked from commit 8f88e57397bc6d4f897c4547770e67abd849498d)
|
||
|
|
||
|
Related: #2190226
|
||
|
---
|
||
|
src/fstab-generator/fstab-generator.c | 32 +++++++++++++--------------
|
||
|
1 file changed, 16 insertions(+), 16 deletions(-)
|
||
|
|
||
|
diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c
|
||
|
index 4885d6d722..07f5ae5b73 100644
|
||
|
--- a/src/fstab-generator/fstab-generator.c
|
||
|
+++ b/src/fstab-generator/fstab-generator.c
|
||
|
@@ -793,7 +793,7 @@ static MountPointFlags fstab_options_to_flags(const char *options, bool is_swap)
|
||
|
return flags;
|
||
|
}
|
||
|
|
||
|
-static int canonicalize_mount_path(const char *path, const char *type, bool initrd, char **ret) {
|
||
|
+static int canonicalize_mount_path(const char *path, const char *type, bool prefix_sysroot, char **ret) {
|
||
|
_cleanup_free_ char *p = NULL;
|
||
|
bool changed;
|
||
|
int r;
|
||
|
@@ -805,11 +805,11 @@ static int canonicalize_mount_path(const char *path, const char *type, bool init
|
||
|
|
||
|
// FIXME: when chase() learns to chase non-existent paths, use this here and drop the prefixing with
|
||
|
// /sysroot on error below.
|
||
|
- r = chase_symlinks(path, initrd ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &p, NULL);
|
||
|
+ r = chase_symlinks(path, prefix_sysroot ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &p, NULL);
|
||
|
if (r < 0) {
|
||
|
log_debug_errno(r, "Failed to chase '%s', using as-is: %m", path);
|
||
|
|
||
|
- if (initrd)
|
||
|
+ if (prefix_sysroot)
|
||
|
p = path_join("/sysroot", path);
|
||
|
else
|
||
|
p = strdup(path);
|
||
|
@@ -834,7 +834,7 @@ static int parse_fstab_one(
|
||
|
const char *fstype,
|
||
|
const char *options,
|
||
|
int passno,
|
||
|
- bool initrd,
|
||
|
+ bool prefix_sysroot,
|
||
|
bool use_swap_enabled) {
|
||
|
|
||
|
_cleanup_free_ char *what = NULL, *where = NULL;
|
||
|
@@ -846,7 +846,7 @@ static int parse_fstab_one(
|
||
|
assert(fstype);
|
||
|
assert(options);
|
||
|
|
||
|
- if (initrd && !mount_in_initrd(where_original, options))
|
||
|
+ if (prefix_sysroot && !mount_in_initrd(where_original, options))
|
||
|
return 0;
|
||
|
|
||
|
is_swap = streq_ptr(fstype, "swap");
|
||
|
@@ -883,16 +883,16 @@ static int parse_fstab_one(
|
||
|
* /etc/fstab. So we canonicalize here. Note that we use CHASE_NONEXISTENT to handle the case
|
||
|
* where a symlink refers to another mount target; this works assuming the sub-mountpoint
|
||
|
* target is the final directory. */
|
||
|
- r = canonicalize_mount_path(where_original, "where", initrd, &where);
|
||
|
+ r = canonicalize_mount_path(where_original, "where", prefix_sysroot, &where);
|
||
|
if (r < 0)
|
||
|
return r;
|
||
|
where_changed = r > 0;
|
||
|
|
||
|
- if (initrd && fstab_is_bind(options, fstype)) {
|
||
|
+ if (prefix_sysroot && fstab_is_bind(options, fstype)) {
|
||
|
/* When in initrd, the source of bind mount needs to be prepended with /sysroot as well. */
|
||
|
_cleanup_free_ char *p = NULL;
|
||
|
|
||
|
- r = canonicalize_mount_path(what, "what", initrd, &p);
|
||
|
+ r = canonicalize_mount_path(what, "what", prefix_sysroot, &p);
|
||
|
if (r < 0)
|
||
|
return r;
|
||
|
|
||
|
@@ -912,7 +912,7 @@ static int parse_fstab_one(
|
||
|
bool is_sysroot_usr = in_initrd() && path_equal(where, "/sysroot/usr");
|
||
|
|
||
|
const char *target_unit =
|
||
|
- initrd ? SPECIAL_INITRD_FS_TARGET :
|
||
|
+ prefix_sysroot ? SPECIAL_INITRD_FS_TARGET :
|
||
|
is_sysroot ? SPECIAL_INITRD_ROOT_FS_TARGET :
|
||
|
is_sysroot_usr ? SPECIAL_INITRD_USR_FS_TARGET :
|
||
|
mount_is_network(fstype, options) ? SPECIAL_REMOTE_FS_TARGET :
|
||
|
@@ -941,13 +941,13 @@ static int parse_fstab_one(
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
-static int parse_fstab(bool initrd) {
|
||
|
+static int parse_fstab(bool prefix_sysroot) {
|
||
|
_cleanup_endmntent_ FILE *f = NULL;
|
||
|
const char *fstab;
|
||
|
struct mntent *me;
|
||
|
int r, ret = 0;
|
||
|
|
||
|
- if (initrd)
|
||
|
+ if (prefix_sysroot)
|
||
|
fstab = sysroot_fstab_path();
|
||
|
else {
|
||
|
fstab = fstab_path();
|
||
|
@@ -967,7 +967,7 @@ static int parse_fstab(bool initrd) {
|
||
|
while ((me = getmntent(f))) {
|
||
|
r = parse_fstab_one(fstab,
|
||
|
me->mnt_fsname, me->mnt_dir, me->mnt_type, me->mnt_opts, me->mnt_passno,
|
||
|
- initrd, /* use_swap_enabled = */ true);
|
||
|
+ prefix_sysroot, /* use_swap_enabled = */ true);
|
||
|
if (r < 0 && ret >= 0)
|
||
|
ret = r;
|
||
|
if (arg_sysroot_check && r > 0)
|
||
|
@@ -1274,7 +1274,7 @@ static int add_mounts_from_cmdline(void) {
|
||
|
m->fstype,
|
||
|
m->options,
|
||
|
/* passno = */ 0,
|
||
|
- /* initrd = */ false,
|
||
|
+ /* prefix_sysroot = */ false,
|
||
|
/* use_swap_enabled = */ false);
|
||
|
if (r < 0 && ret >= 0)
|
||
|
ret = r;
|
||
|
@@ -1447,7 +1447,7 @@ static int run_generator(void) {
|
||
|
(void) determine_usr();
|
||
|
|
||
|
if (arg_sysroot_check) {
|
||
|
- r = parse_fstab(/* initrd= */ true);
|
||
|
+ r = parse_fstab(/* prefix_sysroot = */ true);
|
||
|
if (r == 0)
|
||
|
log_debug("Nothing interesting found, not doing daemon-reload.");
|
||
|
if (r > 0)
|
||
|
@@ -1477,13 +1477,13 @@ static int run_generator(void) {
|
||
|
/* Honour /etc/fstab only when that's enabled */
|
||
|
if (arg_fstab_enabled) {
|
||
|
/* Parse the local /etc/fstab, possibly from the initrd */
|
||
|
- r = parse_fstab(/* initrd= */ false);
|
||
|
+ r = parse_fstab(/* prefix_sysroot = */ false);
|
||
|
if (r < 0 && ret >= 0)
|
||
|
ret = r;
|
||
|
|
||
|
/* If running in the initrd also parse the /etc/fstab from the host */
|
||
|
if (in_initrd())
|
||
|
- r = parse_fstab(/* initrd= */ true);
|
||
|
+ r = parse_fstab(/* prefix_sysroot = */ true);
|
||
|
else
|
||
|
r = generator_enable_remount_fs_service(arg_dest);
|
||
|
if (r < 0 && ret >= 0)
|