·看文件系统源代码的理由
LINUX文件系统的代码从艺术的角度来说,就是人类追求完美的及至体现。结构层次
上更能展现软件的本质,接口的定义上,看的出无数的杰出程序人曾经的努力与贡
献。代码的风格更是我一直无比欣赏理由。
而文件系统更是LINUX这个艺术品值得研究与思考的地方。
·前提以及定位:
代码部分只包含,具体文件系统的部分,如ramfs。
对上不求深与细,对下力求精。既不苛求VFS具体实现。
·目的:
·查找出到底文件系统都做什么基本的贡献。
·应该知道:
LINUX维护一个文件系统类型的集合到底为了什么?
最根本的目的,就是找到一个对应的inode处理函数,来处理不同物理介质上存在的
不同文件系统类型中的各种文件。
涉及的数据结构:
####一个文件系统类型的数据结构表示
struct file_system_type {
const char *name;
int fs_flags;
struct super_block *(*get_sb) (struct file_system_type *, int,
const char *, void *);
void (*kill_sb) (struct super_block *);
struct module *owner;
struct file_system_type * next;
struct list_head fs_supers;
};
####集合了一个具体文件系统管理信息的结构
struct super_block {
struct list_head s_list; /* Keep this first */
dev_t s_dev; /* search index; _not_ kdev_t */
unsigned long s_blocksize;
unsigned long s_old_blocksize;
unsigned char s_blocksize_bits;
unsigned char s_dirt;
unsigned long long s_maxbytes; /* Max file size */
struct file_system_type *s_type;
struct super_operations *s_op;
struct dquot_operations *dq_op;
struct quotactl_ops *s_qcop;
struct export_operations *s_export_op;
unsigned long s_flags;
unsigned long s_magic;
struct dentry *s_root;
struct rw_semaphore s_umount;
struct semaphore s_lock;
int s_count;
int s_syncing;
int s_need_sync_fs;
atomic_t s_active;
void *s_security;
struct xattr_handler **s_xattr;
struct list_head s_inodes; /* all inodes */
struct list_head s_dirty; /* dirty inodes */
struct list_head s_io; /* parked for writeback */
struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */
struct list_head s_files;
struct block_device *s_bdev;
struct list_head s_instances;
struct quota_info s_dquot; /* Diskquota specific options */
int s_frozen;
wait_queue_head_t s_wait_unfrozen;
char s_id[32]; /* Informational name */
void *s_fs_info; /* Filesystem private info */
/*
* The next field is for VFS *only*. No filesystems have any business
* even looking at it. You had been warned.
*/
struct semaphore s_vfs_rename_sem; /* Kludge */
/* Granuality of c/m/atime in ns.
Cannot be worse than a second */
u32 s_time_gran;
};
阅读(1808) | 评论(0) | 转发(0) |