diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-04 15:43:44 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-04 15:43:44 +0200 |
| commit | 32edc6508c91e51316d67b92eb86b4e72d0a41a4 (patch) | |
| tree | dfdd7eda6c5d88ca9b9b0a4a34beb8d9962409bb /tooling/fsck.hefs.cc | |
| parent | 13e1137757626d274e7754d54e7db828da1e7fa8 (diff) | |
feat: libmkfs: a new library to format filesystem and utilities for
them.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'tooling/fsck.hefs.cc')
| -rw-r--r-- | tooling/fsck.hefs.cc | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/tooling/fsck.hefs.cc b/tooling/fsck.hefs.cc index 37dfbdd7..ce386152 100644 --- a/tooling/fsck.hefs.cc +++ b/tooling/fsck.hefs.cc @@ -4,18 +4,40 @@ ------------------------------------------- */ -#include <tooling/hefs.h> -#include <tooling/mkfs.h> +#include <tooling/libmkfs/hefs.h> +#include <tooling/libmkfs/mkfs.h> #include <cstdlib> +#include <fstream> int main(int argc, char** argv) { if (argc < 2) { - mkfs::console_out() << "fsck: hefs: usage: fsck.hefs i <input_device>" + mkfs::console_out() << "fsck: hefs: usage: fsck.hefs -i=<input_device>" << "\n"; return EXIT_FAILURE; } - (void) (argv); + auto args = mkfs::detail::build_args(argc, argv); + + auto opt_disk = mkfs::get_option<char>(args, "-i"); + + if (opt_disk.empty()) { + mkfs::console_out() << "fsck: hefs: error: HeFS is empty! Exiting..." + << "\n"; + return EXIT_FAILURE; + } + + + std::ifstream output_device(opt_disk, std::ios::binary); + + if (!output_device.good()) { + mkfs::console_out() << "hefs: error: Unable to open output device: " << opt_disk << "\n"; + return EXIT_FAILURE; + } + + mkfs::hefs::BootNode boot_node; + std::memset(&boot_node, 0, sizeof(boot_node)); + + mkfs::console_out() << "hefs: HeFS partition is is healthy, exiting...\r"; return EXIT_SUCCESS; }
\ No newline at end of file |
