Debian Codegraph @

fat/type.go

raw symbols SCIP
1 package fat
2
3 import "github.com/mitchellh/go-fs"
4
5 // FATType is a simple enum of the available FAT filesystem types.
6 type FATType uint8
7
8 const (
9 FAT12 FATType = iota
10 FAT16
11 FAT32
12 )
13
14 // TypeForDevice determines the usable FAT type based solely on
15 // size information about the block device.
16 func TypeForDevice(device fs.BlockDevice) FATType {
17 sizeInMB := device.Len() / (1024 * 1024)
18 switch {
19 case sizeInMB < 4:
20 return FAT12
21 case sizeInMB < 512:
22 return FAT16
23 default:
24 return FAT32
25 }
26 }