summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-04-18 12:35:28 +0200
committerAmlal El Mahrouss <amlal@nekernel.org>2025-04-18 12:35:28 +0200
commit0a595d68cd69c365da98c58babf2217bd501615d (patch)
tree7f90867d52f4cb511602e40a4661d930dc126a48
parentb18a1dac7d4bfb2fa335fc4c7f49d14e9a25bc06 (diff)
kernel, HeFS (IMP): time algorithm.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
-rw-r--r--dev/kernel/FSKit/HeFS.h71
1 files changed, 66 insertions, 5 deletions
diff --git a/dev/kernel/FSKit/HeFS.h b/dev/kernel/FSKit/HeFS.h
index 6e529ce4..8fdf933e 100644
--- a/dev/kernel/FSKit/HeFS.h
+++ b/dev/kernel/FSKit/HeFS.h
@@ -77,7 +77,7 @@ inline constexpr UInt16 kHeFSFileKindCount = 0x08;
/// @brief HeFS blocks are array containing sparse blocks of data.
/// @details The blocks are used to store the data of a file. Each block is a pointer to a block of data on the disk.
-inline constexpr UInt16 kHeFSBlockCount = 0x06;
+inline constexpr UInt16 kHeFSBlockCount = 0x10;
struct PACKED HeFS_BOOT_NODE final
{
@@ -103,9 +103,13 @@ struct PACKED HeFS_BOOT_NODE final
/// @details Used to keep track of the INode, INodeDir allocation status.
typedef Kernel::UInt64 ATime;
-inline constexpr ATime kHeFSTimeInvalid = 0x0000000000000000;
-inline constexpr ATime kHeFSTimeMax = 0xFFFFFFFFFFFFFFFF;
+inline constexpr ATime kHeFSTimeInvalid = 0x0000000000000000;
+inline constexpr ATime kHeFSTimeMax = 0xFFFFFFFFFFFFFFFF;
+/// @brief HeFS index node.
+/// @details This structure is used to store the file information of a file.
+/// @note The index node is a special type of INode that contains the file information.
+/// @note The index node is used to store the file information of a file.
struct PACKED HeFS_INDEX_NODE final
{
Kernel::Utf16Char fName[kHeFSFileNameLen];
@@ -126,11 +130,14 @@ struct PACKED HeFS_INDEX_NODE final
Kernel::UInt64 fBlockRecoveryStart[kHeFSBlockCount];
Kernel::UInt64 fBlockRecoveryEnd[kHeFSBlockCount];
-
+
/// @brief Red-black tree pointers.
Kernel::Lba fNext, fPrev, fChild, fParent;
};
+/// @brief HeFS directory node.
+/// @details This structure is used to store the directory information of a file.
+/// @note The directory node is a special type of INode that contains the directory entries.
struct PACKED HeFS_INDEX_NODE_DIRECTORY final
{
Kernel::Utf16Char fName[kHeFSFileNameLen];
@@ -149,4 +156,58 @@ struct PACKED HeFS_INDEX_NODE_DIRECTORY final
/// @brief Red-black tree pointers.
Kernel::Lba fNext, fPrev, fChild, fParent;
-}; \ No newline at end of file
+};
+
+namespace Kernel::Detail
+{
+ /// @brief HeFS get year from ATime.
+ /// @param raw_atime the raw ATime value.
+ /// @return the year value.
+ /// @note The year is stored in the upper 32 bits of the ATime value.
+ inline UInt32 hefs_year_get(ATime raw_atime) noexcept
+ {
+ return (raw_atime & 0x00000000FFFFFFFF) >> 32;
+ }
+
+ /// @brief HeFS get month from ATime.
+ /// @param raw_atime the raw ATime value.
+ /// @return the month value.
+ /// @note The month is stored in the upper 24 bits of the ATime value.
+ inline UInt32 hefs_month_get(ATime raw_atime) noexcept
+ {
+ return (raw_atime & 0x00000000FFFFFFFF) >> 24;
+ }
+
+ /// @brief HeFS get day from ATime.
+ /// @param raw_atime the raw ATime value.
+ /// @return the day value.
+ /// @note The day is stored in the upper 16 bits of the ATime value.
+ inline UInt32 hefs_day_get(ATime raw_atime) noexcept
+ {
+ return (raw_atime & 0x00000000FFFFFFFF) >> 16;
+ }
+
+ /// @brief HeFS get hour from ATime.
+ /// @param raw_atime the raw ATime value.
+ /// @return the hour value.
+ /// @note The hour is stored in the upper 8 bits of the ATime value.
+ inline UInt32 hefs_hour_get(ATime raw_atime) noexcept
+ {
+ return (raw_atime & 0x00000000FFFFFFFF) >> 8;
+ }
+
+ /// @brief HeFS get minute from ATime.
+ /// @param raw_atime the raw ATime value.
+ /// @return the minute value.
+ /// @note The minute is stored in the lower 8 bits of the ATime value.
+ inline UInt32 hefs_minute_get(ATime raw_atime) noexcept
+ {
+ return (raw_atime & 0x00000000FFFFFFFF);
+ }
+
+ inline constexpr UInt32 kHeFSBaseYear = 1970;
+ inline constexpr UInt32 kHeFSBaseMonth = 1;
+ inline constexpr UInt32 kHeFSBaseDay = 1;
+ inline constexpr UInt32 kHeFSBaseHour = 0;
+ inline constexpr UInt32 kHeFSBaseMinute = 0;
+} // namespace Kernel::Detail \ No newline at end of file