-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support probing FAT12/FAT16 filesystems
We always supported FAT32, but for small disk sizes (like the one you might create for a config partition), `mkfs.vfat` would default to FAT16/32 which Tails fails to discover. Fixes #57 Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
- Loading branch information
Showing
6 changed files
with
115 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
// Package msdos provides functions for working with the FAT12/16 filesystems. | ||
package msdos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
package msdos | ||
|
||
import ( | ||
"bytes" | ||
) | ||
|
||
const ( | ||
// Magic12 is the FAT12 magic signature. | ||
Magic12 = "FAT12" | ||
// Magic16 is the FAT16 magic signature. | ||
Magic16 = "FAT16" | ||
) | ||
|
||
// SuperBlock represents the vfat super block. | ||
// | ||
// See https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system#Extended_BIOS_Parameter_Block for the reference. | ||
type SuperBlock struct { | ||
_ [0x2b]uint8 | ||
Label [11]uint8 | ||
Magic [8]uint8 | ||
_ [0x1cd]uint8 | ||
} | ||
|
||
// Is implements the SuperBlocker interface. | ||
func (sb *SuperBlock) Is() bool { | ||
trimmed := bytes.Trim(sb.Magic[:], " ") | ||
|
||
return bytes.Equal(trimmed, []byte(Magic12)) || bytes.Equal(trimmed, []byte(Magic16)) | ||
} | ||
|
||
// Offset implements the SuperBlocker interface. | ||
func (sb *SuperBlock) Offset() int64 { | ||
return 0x0 | ||
} | ||
|
||
// Type implements the SuperBlocker interface. | ||
func (sb *SuperBlock) Type() string { | ||
// using `vfat` here, as it's the filesystem type in Linux | ||
return "vfat" | ||
} | ||
|
||
// Encrypted implements the SuperBlocker interface. | ||
func (sb *SuperBlock) Encrypted() bool { | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters