Skip to content

Commit

Permalink
fix: chain of probe functions
Browse files Browse the repository at this point in the history
Adjust the order of probing once again:

* push up probes which have a strict magic match (xfs, extfs, squashfs,
  etc.), and for filesystems which are commonly used in Talos
* keep GPT after that, as it doesn't have strict magic, but still should
  come early enough before other probes
* ZFS has a very wide way of looking for a superblock, which might match
  ZFS at the end of the disk in a partition, while the disk is actually
  GPT, so keep it low (and it's only an optional extension)

See siderolabs/talos#10069

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira committed Jan 13, 2025
1 parent a047647 commit 688a58a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
30 changes: 30 additions & 0 deletions blkid/blkid_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,16 @@ func corruptGPT(f func(*testing.T, string)) func(*testing.T, string) {
}
}

func gptOverwritesFilesystem(f func(*testing.T, string)) func(*testing.T, string) {
return func(t *testing.T, path string) {
t.Helper()

f(t, path)

setupGPT(t, path)
}
}

func wipe1MB(f func(*testing.T, string)) func(*testing.T, string) {
return func(t *testing.T, path string) {
t.Helper()
Expand Down Expand Up @@ -820,6 +830,26 @@ func TestProbePathGPT(t *testing.T) {
},
},
},
{
name: "GPT overwrites ZFS",

size: 2 * GiB,
setup: gptOverwritesFilesystem(zfsSetup),

expectedSize: 2 * GiB,
expectedUUID: uuid.MustParse("DDDA0816-8B53-47BF-A813-9EBB1F73AAA2"),
expectedParts: expectedParts,
expectedSignatures: []blkid.SignatureRange{
{
Offset: 512,
Size: 512,
},
{
Offset: 2147483136,
Size: 512,
},
},
},
{
name: "corrupted GPT",

Expand Down
13 changes: 6 additions & 7 deletions blkid/internal/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ func Default() Chain {
&ext.Probe3{},
&ext.Probe2{},
&vfat.Probe{},
&swap.Probe{},
&lvm2.Probe{},
&zfs.Probe{},
&iso9660.Probe{},
&squashfs.Probe{},
&talosmeta.Probe{},
&luks.Probe{},
&iso9660.Probe{},
&bluestore.Probe{},
// keep GPT last, as if GPT is overwritten with smaller filesystem image, it should be detected first
&gpt.Probe{},
&bluestore.Probe{},
&luks.Probe{},
&swap.Probe{},
&lvm2.Probe{},
&zfs.Probe{},
}
}

0 comments on commit 688a58a

Please sign in to comment.