fstab-generator: call add_swap() earlier
As 'where' field will be ignored for swap entry.
This commit is contained in:
@@ -131,6 +131,11 @@ static int add_swap(
|
||||
return true;
|
||||
}
|
||||
|
||||
log_debug("Found swap entry what=%s makefs=%s growfs=%s pcrfs=%s noauto=%s nofail=%s",
|
||||
what,
|
||||
yes_no(flags & MOUNT_MAKEFS), yes_no(flags & MOUNT_GROWFS), yes_no(flags & MOUNT_PCRFS),
|
||||
yes_no(flags & MOUNT_NOAUTO), yes_no(flags & MOUNT_NOFAIL));
|
||||
|
||||
r = unit_name_from_path(what, ".swap", &name);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to generate unit name: %m");
|
||||
@@ -702,16 +707,18 @@ static int parse_fstab_one(
|
||||
|
||||
_cleanup_free_ char *what = NULL, *where = NULL, *canonical_where = NULL;
|
||||
MountPointFlags flags;
|
||||
bool is_swap;
|
||||
int r;
|
||||
|
||||
assert(what_original);
|
||||
assert(where_original);
|
||||
assert(fstype);
|
||||
assert(options);
|
||||
|
||||
if (initrd && !mount_in_initrd(where_original, options))
|
||||
return 0;
|
||||
|
||||
is_swap = streq_ptr(fstype, "swap");
|
||||
|
||||
what = fstab_node_to_udev_node(what_original);
|
||||
if (!what)
|
||||
return log_oom();
|
||||
@@ -723,6 +730,13 @@ static int parse_fstab_one(
|
||||
return 0;
|
||||
}
|
||||
|
||||
flags = fstab_options_to_flags(options, is_swap);
|
||||
|
||||
if (is_swap)
|
||||
return add_swap(source, what, options, flags);
|
||||
|
||||
assert(where_original); /* 'where' is not necessary for swap entry. */
|
||||
|
||||
where = strdup(where_original);
|
||||
if (!where)
|
||||
return log_oom();
|
||||
@@ -757,16 +771,11 @@ static int parse_fstab_one(
|
||||
log_debug("Canonicalized what=%s where=%s to %s", what, where, canonical_where);
|
||||
}
|
||||
|
||||
flags = fstab_options_to_flags(options, streq_ptr(fstype, "swap"));
|
||||
|
||||
log_debug("Found entry what=%s where=%s type=%s makefs=%s growfs=%s pcrfs=%s noauto=%s nofail=%s",
|
||||
what, where, strna(fstype),
|
||||
yes_no(flags & MOUNT_MAKEFS), yes_no(flags & MOUNT_GROWFS), yes_no(flags & MOUNT_PCRFS),
|
||||
yes_no(flags & MOUNT_NOAUTO), yes_no(flags & MOUNT_NOFAIL));
|
||||
|
||||
if (streq_ptr(fstype, "swap"))
|
||||
return add_swap(source, what, options, flags);
|
||||
|
||||
bool is_sysroot = in_initrd() && path_equal(where, "/sysroot");
|
||||
/* See comment from add_sysroot_usr_mount() about the need for extra indirection in case /usr needs
|
||||
* to be mounted in order for the root fs to be synthesized based on configuration included in /usr/,
|
||||
|
||||
Reference in New Issue
Block a user