summary refs log tree commit diff
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2018-11-06 11:09:02 +0000
committerGitHub <noreply@github.com>2018-11-06 11:09:02 +0000
commitb2099d21cfabe8ed26801bae7deda2a9de1335c3 (patch)
tree25383e50ab6b282e3ed088008c7dc5c1c9f7851c
parent19091a51786593b731f348910dfd05dde5d16c63 (diff)
parent36d695f696e73ff1be79b48e01df663eaac22e3b (diff)
downloadnixlib-b2099d21cfabe8ed26801bae7deda2a9de1335c3.tar
nixlib-b2099d21cfabe8ed26801bae7deda2a9de1335c3.tar.gz
nixlib-b2099d21cfabe8ed26801bae7deda2a9de1335c3.tar.bz2
nixlib-b2099d21cfabe8ed26801bae7deda2a9de1335c3.tar.lz
nixlib-b2099d21cfabe8ed26801bae7deda2a9de1335c3.tar.xz
nixlib-b2099d21cfabe8ed26801bae7deda2a9de1335c3.tar.zst
nixlib-b2099d21cfabe8ed26801bae7deda2a9de1335c3.zip
Merge pull request #49354 from aanderse/fstab-escaping
filesystems: escape spaces in fstab with \040
-rw-r--r--nixos/modules/tasks/filesystems.nix8
1 files changed, 5 insertions, 3 deletions
diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix
index b3690fad1a6a..9e4057b50897 100644
--- a/nixos/modules/tasks/filesystems.nix
+++ b/nixos/modules/tasks/filesystems.nix
@@ -230,6 +230,8 @@ in
       let
         fsToSkipCheck = [ "none" "bindfs" "btrfs" "zfs" "tmpfs" "nfs" "vboxsf" "glusterfs" ];
         skipCheck = fs: fs.noCheck || fs.device == "none" || builtins.elem fs.fsType fsToSkipCheck;
+        # https://wiki.archlinux.org/index.php/fstab#Filepath_spaces
+        escape = string: builtins.replaceStrings [ " " ] [ "\\040" ] string;
       in ''
         # This is a generated file.  Do not edit!
         #
@@ -238,10 +240,10 @@ in
 
         # Filesystems.
         ${concatMapStrings (fs:
-            (if fs.device != null then fs.device
-             else if fs.label != null then "/dev/disk/by-label/${fs.label}"
+            (if fs.device != null then escape fs.device
+             else if fs.label != null then "/dev/disk/by-label/${escape fs.label}"
              else throw "No device specified for mount point ‘${fs.mountPoint}’.")
-            + " " + fs.mountPoint
+            + " " + escape fs.mountPoint
             + " " + fs.fsType
             + " " + builtins.concatStringsSep "," fs.options
             + " 0"