1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# `mkfs.hefs` – HeFS Filesystem Formatter
`mkfs.hefs` is a command-line utility used to format a block device or disk image with the **High-throughput Extended File System (HeFS)** used by NeKernel. This tool initializes a HeFS volume by writing a boot node and configuring directory and inode index regions, block ranges, and volume metadata.
---
## 🛠 Features
- Writes a valid `BootNode` to the specified output device or file.
- Sets disk size, sector size, and volume label.
- Supports user-defined ranges for:
- Index Node Directory (IND)
- Inodes (IN)
- Data blocks
- UTF-8 encoded volume label support.
- Fully compatible with NeKernel's VFS subsystem.
---
## 🧪 Usage
mkfs.hefs -L <label> -s <sector_size> \
-b <ind_start> -e <ind_end> \
-bs <block_start> -be <block_end> \
-is <in_start> -ie <in_end> \
-S <disk_size> -o <output_device>
---
## 🧾 Arguments
| Option | Description |
|---------------|-------------------------------------------------------------------------|
| `-L` | Volume label (UTF-8, internally stored as UTF-16) |
| `-s` | Sector size (e.g., 512) |
| `-b` `-e` | Start and end addresses for the **Index Node Directory (IND)** region |
| `-bs` `-be` | Start and end addresses for the **Block** data region |
| `-is` `-ie` | Start and end addresses for the **Inode** region |
| `-S` | Disk size in **gigabytes** |
| `-o` | Path to the output device or image file |
> All address-based inputs (`-b`, `-e`, etc.) must be specified in **hexadecimal** format.
---
## 🧷 Notes
- Default sector size is `512` bytes.
- Default volume name is `"HeFS_VOLUME"`, defined as `kHeFSDefaultVolumeName`.
- The tool writes a `BootNode` at the beginning of the index node range.
- A CRC-safe magic signature is embedded for boot and integrity validation.
- After writing the metadata, the tool flushes and closes the file stream.
---
## 💻 Example
mkfs.hefs -L "MyHeFS" -s 512 \
-b 0x1000 -e 0x8000 \
-bs 0x8000 -be 0x800000 \
-is 0x800000 -ie 0xA00000 \
-S 128 -o hefs.img
This will create a 128 GiB formatted HeFS image named `hefs.img` with specified region boundaries.
---
## 📁 BootNode Structure
The `BootNode` stores key filesystem metadata:
struct BootNode {
char magic[8];
char16_t volumeName[64];
uint16_t version;
uint16_t diskKind;
uint16_t encoding;
uint64_t diskSize;
uint32_t sectorSize;
uint64_t startIND, endIND;
uint64_t startIN, endIN;
uint64_t startBlock, endBlock;
uint64_t indCount;
uint16_t diskStatus;
};
---
## ⚠️ Error Handling
- Prints usage and exits on invalid/missing arguments.
- Exits with error if the output device cannot be opened or written to.
- Checks for zero sector size or disk size to prevent invalid formatting.
---
## 📚 Source Location
Part of the [HeFS Tooling module](https://github.com/nekernel-org/nekernel) and used during system setup or disk preparation for NeKernel.
---
## © License
Copyright (C) 2025,
Amlal El Mahrouss – All rights reserved.
|