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;
// FIXME: when chase() learns to chase non-existent paths, use this here and drop the prefixing with
// /sysroot on error below.
- r = chase(path, initrd ? "/sysroot" : NULL, CHASE_PREFIX_ROOT | CHASE_NONEXISTENT, &p, NULL);
+ r = chase(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);
const char *fstype,
const char *options,
int passno,
- bool initrd,
+ bool prefix_sysroot,
bool use_swap_enabled) {
_cleanup_free_ char *what = NULL, *where = NULL;
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");
* /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;
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 :
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();
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)
m->fstype,
m->options,
/* passno = */ 0,
- /* initrd = */ false,
+ /* prefix_sysroot = */ false,
/* use_swap_enabled = */ false);
if (r < 0 && ret >= 0)
ret = r;
me->mnt_type,
me->mnt_opts,
me->mnt_passno,
- /* initrd = */ false,
+ /* prefix_sysroot = */ false,
/* use_swap_enabled = */ true);
if (r < 0 && ret >= 0)
ret = r;
(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)
/* 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)