diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-08 09:28:31 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-07-08 09:28:31 +0200 |
| commit | 6f454424153fc205e519f7aada62837487600a8e (patch) | |
| tree | 9b7d753b7c87db6a8b81275247a5e31a90e98c5c | |
| parent | 844968b28ffa805bfb5e3ade5b5537d716dca96e (diff) | |
refactor: New Embfs TeX specs, and reworked SNU-LIB's fix module.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | compile_flags.txt | 3 | ||||
| -rw-r--r-- | examples/fix/fix.cc | 6 | ||||
| -rw-r--r-- | lib/embdfs.hpp | 26 | ||||
| -rw-r--r-- | lib/fix/network.hpp | 5 | ||||
| -rw-r--r-- | lib/fix/parser.hpp | 28 | ||||
| -rw-r--r-- | meta/tex/embfs.tex (renamed from meta/tex/embdfs.tex) | 16 |
6 files changed, 45 insertions, 39 deletions
diff --git a/compile_flags.txt b/compile_flags.txt index 9863035..b804da6 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -1,3 +1,4 @@ -I./ -std=c++20 --DEMBDFS_28BIT_LBA
\ No newline at end of file +-DEMBFS_28BIT_LBA +-xc++
\ No newline at end of file diff --git a/examples/fix/fix.cc b/examples/fix/fix.cc index 9b983de..af57ae1 100644 --- a/examples/fix/fix.cc +++ b/examples/fix/fix.cc @@ -10,15 +10,15 @@ /* finally test it */ int main(int argc, char** argv) { - snu::fix::fix_visitor visitor; - auto fix = visitor.visit("8=FIX.4.2|9=65|35=A|49=SERVER|56=CLIENT|34=177|52=20090107-18:15:16|98=0|108=30|10=062|"); + snu::fix::visitor visitor; + snu::fix::range_data fix = visitor.visit("8=FIX.4.2|9=65|35=A|49=SERVER|56=CLIENT|34=177|52=20090107-18:15:16|98=0|108=30|10=062|"); std::cout << "magic: " << fix.msg_magic_ << std::endl; for (auto fields : fix.msg_body_) { std::cout << "key: " << fields.first; - std::cout << ",value: " << fields.second << std::endl; + std::cout << ", value: " << fields.second << std::endl; } return 0; diff --git a/lib/embdfs.hpp b/lib/embdfs.hpp index 9ec82d4..7beb1db 100644 --- a/lib/embdfs.hpp +++ b/lib/embdfs.hpp @@ -5,21 +5,21 @@ * Copyright 2025, Amlal El Mahrouss all rights reserved. */ -#ifndef _SNU_EMBDFS_HPP -#define _SNU_EMBDFS_HPP +#ifndef _SNU_EMBFS_HPP +#define _SNU_EMBFS_HPP #include <cstdint> #include <cstddef> -/// @brief A Filesystem designed for tiny storage medias. +/// @brief A filesystem designed for tiny storage medias. /// @author Amlal EL Mahrouss (founder@snu.systems) -namespace snu::embdfs +namespace snu::embfs { namespace details { - struct embdfs_superblock; - struct embdfs_inode; + struct embfs_superblock; + struct embfs_inode; inline constexpr const size_t _superblock_name_len = 16; inline constexpr const size_t _superblock_reserve_len = 462; @@ -27,9 +27,9 @@ namespace snu::embdfs inline constexpr const size_t _inode_arr_len = 12; inline constexpr const size_t _inode_lookup_len = 8; -#ifdef EMBDFS_28BIT_LBA +#ifdef EMBFS_28BIT_LBA typedef std::uint32_t lba_t; -#elif defined(EMBDFS_48BIT_LBA) +#elif defined(EMBFS_48BIT_LBA) typedef std::uint64_t lba_t; #endif @@ -39,7 +39,7 @@ namespace snu::embdfs typedef std::uint8_t utf8_char_t; /// @brief Superblock data structure - struct embdfs_superblock + struct embfs_superblock { sword_t s_block_mag; sdword_t s_num_inodes; @@ -60,7 +60,7 @@ namespace snu::embdfs /// @brief i_checksum crc32 checksum. /// @brief i_flags_perms flags and permissions /// @brief i_acl_* ACL to keep track of inode allocation status. - struct embdfs_inode + struct embfs_inode { utf8_char_t i_name[_inode_name_len]; sword_t i_size_virt, i_size_phys; @@ -70,8 +70,8 @@ namespace snu::embdfs }; /// @brief Indexed node linear array. - typedef embdfs_inode embdfs_inode_arr_t[_inode_arr_len]; + typedef embfs_inode embfs_inode_arr_t[_inode_arr_len]; } // namespace details -} // namespace snu::embdfs +} // namespace snu::embfs -#endif // ifndef _SNU_EMBDFS_HPP
\ No newline at end of file +#endif // ifndef _SNU_EMBFS_HPP
\ No newline at end of file diff --git a/lib/fix/network.hpp b/lib/fix/network.hpp index 0c167e5..95de49b 100644 --- a/lib/fix/network.hpp +++ b/lib/fix/network.hpp @@ -11,4 +11,9 @@ #include <arpa/inet.h> #include <sys/socket.h> +namespace snu::fix +{ + +} + #endif // ifndef _SNU_FIX_NETWORK_HPP
\ No newline at end of file diff --git a/lib/fix/parser.hpp b/lib/fix/parser.hpp index c20fe2f..edafc5a 100644 --- a/lib/fix/parser.hpp +++ b/lib/fix/parser.hpp @@ -17,21 +17,21 @@ namespace snu::fix { - struct fix_visitor; - struct fix_range; - struct fix_range_data; + struct visitor; + struct range; + struct range_data; /// @brief Buffer+Length structure - typedef fix_range* fix_range_ptr_t; + typedef range* range_ptr_t; - struct fix_range final + struct range final { char* ascii_bytes_; uint16_t length_; }; /// @brief Convert range to usable string. - inline std::string to_string(fix_range& range) noexcept + inline std::string to_string(range& range) noexcept { if (range.length_ < 0) return ""; @@ -39,7 +39,7 @@ namespace snu::fix return std::string(range.ascii_bytes_, range.length_); } - class fix_range_data final + class range_data final { public: std::string msg_magic_; @@ -47,21 +47,21 @@ namespace snu::fix std::vector<std::pair<std::string, std::string>> msg_body_; }; - class fix_visitor final + class visitor final { public: static constexpr auto soh = '|'; static constexpr auto base = 10U; - explicit fix_visitor() = default; - ~fix_visitor() = default; + explicit visitor() = default; + ~visitor() = default; - fix_visitor& operator=(const fix_visitor&) = default; - fix_visitor(const fix_visitor&) = default; + visitor& operator=(const visitor&) = default; + visitor(const visitor&) = default; - fix_range_data visit(const std::string& in) + range_data visit(const std::string& in) { - fix_range_data ret{}; + range_data ret{}; std::string in_tmp; diff --git a/meta/tex/embdfs.tex b/meta/tex/embfs.tex index d6e6e99..e72d4b4 100644 --- a/meta/tex/embdfs.tex +++ b/meta/tex/embfs.tex @@ -37,14 +37,14 @@ The \textbf{Embedded File System (EMBFS)} is a compact and minimal filesystem de \section{Namespace} The EMBFS implementation resides under: \begin{lstlisting} -namespace snu::embdfs +namespace snu::embfs \end{lstlisting} \section{Supported Logical Block Addressing (LBA) Modes} Two LBA addressing modes are supported via macro definitions: \begin{itemize} - \item \texttt{EMBDFS\_28BIT\_LBA} — Uses \texttt{uint32\_t}. - \item \texttt{EMBDFS\_48BIT\_LBA} — Uses \texttt{uint64\_t}. + \item \texttt{EMBFS\_28BIT\_LBA} — Uses \texttt{uint32\_t}. + \item \texttt{EMBFS\_48BIT\_LBA} — Uses \texttt{uint64\_t}. \end{itemize} \section{Fundamental Types} @@ -73,9 +73,9 @@ Two LBA addressing modes are supported via macro definitions: \end{longtable} \section{Superblock Structure} -\textbf{Structure:} \texttt{embdfs\_superblock} +\textbf{Structure:} \texttt{embfs\_superblock} \begin{lstlisting} -struct embdfs_superblock { +struct embfs_superblock { sword_t s_block_mag; sdword_t s_num_inodes; sdword_t s_part_size; @@ -103,9 +103,9 @@ struct embdfs_superblock { \end{itemize} \section{Inode Structure} -\textbf{Structure:} \texttt{embdfs\_inode} +\textbf{Structure:} \texttt{embfs\_inode} \begin{lstlisting} -struct embdfs_inode { +struct embfs_inode { utf8_char_t i_name[128]; sword_t i_size_virt, i_size_phys; lba_t i_offset[8]; @@ -127,7 +127,7 @@ struct embdfs_inode { \section{Inode Array Type} \begin{lstlisting} -typedef embdfs_inode embdfs_inode_arr_t[12]; +typedef embfs_inode embfs_inode_arr_t[12]; \end{lstlisting} Represents a fixed-size array of 12 inodes within a given partition. |
