summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-17 09:19:52 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-17 09:19:52 +0100
commit0d931fe17b32cc5082f1180138dbb7bd6416dd14 (patch)
tree2c5b2f6176423cf53d419fd2e6d5131d2bbb224f /tools
parentbfce4d5673fc469395e0d438daa7f6d839834abc (diff)
tools: feat: new syntax for function.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/chk.hefs.cc (renamed from tools/fsck.hefs.cc)8
-rw-r--r--tools/chk.hefs.json (renamed from tools/fsck.hefs.json)4
-rw-r--r--tools/libmkfs/mkfs.h5
-rw-r--r--tools/mkfs.hefs.cc47
4 files changed, 32 insertions, 32 deletions
diff --git a/tools/fsck.hefs.cc b/tools/chk.hefs.cc
index a2162a4f..121604f1 100644
--- a/tools/fsck.hefs.cc
+++ b/tools/chk.hefs.cc
@@ -14,16 +14,16 @@ static uint16_t kNumericalBase = 10;
int main(int argc, char** argv) {
if (argc < 2) {
- mkfs::console_out() << "fsck: hefs: usage: fsck.hefs -in=<input_device> -org=<origin>"
+ mkfs::console_out() << "fsck: hefs: usage: chk.hefs -in=<input_device> -b=<origin>"
<< "\n";
return EXIT_FAILURE;
}
auto args = mkfs::detail::build_args(argc, argv);
- auto opt_disk = mkfs::get_option<char>(args, "-in");
+ auto opt_disk = mkfs::get_option<char>(args, "in");
- auto origin = mkfs::get_option<char>(args, "-org");
+ auto origin = mkfs::get_option<char>(args, "b");
if (opt_disk.empty()) {
mkfs::console_out() << "fsck: hefs: error: OpenHeFS partition is empty! Exiting..."
@@ -68,7 +68,7 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
- mkfs::console_out() << "hefs: OpenHeFS partition is healthy, exiting...\n";
+ mkfs::console_out() << "hefs: OpenHeFS partition is healthy. Exiting...\n";
output_device.close();
diff --git a/tools/fsck.hefs.json b/tools/chk.hefs.json
index 970665aa..58918613 100644
--- a/tools/fsck.hefs.json
+++ b/tools/chk.hefs.json
@@ -5,9 +5,9 @@
"../"
],
"sources_path": [
- "fsck.hefs.cc"
+ "chk.hefs.cc"
],
- "output_name": "./dist/fsck.hefs",
+ "output_name": "./dist/chk.hefs",
"cpp_macros": [
"kFsckHeFSVersion=0x0100",
"kFsckHeFSVersionHighest=0x0100",
diff --git a/tools/libmkfs/mkfs.h b/tools/libmkfs/mkfs.h
index 6e242293..18ed571b 100644
--- a/tools/libmkfs/mkfs.h
+++ b/tools/libmkfs/mkfs.h
@@ -8,7 +8,6 @@
#include <tools/rang.h>
#include <iostream>
-#include <sstream>
#include <string>
#define kMkFsSectorSz (512U)
@@ -63,10 +62,10 @@ namespace detail {
template <typename CharType>
inline std::basic_string<CharType> get_option(const std::basic_string<CharType>& args,
const std::basic_string<CharType>& option) {
- size_t pos = args.find(option + CharType('='));
+ size_t pos = args.find(CharType('-') + option + CharType('='));
if (pos != std::string::npos) {
- size_t start = pos + option.length() + 1;
+ size_t start = pos + option.length() + 2;
size_t end = args.find(' ', start);
return args.substr(start, end - start);
}
diff --git a/tools/mkfs.hefs.cc b/tools/mkfs.hefs.cc
index d1139e10..77dd1658 100644
--- a/tools/mkfs.hefs.cc
+++ b/tools/mkfs.hefs.cc
@@ -12,12 +12,13 @@
#include <fstream>
#include <limits>
-static size_t kDiskSize = mkfs::detail::gib_cast(4UL);
static uint16_t kVersion = kHeFSVersion;
-static std::u8string kLabel;
-static size_t kSectorSize = 512;
static uint16_t kNumericalBase = 10;
+static size_t kDiskSize = mkfs::detail::gib_cast(4UL);
+static std::u8string kDiskLabel;
+static size_t kDiskSectorSz = 512;
+
int main(int argc, char** argv) {
if (argc < 2) {
mkfs::console_out()
@@ -30,13 +31,13 @@ int main(int argc, char** argv) {
std::string args = mkfs::detail::build_args(argc, argv);
- auto output_path = mkfs::get_option<char>(args, "-o");
+ auto output_path = mkfs::get_option<char>(args, "o");
if (output_path.empty()) {
mkfs::console_out() << "hefs: error: Missing -o <output_device> argument.\n";
return EXIT_FAILURE;
}
- auto opt_s = mkfs::get_option<char>(args, "-s");
+ auto opt_s = mkfs::get_option<char>(args, "s");
long parsed_s = 0;
if (!mkfs::detail::parse_signed(opt_s, parsed_s, kNumericalBase) || parsed_s == 0) {
mkfs::console_out() << "hefs: error: Invalid sector size \"" << opt_s
@@ -49,20 +50,20 @@ int main(int argc, char** argv) {
<< "\" is not a power of two.\n";
return EXIT_FAILURE;
}
- kSectorSize = static_cast<size_t>(parsed_s);
+ kDiskSectorSz = static_cast<size_t>(parsed_s);
- auto opt_L = mkfs::get_option<char>(args, "-L");
+ auto opt_L = mkfs::get_option<char>(args, "L");
if (!opt_L.empty()) {
- kLabel.clear();
- for (char c : opt_L) kLabel.push_back(static_cast<char8_t>(c));
+ kDiskLabel.clear();
+ for (char c : opt_L) kDiskLabel.push_back(static_cast<char8_t>(c));
} else {
- kLabel.clear();
+ kDiskLabel.clear();
for (size_t i = 0; i < kHeFSPartNameLen && kHeFSDefaultVolumeName[i] != u'\0'; ++i) {
- kLabel.push_back(static_cast<char8_t>(kHeFSDefaultVolumeName[i]));
+ kDiskLabel.push_back(static_cast<char8_t>(kHeFSDefaultVolumeName[i]));
}
}
- auto opt_S = mkfs::get_option<char>(args, "-S");
+ auto opt_S = mkfs::get_option<char>(args, "S");
unsigned long long gb = 0;
if (!mkfs::detail::parse_decimal(opt_S, gb) || gb == 0ULL) {
mkfs::console_out() << "hefs: error: Invalid disk size \"" << opt_S
@@ -76,12 +77,12 @@ int main(int argc, char** argv) {
}
kDiskSize = static_cast<size_t>(gb * 1024ULL * 1024ULL * 1024ULL);
- auto opt_b = mkfs::get_option<char>(args, "-b");
- auto opt_e = mkfs::get_option<char>(args, "-e");
- auto opt_bs = mkfs::get_option<char>(args, "-bs");
- auto opt_be = mkfs::get_option<char>(args, "-be");
- auto opt_is = mkfs::get_option<char>(args, "-is");
- auto opt_ie = mkfs::get_option<char>(args, "-ie");
+ auto opt_b = mkfs::get_option<char>(args, "b");
+ auto opt_e = mkfs::get_option<char>(args, "e");
+ auto opt_bs = mkfs::get_option<char>(args, "bs");
+ auto opt_be = mkfs::get_option<char>(args, "be");
+ auto opt_is = mkfs::get_option<char>(args, "is");
+ auto opt_ie = mkfs::get_option<char>(args, "ie");
long start_ind = 0, end_ind = 0;
long start_block = 0, end_block = 0;
@@ -117,7 +118,7 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
- if (static_cast<size_t>(end_block) * kSectorSize > kDiskSize ||
+ if (static_cast<size_t>(end_block) * kDiskSectorSz > kDiskSize ||
static_cast<size_t>(end_ind) > kDiskSize || static_cast<size_t>(end_in) > kDiskSize) {
mkfs::console_out() << "hefs: error: One or more ranges exceed disk size.\n";
return EXIT_FAILURE;
@@ -137,8 +138,8 @@ int main(int argc, char** argv) {
boot_node.diskKind = mkfs::hefs::kHeFSHardDrive;
boot_node.encoding = mkfs::hefs::kHeFSEncodingFlagsUTF8;
boot_node.diskSize = kDiskSize;
- boot_node.sectorSize = kSectorSize;
- boot_node.sectorCount = kDiskSize / kSectorSize;
+ boot_node.sectorSize = kDiskSectorSz;
+ boot_node.sectorCount = kDiskSize / kDiskSectorSz;
boot_node.startIND = static_cast<size_t>(start_ind) + sizeof(mkfs::hefs::BootNode);
boot_node.endIND = static_cast<size_t>(end_ind);
boot_node.startIN = static_cast<size_t>(start_in);
@@ -161,10 +162,10 @@ int main(int argc, char** argv) {
std::memset(boot_node.volumeName, 0, sizeof(boot_node.volumeName));
- size_t label_units = std::min(kLabel.size(), vol_slots - 1);
+ size_t label_units = std::min(kDiskLabel.size(), vol_slots - 1);
for (size_t i = 0; i < label_units; ++i) {
- boot_node.volumeName[i] = static_cast<char8_t>(kLabel[i]);
+ boot_node.volumeName[i] = static_cast<char8_t>(kDiskLabel[i]);
}
boot_node.volumeName[label_units] = 0U;