From 666ba3b970da8a23e96d76310cfb52f3fe8f8f2e Mon Sep 17 00:00:00 2001 From: implicitfield <114500360+implicitfield@users.noreply.github.com> Date: Mon, 2 Dec 2024 00:19:50 +0200 Subject: [PATCH] Kernel/Ext2FS: Make to_ext2_file_type a static member of Ext2FSInode --- Kernel/FileSystem/Ext2FS/Inode.cpp | 16 ++++++++-------- Kernel/FileSystem/Ext2FS/Inode.h | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Kernel/FileSystem/Ext2FS/Inode.cpp b/Kernel/FileSystem/Ext2FS/Inode.cpp index ea24815fafc..3d408b0ff0b 100644 --- a/Kernel/FileSystem/Ext2FS/Inode.cpp +++ b/Kernel/FileSystem/Ext2FS/Inode.cpp @@ -19,21 +19,21 @@ namespace Kernel { static constexpr size_t max_inline_symlink_length = 60; -static u8 to_ext2_file_type(mode_t mode) +u8 Ext2FSInode::to_ext2_file_type(mode_t mode) { - if (is_regular_file(mode)) + if (Kernel::is_regular_file(mode)) return EXT2_FT_REG_FILE; - if (is_directory(mode)) + if (Kernel::is_directory(mode)) return EXT2_FT_DIR; - if (is_character_device(mode)) + if (Kernel::is_character_device(mode)) return EXT2_FT_CHRDEV; - if (is_block_device(mode)) + if (Kernel::is_block_device(mode)) return EXT2_FT_BLKDEV; - if (is_fifo(mode)) + if (Kernel::is_fifo(mode)) return EXT2_FT_FIFO; - if (is_socket(mode)) + if (Kernel::is_socket(mode)) return EXT2_FT_SOCK; - if (is_symlink(mode)) + if (Kernel::is_symlink(mode)) return EXT2_FT_SYMLINK; return EXT2_FT_UNKNOWN; } diff --git a/Kernel/FileSystem/Ext2FS/Inode.h b/Kernel/FileSystem/Ext2FS/Inode.h index 602ddb0ed9e..4a43ee77464 100644 --- a/Kernel/FileSystem/Ext2FS/Inode.h +++ b/Kernel/FileSystem/Ext2FS/Inode.h @@ -49,6 +49,8 @@ private: bool is_within_inode_bounds(FlatPtr base, FlatPtr value_offset, size_t value_size) const; + static u8 to_ext2_file_type(mode_t mode); + static time_t decode_seconds_with_extra(i32 seconds, u32 extra) { return (extra & EXT4_EPOCH_MASK) ? static_cast(seconds) + (static_cast(extra & EXT4_EPOCH_MASK) << 32) : static_cast(seconds); } static u32 decode_nanoseconds_from_extra(u32 extra) { return (extra & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS; } static u32 encode_time_to_extra(time_t seconds, u32 nanoseconds) { return (((static_cast(seconds) - static_cast(seconds)) >> 32) & EXT4_EPOCH_MASK) | (nanoseconds << EXT4_EPOCH_BITS); }