剖析 linux file system-Ext2
来源:互联网 发布:老虎证券 客户端软件 编辑:程序博客网 时间:2024/05/29 17:05
The ext2 filesystem was developed by Rémy Card and added to Linux in version 0.99pl7 (March 1993). It was a greatly improved version of his earlier ext filesystem (that again was a small improvement on the minix filesystem), and uses ideas from the Berkeley Fast Filesystem. It is really fast and robust. The main reason people want something else nowadays is that on the modern very large disks an invocation of e2fsck (to check filesystem integrity after a crash or power failure, or just after some predetermined number of boots) takes a long time, like one hour.
The structure of ext2 can be read in the kernel source. The data structures are defined in ext2_fs.h,ext2_fs_i.h, ext2_fs_sb.h (in include/linux) and the code is in fs/ext2
The superblock:
struct ext2_super_block { unsigned long s_inodes_count; /* Inodes count */ unsigned long s_blocks_count; /* Blocks count */ unsigned long s_r_blocks_count; /* Reserved blocks count */ unsigned long s_free_blocks_count;/* Free blocks count */ unsigned long s_free_inodes_count;/* Free inodes count */ unsigned long s_first_data_block; /* First Data Block */ unsigned long s_log_block_size; /* log(Block size) - 10 */ long s_log_frag_size; /* Fragment size */ unsigned long s_blocks_per_group; /* # Blocks per group */ unsigned long s_frags_per_group; /* # Fragments per group */ unsigned long s_inodes_per_group; /* # Inodes per group */ unsigned long s_mtime; /* Mount time */ unsigned long s_wtime; /* Write time */ unsigned long s_pad; /* Padding to get the magic signature*/ /* at the same offset as in the */ /* previous ext fs */ unsigned short s_magic; /* Magic signature */ unsigned short s_valid; /* Flag */ unsigned long s_reserved[243]; /* Padding to the end of the block */};
The superblock contains information that is global to the entire filesystem,such as the total numbel of blosks ,and the time of the last mount.Some parameters,such as the number of blocks reserved for the superuser.
The group descriptors:
Then the group descriptors.Each block group has a group descriptor,and all group descriptors for all block groups are repeated in each group.All copies except thr first of superblock and group descriptor are never used or updated.They are just there to help recovering from a crash or power failure.
The size of a block group depends on the chosen block size for the ext2 filesystem.Allowed block size are 1024/2048/4096.The blocks of a block grou are represented by bits in a bitmap that file one block.
struct ext2_group_desc{
unsigned long bg_block_bitmap; /* Blocks bitmap block */ unsigned long bg_inode_bitmap; /* Inodes bitmap block */ unsigned long bg_inode_table; /* Inodes table block */ unsigned short bg_free_blocks_count; /* Free blocks count */ unsigned short bg_free_inodes_count; /* Free inodes count */ unsigned short bg_used_dirs_count; /* Directories count */ unsigned short bg_pad; unsigned long bg_reserved[3];
};
- 剖析 linux file system-Ext2
- EXT2 file system file.c with my comments
- Seq_file File System实例剖析
- Seq_file File System实例剖析
- EXT2 file system dir.c with my comments
- EXT2 file system namei.c with my comments
- EXT2 file system super.c with my comments
- EXT2 file system ioctl.c with my comments
- EXT2 file system ialloc.c with my comments
- EXT2 file system balloc.c with my comments
- EXT2 file system inode.c with my comments
- Linux file system hierarchy
- Linux File System - Basics
- linux file system
- Embedded Linux - File System
- Linux file system superblock
- linux file System directory
- linux file System inode
- DLL版本不兼容问题
- Convert spaces to |s.
- [wtl学习]-[第二天]-关于ATL_NO_VTABLE一些困惑
- How To Get Startup Ideas
- 将Applet嵌入页面并显示
- 剖析 linux file system-Ext2
- 黑马程序员_C#基础知识学习笔记:条件语句
- 10年打工总结了6句话
- 生活在 Emacs 中
- 临界区(Critical section)与互斥体(Mutex)的区别
- 如何让bat批处理完毕后自动关闭窗口
- Android最佳实践之:StrictMode介绍
- [MySQL]如何计算varchar最大长度
- JDOM入门实例:读取与创建xml文档