nixos-generate-config: account for mount points & devices with spaces & tabs in the name (#50234)
This commit is contained in:
parent
4a394e4150
commit
c01eeda8e9
@ -340,6 +340,8 @@ foreach my $fs (read_file("/proc/self/mountinfo")) {
|
|||||||
chomp $fs;
|
chomp $fs;
|
||||||
my @fields = split / /, $fs;
|
my @fields = split / /, $fs;
|
||||||
my $mountPoint = $fields[4];
|
my $mountPoint = $fields[4];
|
||||||
|
$mountPoint =~ s/\\040/ /g; # account for mount points with spaces in the name (\040 is the escape character)
|
||||||
|
$mountPoint =~ s/\\011/\t/g; # account for mount points with tabs in the name (\011 is the escape character)
|
||||||
next unless -d $mountPoint;
|
next unless -d $mountPoint;
|
||||||
my @mountOptions = split /,/, $fields[5];
|
my @mountOptions = split /,/, $fields[5];
|
||||||
|
|
||||||
@ -355,6 +357,8 @@ foreach my $fs (read_file("/proc/self/mountinfo")) {
|
|||||||
my $fsType = $fields[$n];
|
my $fsType = $fields[$n];
|
||||||
my $device = $fields[$n + 1];
|
my $device = $fields[$n + 1];
|
||||||
my @superOptions = split /,/, $fields[$n + 2];
|
my @superOptions = split /,/, $fields[$n + 2];
|
||||||
|
$device =~ s/\\040/ /g; # account for devices with spaces in the name (\040 is the escape character)
|
||||||
|
$device =~ s/\\011/\t/g; # account for mount points with tabs in the name (\011 is the escape character)
|
||||||
|
|
||||||
# Skip the read-only bind-mount on /nix/store.
|
# Skip the read-only bind-mount on /nix/store.
|
||||||
next if $mountPoint eq "/nix/store" && (grep { $_ eq "rw" } @superOptions) && (grep { $_ eq "ro" } @mountOptions);
|
next if $mountPoint eq "/nix/store" && (grep { $_ eq "rw" } @superOptions) && (grep { $_ eq "ro" } @mountOptions);
|
||||||
|
@ -231,7 +231,7 @@ in
|
|||||||
fsToSkipCheck = [ "none" "bindfs" "btrfs" "zfs" "tmpfs" "nfs" "vboxsf" "glusterfs" ];
|
fsToSkipCheck = [ "none" "bindfs" "btrfs" "zfs" "tmpfs" "nfs" "vboxsf" "glusterfs" ];
|
||||||
skipCheck = fs: fs.noCheck || fs.device == "none" || builtins.elem fs.fsType fsToSkipCheck;
|
skipCheck = fs: fs.noCheck || fs.device == "none" || builtins.elem fs.fsType fsToSkipCheck;
|
||||||
# https://wiki.archlinux.org/index.php/fstab#Filepath_spaces
|
# https://wiki.archlinux.org/index.php/fstab#Filepath_spaces
|
||||||
escape = string: builtins.replaceStrings [ " " ] [ "\\040" ] string;
|
escape = string: builtins.replaceStrings [ " " "\t" ] [ "\\040" "\\011" ] string;
|
||||||
in ''
|
in ''
|
||||||
# This is a generated file. Do not edit!
|
# This is a generated file. Do not edit!
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user