X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Ffstab-generator%2Ffstab-generator.c;h=496657bdc176a25b170788d8304bf306ceff5b1b;hp=e8a21f7fff75078fb2d848deb30172493fc50c59;hb=00b4ffdecbb39d849af65c0ab741be482325a4a9;hpb=4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4f;ds=sidebyside diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index e8a21f7ff..496657bdc 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -87,6 +87,11 @@ static int add_swap( assert(what); assert(me); + if (access("/proc/swaps", F_OK) < 0) { + log_info("Swap not supported, ignoring fstab swap entry for %s.", what); + return 0; + } + if (detect_container(NULL) > 0) { log_info("Running in a container, ignoring fstab swap entry for %s.", what); return 0; @@ -355,7 +360,7 @@ static int parse_fstab(bool initrd) { if (!what) return log_oom(); - if (detect_container(NULL) > 0 && is_device_path(what)) { + if (is_device_path(what) && path_is_read_only_fs("sys") > 0) { log_info("Running in a container, ignoring fstab device entry for %s.", what); continue; } @@ -476,7 +481,7 @@ static int add_usr_mount(void) { return log_oom(); } - if (!arg_usr_what || !arg_usr_options) + if (!arg_usr_what) return 0; what = fstab_node_to_udev_node(arg_usr_what); @@ -485,7 +490,13 @@ static int add_usr_mount(void) { return -1; } - opts = arg_usr_options; + if (!arg_usr_options) + opts = arg_root_rw > 0 ? "rw" : "ro"; + else if (!mount_test_option(arg_usr_options, "ro") && + !mount_test_option(arg_usr_options, "rw")) + opts = strappenda(arg_usr_options, ",", arg_root_rw > 0 ? "rw" : "ro"); + else + opts = arg_usr_options; log_debug("Found entry what=%s where=/sysroot/usr type=%s", what, strna(arg_usr_fstype)); return add_mount(what, @@ -617,6 +628,12 @@ int main(int argc, char *argv[]) { } free(arg_root_what); + free(arg_root_fstype); + free(arg_root_options); + + free(arg_usr_what); + free(arg_usr_fstype); + free(arg_usr_options); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; }