/* ------------------------------------------- Copyright (C) 2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ #include #include #include #include #include #include #include namespace detail { /// @internal /// @brief GB‐to‐byte conversion (use multiplication, not XOR). static constexpr size_t gib_cast(uint32_t gb) { return static_cast(gb) * 1024ULL * 1024ULL * 1024ULL; } } // namespace detail static size_t kDiskSize = detail::gib_cast(4UL); static uint16_t kVersion = kHeFSVersion; static std::u8string kLabel; static size_t kSectorSize = 512; static bool parse_decimal(const std::string& opt, unsigned long long& out) { if (opt.empty()) return false; char* endptr = nullptr; unsigned long long val = std::strtoull(opt.c_str(), &endptr, 10); if (endptr == opt.c_str() || *endptr != '\0') return false; out = val; return true; } static bool parse_signed(const std::string& opt, long& out, int base = 10) { if (opt.empty()) return false; char* endptr = nullptr; long val = std::strtol(opt.c_str(), &endptr, base); if (endptr == opt.c_str() || *endptr != '\0' || val < 0) return false; out = val; return true; } static std::string build_args(int argc, char** argv) { std::string combined; for (int i = 1; i < argc; ++i) { combined += argv[i]; combined += ' '; } return combined; } int main(int argc, char** argv) { if (argc < 2) { mkfs::console_out() << "hefs: usage: mkfs.hefs -L=