国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

Linux中的EXT系列文件系統格式詳解

2024-08-28 00:04:44
字體:
來源:轉載
供稿:網友

Linux文件系統

常見的硬盤如上圖所示,每個盤片分多個磁道,每個磁道分多個扇區,每個扇區512字節,是硬盤的最小存儲單元,但是在操作系統層面會將多個扇區組成塊(block),是操作系統存儲數據的最小單元,通常是8個扇區組成4K字節的塊。
對于Linux文件系統,需要考慮以下幾點:

文件系統需要有嚴格的組織形式,使文件能夠以塊為單位存儲 文件系統需要有索引區,方便查找一個文件分成的多個塊存在了什么位置 如果有文件近期經常被讀寫,需要有緩存層 文件應該用文件夾的形式組織起來方便管理和查詢 Linux內核要在自己的內存里維護一套數據結構,保持哪些文件被哪些進程打開和使用

Linux里面一切皆文件,都有以下幾種文件(從ls -l結果的第一位標識位可以看出來):

- 表示普通文件 d 表示文件夾 c 表示字符設備文件 b 表示塊設備文件 s 表示套接字socket文件 l 表示軟鏈接

Inode和塊存儲

下面就以EXT系列格式為例來看一下文件是如果存在硬盤上的。首先文件會被分成一個個的塊,分散得存在硬盤上,就需要一個索引結構來幫助我們找到這些塊以及記錄文件的一些元信息,這就是inode,其中i代表index。inode數據結構如下:

struct ext4_inode { __le16 i_mode;  /* File mode */ __le16 i_uid;  /* Low 16 bits of Owner Uid */ __le32 i_size_lo; /* Size in bytes */ __le32 i_atime; /* Access time */ __le32 i_ctime; /* Inode Change time */ __le32 i_mtime; /* Modification time */ __le32 i_dtime; /* Deletion Time */ __le16 i_gid;  /* Low 16 bits of Group Id */ __le16 i_links_count; /* Links count */ __le32 i_blocks_lo; /* Blocks count */ __le32 i_flags; /* File flags */ union {  struct {   __le32 l_i_version;  } linux1;  struct {   __u32 h_i_translator;  } hurd1;  struct {   __u32 m_i_reserved1;  } masix1; } osd1;    /* OS dependent 1 */ __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */ __le32 i_generation; /* File version (for NFS) */ __le32 i_file_acl_lo; /* File ACL */ __le32 i_size_high; __le32 i_obso_faddr; /* Obsoleted fragment address */ union {  struct {   __le16 l_i_blocks_high; /* were l_i_reserved1 */   __le16 l_i_file_acl_high;   __le16 l_i_uid_high; /* these 2 fields */   __le16 l_i_gid_high; /* were reserved2[0] */   __le16 l_i_checksum_lo;/* crc32c(uuid+inum+inode) LE */   __le16 l_i_reserved;  } linux2;  struct {   __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */   __u16 h_i_mode_high;   __u16 h_i_uid_high;   __u16 h_i_gid_high;   __u32 h_i_author;  } hurd2;  struct {   __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */   __le16 m_i_file_acl_high;   __u32 m_i_reserved2[2];  } masix2; } osd2;    /* OS dependent 2 */ __le16 i_extra_isize; __le16 i_checksum_hi; /* crc32c(uuid+inum+inode) BE */ __le32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */ __le32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */ __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */ __le32 i_crtime; /* File Creation time */ __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */ __le32 i_version_hi; /* high 32 bits for 64-bit version */ __le32 i_projid; /* Project ID */};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 金平| 烟台市| 衡东县| 周至县| 垣曲县| 湘乡市| 工布江达县| 湟源县| 任丘市| 益阳市| 封丘县| 张家港市| 修武县| 卢龙县| 太白县| 兴业县| 潜江市| 双牌县| 湘潭市| 萝北县| 皋兰县| 麻城市| 西贡区| 安徽省| 中阳县| 耒阳市| 阆中市| 海兴县| 麦盖提县| 高淳县| 佳木斯市| 鄂州市| 昭平县| 荥阳市| 郎溪县| 正阳县| 历史| 右玉县| 安化县| 浠水县| 郸城县|