summaryrefslogtreecommitdiffhomepage
path: root/docs/tex/hefs.tex
blob: 75f98bccb5a987402cf5512bf4a1891ce61ed76b (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
\documentclass{article}
\usepackage[a4paper, margin=1in]{geometry}
\usepackage{amsmath, amssymb}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{caption}
\usepackage{longtable}

\definecolor{lightgray}{gray}{0.95}

\lstdefinestyle{cstyle}{
  language=C++,
  backgroundcolor=\color{lightgray},
  basicstyle=\ttfamily\small,
  keywordstyle=\color{blue},
  commentstyle=\color{green!60!black},
  stringstyle=\color{orange},
  numbers=left,
  numberstyle=\tiny,
  breaklines=true,
  frame=single,
  showstringspaces=false
}

\title{HeFS (High-Throughput Extended File System) Specification}
\author{Amlal El Mahrouss}
\date{2024--2025}

\begin{document}

\maketitle

\section{Overview}
HeFS is a custom filesystem developed as part of the NeKernel project. It offers a journaling-like inode tree structure using red-black tree-inspired navigation for directories. Designed for robust use in desktop, server, and embedded environments, it supports various encoding modes and drive types.

\section{Boot Node Structure}
\begin{longtable}{|l|l|p{8cm}|}
\hline
\textbf{Field} & \textbf{Type} & \textbf{Description} \\
\hline
\verb|fMagic| & \verb|char[8]| & Filesystem magic ("  HeFS") \\
\verb|fVolName| & \verb|Utf16Char[128]| & Volume name \\
\verb|fVersion| & \verb|UInt32| & Filesystem version (e.g., 0x0101) \\
\verb|fBadSectors| & \verb|UInt64| & Number of bad sectors detected \\
\verb|fSectorCount| & \verb|UInt64| & Total sector count \\
\verb|fSectorSize| & \verb|UInt64| & Size of each sector \\
\verb|fChecksum| & \verb|UInt32| & CRC32 checksum of the boot node \\
\verb|fDiskKind| & \verb|UInt8| & Type of drive (e.g., HDD, SSD, USB) \\
\verb|fEncoding| & \verb|UInt8| & Encoding mode (UTF-8, UTF-16, etc.) \\
\verb|fStartIND| & \verb|UInt64| & Starting LBA of inode tree \\
\verb|fEndIND| & \verb|UInt64| & Ending LBA of inode tree \\
\verb|fINDCount| & \verb|UInt64| & Number of directory nodes allocated \\
\verb|fDiskSize| & \verb|UInt64| & Logical size of the disk \\
\verb|fDiskStatus| & \verb|UInt16| & Status of the disk (e.g., unlocked, locked) \\
\verb|fDiskFlags| & \verb|UInt16| & Disk flags (e.g., read-only) \\
\verb|fVID| & \verb|UInt16| & Virtual ID (EPM integration) \\
\hline
\end{longtable}

\section{File Types and Flags}
\subsection*{File Kinds}
\begin{itemize}[label=--]
    \item \verb|0x00| --- Regular File
    \item \verb|0x01| --- Directory
    \item \verb|0x02| --- Block Device
    \item \verb|0x03| --- Character Device
    \item \verb|0x04| --- FIFO
    \item \verb|0x05| --- Socket
    \item \verb|0x06| --- Symbolic Link
    \item \verb|0x07| --- Unknown
\end{itemize}

\subsection*{Drive Types}
\begin{itemize}[label=--]
    \item \verb|0xC0| --- Hard Drive
    \item \verb|0xC1| --- Solid State Drive
    \item \verb|0x0C| --- Optical Drive
    \item \verb|0xCC| --- USB Mass Storage
    \item \verb|0xC4| --- SCSI/SAS Drive
    \item \verb|0xC6| --- Flash Drive
\end{itemize}

\section{Index Node Structure}
Files are stored through block links, offering native recovery fields and MIME type support.

\begin{lstlisting}[style=cstyle, caption={HEFS\_INDEX\_NODE structure}]
struct HEFS_INDEX_NODE {
    Utf16Char fName[256];
    UInt32    fFlags;
    UInt16    fKind;
    UInt32    fSize;
    UInt32    fChecksum, fRecoverChecksum, fBlockChecksum, fLinkChecksum;
    Utf16Char fMime[256];
    Boolean   fSymLink;
    ATime     fCreated, fAccessed, fModified, fDeleted;
    UInt32    fUID, fGID;
    UInt32    fMode;
    UInt64    fBlockLinkStart[16], fBlockLinkEnd[16];
    UInt64    fBlockStart[16], fBlockEnd[16];
    UInt64    fBlockRecoveryStart[16], fBlockRecoveryEnd[16];
};
\end{lstlisting}

\section{Directory Node Structure}
Directories are organized into a red-black tree for efficient balancing.

\begin{lstlisting}[style=cstyle, caption={HEFS\_INDEX\_NODE\_DIRECTORY structure}]
struct HEFS_INDEX_NODE_DIRECTORY {
    Utf16Char fName[256];
    UInt32    fFlags;
    UInt16    fKind;
    UInt32    fEntryCount;
    UInt32    fChecksum, fIndexNodeChecksum;
    Utf16Char fDim[256];
    ATime     fCreated, fAccessed, fModified, fDeleted;
    UInt32    fUID, fGID;
    UInt32    fMode;
    UInt64    fIndexNodeStart[16], fIndexNodeEnd[16];
    UInt8     fColor;
    Lba       fNext, fPrev, fChild, fParent;
};
\end{lstlisting}

\section{Filesystem Design}

HeFS is designed with the following objectives:
\begin{itemize}
    \item Red-black tree navigation for efficient directory balancing
    \item Journaling fields for block-level recovery
    \item Multi-encoding support: UTF-8, UTF-16, UTF-32
    \item Advanced MIME type support
    \item Redundant fields (checksums, recovery inodes) for crash resistance
    \item Extensible for future LVM (Logical Volume Management) and network filesystem support
\end{itemize}

\section{Minimum Requirements}

HeFS expects a minimum disk size of 4GB. Optimal performance is achieved with 8GB or more.
Supports: HDDs, SSDs, USB mass storage, SCSI/SAS, optical drives.

\section{Future Work}
Planned enhancements include:
\begin{itemize}
    \item Full journaling implementation (recovery on crash)
    \item Advanced ACLs (Access Control Lists) and permissions
    \item Logical Volume Management (LVM) integration
    \item Backup Superblock and dual-boot sectors
    \item Online filesystem checking and self-healing algorithms
\end{itemize}

\end{document}