diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-08 09:35:45 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-08 09:36:50 +0200 |
| commit | 3616886fed21351949865ba0f57011624a172e74 (patch) | |
| tree | 3ff4f3f64c1fa6bc08d2111ca66056e1f7877db8 /tooling | |
| parent | f6a7873714c73b8f3d3190669f8a3181d6679b9d (diff) | |
feat: Reinforce code inside PEFCodeMgr and mkfs.hefs, extend fsck.hefs
and libmkfs.
fix: Fix UserMgr FNV hashing.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'tooling')
| -rw-r--r-- | tooling/fsck.hefs.cc | 10 | ||||
| -rw-r--r-- | tooling/libmkfs/mkfs.h | 3 | ||||
| -rw-r--r-- | tooling/mkfs.hefs.cc | 8 |
3 files changed, 17 insertions, 4 deletions
diff --git a/tooling/fsck.hefs.cc b/tooling/fsck.hefs.cc index 0fa697be..950a709b 100644 --- a/tooling/fsck.hefs.cc +++ b/tooling/fsck.hefs.cc @@ -34,14 +34,20 @@ int main(int argc, char** argv) { } mkfs::hefs::BootNode boot_node; + std::memset(&boot_node, 0, sizeof(boot_node)); - if (strncmp(boot_node.magic, kHeFSMagic, kHeFSMagicLen) != 0) { + if (strncmp(boot_node.magic, kHeFSMagic, kHeFSMagicLen) != 0 || boot_node.sectorCount < 1 || + boot_node.sectorSize < kMkFsSectorSz) { mkfs::console_out() << "hefs: error: Device is not an HeFS disk: " << opt_disk << "\n"; return EXIT_FAILURE; } - mkfs::console_out() << "hefs: HeFS partition is is healthy, exiting...\r"; + if (boot_node.badSectors >= kMkFsMaxBadSectors) { + mkfs::console_out() << "hefs: error: HeFS disk has too much bad sectors: " << opt_disk << "\n"; + return EXIT_FAILURE; + } + mkfs::console_out() << "hefs: HeFS partition is is healthy, exiting...\r"; return EXIT_SUCCESS; }
\ No newline at end of file diff --git a/tooling/libmkfs/mkfs.h b/tooling/libmkfs/mkfs.h index d954624c..d87060da 100644 --- a/tooling/libmkfs/mkfs.h +++ b/tooling/libmkfs/mkfs.h @@ -10,6 +10,9 @@ #include <iostream> #include <string> +#define kMkFsSectorSz (512U) +#define kMkFsMaxBadSectors (128U) + /// @internal namespace mkfs { diff --git a/tooling/mkfs.hefs.cc b/tooling/mkfs.hefs.cc index c1cf9bca..3c2727fd 100644 --- a/tooling/mkfs.hefs.cc +++ b/tooling/mkfs.hefs.cc @@ -150,12 +150,16 @@ int main(int argc, char** argv) { boot_node.magic[magic_copy] = 0; constexpr size_t vol_slots = kHeFSPartNameLen; + std::memset(boot_node.volumeName, 0, sizeof(boot_node.volumeName)); + size_t label_units = std::min(kLabel.size(), vol_slots - 1); + for (size_t i = 0; i < label_units; ++i) { - boot_node.volumeName[i] = static_cast<char16_t>(kLabel[i]); + boot_node.volumeName[i] = static_cast<char8_t>(kLabel[i]); } - boot_node.volumeName[label_units] = 0; + + boot_node.volumeName[label_units] = 0U; output_device.seekp(static_cast<std::streamoff>(start_ind)); if (!output_device.good()) { |
