nixos/generate-config: Don't interpret btrfs subvols as bind mounts
This commit is contained in:
parent
3944239362
commit
87b6232f3a
@ -22,7 +22,7 @@ sub uniq {
|
|||||||
|
|
||||||
sub runCommand {
|
sub runCommand {
|
||||||
my ($cmd) = @_;
|
my ($cmd) = @_;
|
||||||
open FILE, "$cmd 2>/dev/null |" or die "Failed to execute: $cmd\n";
|
open FILE, "$cmd 2>&1 |" or die "Failed to execute: $cmd\n";
|
||||||
my @ret = <FILE>;
|
my @ret = <FILE>;
|
||||||
close FILE;
|
close FILE;
|
||||||
return ($?, @ret);
|
return ($?, @ret);
|
||||||
@ -311,10 +311,13 @@ foreach my $fs (read_file("/proc/self/mountinfo")) {
|
|||||||
|
|
||||||
# Maybe this is a bind-mount of a filesystem we saw earlier?
|
# Maybe this is a bind-mount of a filesystem we saw earlier?
|
||||||
if (defined $fsByDev{$fields[2]}) {
|
if (defined $fsByDev{$fields[2]}) {
|
||||||
my $path = $fields[3]; $path = "" if $path eq "/";
|
# Make sure this isn't a btrfs subvolume
|
||||||
my $base = $fsByDev{$fields[2]};
|
my ($status, @msg) = runCommand("btrfs subvol show $rootDir$mountPoint");
|
||||||
$base = "" if $base eq "/";
|
if (join("", @msg) =~ /ERROR:/) {
|
||||||
$fileSystems .= <<EOF;
|
my $path = $fields[3]; $path = "" if $path eq "/";
|
||||||
|
my $base = $fsByDev{$fields[2]};
|
||||||
|
$base = "" if $base eq "/";
|
||||||
|
$fileSystems .= <<EOF;
|
||||||
fileSystems.\"$mountPoint\" =
|
fileSystems.\"$mountPoint\" =
|
||||||
{ device = \"$base$path\";
|
{ device = \"$base$path\";
|
||||||
fsType = \"none\";
|
fsType = \"none\";
|
||||||
@ -322,7 +325,8 @@ foreach my $fs (read_file("/proc/self/mountinfo")) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
next;
|
next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$fsByDev{$fields[2]} = $mountPoint;
|
$fsByDev{$fields[2]} = $mountPoint;
|
||||||
|
|
||||||
@ -347,7 +351,7 @@ EOF
|
|||||||
# Is this a btrfs filesystem?
|
# Is this a btrfs filesystem?
|
||||||
if ($fsType eq "btrfs") {
|
if ($fsType eq "btrfs") {
|
||||||
my ($status, @id_info) = runCommand("btrfs subvol show $rootDir$mountPoint");
|
my ($status, @id_info) = runCommand("btrfs subvol show $rootDir$mountPoint");
|
||||||
if ($status != 0) {
|
if ($status != 0 || join("", @msg) =~ /ERROR:/) {
|
||||||
die "Failed to retreive subvolume info for $mountPoint\n";
|
die "Failed to retreive subvolume info for $mountPoint\n";
|
||||||
}
|
}
|
||||||
my @ids = join("", @id_info) =~ m/Object ID:[ \t\n]*([^ \t\n]*)/;
|
my @ids = join("", @id_info) =~ m/Object ID:[ \t\n]*([^ \t\n]*)/;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user