mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-01 01:33:20 +00:00
nixos/generate-config: Support detecting nested subvolumes
This commit is contained in:
parent
0b66483c9a
commit
7fae423522
@ -346,15 +346,25 @@ EOF
|
||||
|
||||
# Is this a btrfs filesystem?
|
||||
if ($fsType eq "btrfs") {
|
||||
my ($status, @info) = runCommand("btrfs subvol show $rootDir$mountPoint");
|
||||
my ($status, @id_info) = runCommand("btrfs subvol show $rootDir$mountPoint");
|
||||
if ($status != 0) {
|
||||
die "Failed to retreive subvolume info for $mountPoint";
|
||||
die "Failed to retreive subvolume info for $mountPoint\n";
|
||||
}
|
||||
my @subvols = join("", @info) =~ m/Name:[ \t\n]*([^ \t\n]*)/;
|
||||
if ($#subvols > 0) {
|
||||
my @ids = join("", @id_info) =~ m/Object ID:[ \t\n]*([^ \t\n]*)/;
|
||||
if ($#ids > 0) {
|
||||
die "Btrfs subvol name for $mountPoint listed multiple times in mount\n"
|
||||
} elsif ($#subvols == 0) {
|
||||
push @extraOptions, "subvol=$subvols[0]";
|
||||
} elsif ($#ids == 0) {
|
||||
my ($status, @path_info) = runCommand("btrfs subvol list $rootDir$mountPoint");
|
||||
if ($status != 0) {
|
||||
die "Failed to find $mountPoint subvolume id from btrfs\n";
|
||||
}
|
||||
my @paths = join("", @path_info) =~ m/ID $ids[0] [^\n]* path ([^\n]*)/;
|
||||
if ($#paths > 0) {
|
||||
die "Btrfs returned multiple paths for a single subvolume id, mountpoint $mountPoint\n";
|
||||
} elsif ($#paths != 0) {
|
||||
die "Btrfs did not return a path for the subvolume at $mountPoint\n";
|
||||
}
|
||||
push @extraOptions, "subvol=$paths[0]";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user