2024-09-17 08:01:16 -05:00
|
|
|
stn := @use("../../../libraries/stn/src/lib.hb");
|
|
|
|
.{string, memory, buffer, log} := stn
|
|
|
|
|
2024-09-18 03:38:49 -05:00
|
|
|
attributes := @use("attributes.hb")
|
|
|
|
datetime := @use("datetime.hb")
|
|
|
|
directory := @use("file.hb")
|
|
|
|
bios_parameter_block := @use("bios_parameter_block.hb");
|
2024-09-17 08:01:16 -05:00
|
|
|
.{bpb_sanity_check, ebr_sanity_check, fs_info_sanity_check} := bios_parameter_block;
|
2024-12-01 11:52:26 -06:00
|
|
|
.{BiosParameterBlock, ExtendedBootRecord, FSInfo} := bios_parameter_block
|
2024-09-17 08:01:16 -05:00
|
|
|
|
|
|
|
FAT12_THRESHOLD := 4085
|
|
|
|
FAT16_THRESHOLD := 65525
|
|
|
|
|
|
|
|
ExFAT := 0
|
|
|
|
FAT12 := 1
|
|
|
|
FAT16 := 2
|
|
|
|
FAT32 := 3
|
|
|
|
|
2024-10-25 10:37:38 -05:00
|
|
|
calculate_fat_type := fn(sector_size: uint, total_clusters: uint): uint {
|
2024-09-17 08:01:16 -05:00
|
|
|
if sector_size == 0 {
|
|
|
|
return ExFAT
|
|
|
|
} else if total_clusters < 4085 {
|
|
|
|
return FAT12
|
|
|
|
} else if total_clusters < 65525 {
|
|
|
|
return FAT16
|
|
|
|
} else {
|
|
|
|
return FAT32
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main := fn(): int {
|
2024-12-01 11:52:26 -06:00
|
|
|
bpb := BiosParameterBlock.new()
|
|
|
|
ebr := ExtendedBootRecord.new()
|
|
|
|
fsi := FSInfo.new()
|
2024-09-17 08:01:16 -05:00
|
|
|
|
|
|
|
fat_type := calculate_fat_type(1, 100)
|
|
|
|
|
|
|
|
if fat_type != FAT32 {
|
|
|
|
log.warn("filesystem_fat32 driver only supports Fat32.\0")
|
|
|
|
}
|
|
|
|
|
2024-12-01 11:52:26 -06:00
|
|
|
bsc := bpb.sanity_check()
|
|
|
|
esc := ebr.sanity_check()
|
|
|
|
fssc := fsi.sanity_check()
|
2024-09-17 09:39:46 -05:00
|
|
|
|
|
|
|
msg_type := 0
|
|
|
|
|
|
|
|
loop {
|
2024-09-17 09:52:27 -05:00
|
|
|
// Open file
|
2024-09-17 09:39:46 -05:00
|
|
|
if msg_type == 0 {
|
|
|
|
// Paths without a node-disk component are to be treated as local files.
|
2024-09-17 09:52:27 -05:00
|
|
|
file_path := "node-disk:/test\0"
|
2024-09-17 09:39:46 -05:00
|
|
|
} else {
|
|
|
|
// error
|
|
|
|
}
|
|
|
|
}
|
2024-09-17 08:01:16 -05:00
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|