From b42af252238d8e5a4b737ad39fda503f9d93c36f Mon Sep 17 00:00:00 2001 From: Jörg Thalheim Date: Tue, 4 Apr 2017 23:27:51 +0200 Subject: stage-2: replace readonly-mountpoint by findmnt --- nixos/modules/system/boot/readonly-mountpoint.c | 20 -------------------- nixos/modules/system/boot/stage-2-init.sh | 4 +++- nixos/modules/system/boot/stage-2.nix | 13 ++----------- 3 files changed, 5 insertions(+), 32 deletions(-) delete mode 100644 nixos/modules/system/boot/readonly-mountpoint.c (limited to 'nixos/modules/system') diff --git a/nixos/modules/system/boot/readonly-mountpoint.c b/nixos/modules/system/boot/readonly-mountpoint.c deleted file mode 100644 index 27b666873821a..0000000000000 --- a/nixos/modules/system/boot/readonly-mountpoint.c +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include - -int main(int argc, char ** argv) { - struct statvfs stat; - if (argc != 2) { - fprintf(stderr, "Usage: %s PATH", argv[0]); - exit(2); - } - if (statvfs(argv[1], &stat) != 0) { - perror("statvfs"); - exit(3); - } - if (stat.f_flag & ST_RDONLY) - exit(0); - else - exit(1); -} - diff --git a/nixos/modules/system/boot/stage-2-init.sh b/nixos/modules/system/boot/stage-2-init.sh index 99930fb95a61a..b5b2acf86ab30 100644 --- a/nixos/modules/system/boot/stage-2-init.sh +++ b/nixos/modules/system/boot/stage-2-init.sh @@ -46,7 +46,9 @@ echo "booting system configuration $systemConfig" > /dev/kmsg chown -f 0:30000 /nix/store chmod -f 1775 /nix/store if [ -n "@readOnlyStore@" ]; then - if ! readonly-mountpoint /nix/store; then + if ! [[ "$(findmnt --noheadings --output OPTIONS /nix/store)" =~ ro(,|$) ]]; then + # FIXME when linux < 4.5 is EOL, switch to atomic bind mounts + #mount /nix/store /nix/store -o bind,remount,ro mount --bind /nix/store /nix/store mount -o remount,ro,bind /nix/store fi diff --git a/nixos/modules/system/boot/stage-2.nix b/nixos/modules/system/boot/stage-2.nix index a6864bf80c30c..8db6d2d2f7347 100644 --- a/nixos/modules/system/boot/stage-2.nix +++ b/nixos/modules/system/boot/stage-2.nix @@ -7,15 +7,6 @@ let kernel = config.boot.kernelPackages.kernel; activateConfiguration = config.system.activationScripts.script; - readonlyMountpoint = pkgs.stdenv.mkDerivation { - name = "readonly-mountpoint"; - unpackPhase = "true"; - installPhase = '' - mkdir -p $out/bin - cc -O3 ${./readonly-mountpoint.c} -o $out/bin/readonly-mountpoint - ''; - }; - bootStage2 = pkgs.substituteAll { src = ./stage-2-init.sh; shellDebug = "${pkgs.bashInteractive}/bin/bash"; @@ -23,11 +14,11 @@ let inherit (config.nix) readOnlyStore; inherit (config.networking) useHostResolvConf; inherit (config.system.build) earlyMountScript; - path = lib.makeBinPath ([ + path = lib.makeBinPath [ pkgs.coreutils pkgs.utillinux pkgs.openresolv - ] ++ optional config.nix.readOnlyStore readonlyMountpoint); + ]; postBootCommands = pkgs.writeText "local-cmds" '' ${config.boot.postBootCommands} -- cgit 1.4.1