超级块对象记录已安装文件系统的整体信息,由于具体的文件系统来实现,它对应于具体文件系统的超级块或控制块,存储在磁盘的特定扇区上,如果不是基于磁盘的文件系统,比如sysfs,会生成临时的超级块,保存在内存当中。01struct super_block {02 struct list_head s_list; /* Keep this first */03 dev_t s_dev; /* search index; _not_ kdev_t */04 unsigned long s_blocksize;05 unsigned char s_blocksize_bits;06 unsigned char s_dirt;07 unsigned long long s_maxbytes; /* Max file size */08 struct file_system_type *s_type;09 const struct super_operations *s_op;10 struct dquot_operations *dq_op;11 struct quotactl_ops *s_qcop;12 const struct export_operations *s_export_op;13 unsigned long s_flags;14 unsigned long s_magic;15 struct dentry *s_root;16 struct rw_semaphore s_umount;17 struct mutex s_lock;18 int s_count;19 int s_need_sync_fs;20 atomic_t s_active;21#ifdef CONFIG_SECURITY22 void *s_security;23#endif24 struct xattr_handler **s_xattr;2526 struct list_head s_inodes; /* all inodes */27 struct list_head s_dirty; /* dirty inodes */28 struct list_head s_io; /* parked for writeback */29 struct list_head s_more_io; /* parked for more writeback */30 struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */31 struct list_head s_files;32 /* s_dentry_lru and s_nr_dentry_unused are protected by dcache_lock */33 struct list_head s_dentry_lru; /* unused dentry lru */34 int s_nr_dentry_unused; /* # of dentry on lru */3536 struct block_device *s_bdev;37 struct mtd_info *s_mtd;38 struct list_head s_instances;39 struct quota_info s_dquot; /* Diskquota specific options */4041 int s_frozen;42 wait_queue_head_t s_wait_unfrozen;4344 char s_id[32]; /* Informational name */4546 void *s_fs_info; /* Filesystem private info */47 fmode_t s_mode;48 struct mutex s_vfs_rename_mutex; /* Kludge */4950 /* Granularity of c/m/atime in ns.51 Cannot be worse than a second */52 u32 s_time_gran;5354 char *s_subtype;5556 char *s_options;57 struct list_head s_async_list;58};第2行指向超级块链表的指针第3行设备标识符第4行以字节为单位的块大小第5行以位为单位的块大小第6行修改标志第7行文件的最长长度第8行文件系统类型第9行超级块方法第10行磁盘限额处理方法第11行磁盘限额管理方法第12行网络文件系统使用的输出操作第13行安装标志第14行文件系统的魔数第15行文件系统根目录的目录项对象第16行卸载所用的信号量第17行超级块信息量第18行引用计数器第19行对超级块的已安装文件系统进行同步的标志第20行次级引用计数器第22行指向超级块安全数据结构的指针第24行指向超级块扩展属性结构的指针第26行所有索引节点的链表第27行改进型索引节点的链表第28行等待被写入磁盘的索引节点的链表第30行用于处理远程网络文件系统的匿名目录项的链表第31行文件对象的链表第36行指向块设备驱动程序描述符的指针第38行用于给定文件系统类型的超级块对象链表的指针第39行磁盘限额的描述符第41行冻结文件系统时使用的标志第42行进程挂起的等待队列,直到文件系统被解冻第46行指向特定文件的超级块信息的指针第52行时间戳的粒度超级块的操作方法01struct super_operations {02 struct inode *(*alloc_inode)(struct super_block *sb);03 void (*destroy_inode)(struct inode *);0405 void (*dirty_inode) (struct inode *);06 int (*write_inode) (struct inode *, int);07 void (*drop_inode) (struct inode *);08 void (*delete_inode) (struct inode *);09 void (*put_super) (struct super_block *);10 void (*write_super) (struct super_block *);11 int (*sync_fs)(struct super_block *sb, int wait);12 int (*freeze_fs) (struct super_block *);13 int (*unfreeze_fs) (struct super_block *);14 int (*statfs) (struct dentry *, struct kstatfs *);15 int (*remount_fs) (struct super_block *, int *, char *);16 void (*clear_inode) (struct inode *);17 void (*umount_begin) (struct super_block *);1819 int (*show_options)(struct seq_file *, struct vfsmount *);20 int (*show_stats)(struct seq_file *, struct vfsmount *);21#ifdef CONFIG_QUOTA22 ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t);23 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);24#endif25 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);26};第2行为索引节点对象分配空间,包括具体文件系统的数据所需要的空间。第3行撤消索引节点对象。第5行当索引节点标记为修改(脏)时调用。第6行用通过传递参数指定的索引节点对象的内容更新一个文件系统的索引节点。索引节点对象的i_ino字段标识所涉及磁盘上文件系统的索引节点。flag参数表示I/O操作是否应当同步。第7行撤消索引节点时调用第8行在必须撤消索引节点时调用。删除内存中的VFS索引节点和磁盘上的文件数据及元数据第9行释放通过传递的参数指定的超级块对象第10行用指定对象的内容更新文件系统的超级块第11行在清除文件系统来更新磁盘上的具体文件系统数据时调用。第14行将文件系统的统计信息返回,填写在buf缓存区中。第15行用新选项重新安装文件系统第16行当撤消磁盘索引节点执行具体文件操作时调用。第17行中断一个安装操作第19行用来显示特定文件系统的选项第22行限额系统使用该方法从文件中读取数据。第23行限额系统使用该方法将数据写入文件中索引节点对象存放关于具体文件的一般信息。对基于磁盘的文件系统,通常对应于存放在磁盘上的文件控制块。每个索引节点对象都有一个索引节点号,这个节点号唯一的标识文件系统中的文件。。01struct inode {02 struct hlist_node i_hash;03 struct list_head i_list;04 struct list_head i_sb_list;05 struct list_head i_dentry;06 unsigned long i_ino;07 atomic_t i_count;08 unsigned int i_nlink;09 uid_t i_uid;10 gid_t i_gid;11 dev_t i_rdev;12 u64 i_version;13 loff_t i_size;14#ifdef __NEED_I_SIZE_ORDERED15 seqcount_t i_size_seqcount;16#endif17 struct timespec i_atime;18 struct timespec i_mtime;19 struct timespec i_ctime;20 unsigned int i_blkbits;21 blkcnt_t i_blocks;22 unsigned short i_bytes;23 umode_t i_mode;24 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */25 struct mutex i_mutex;26 struct rw_semaphore i_alloc_sem;27 const struct inode_operations *i_op;28 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */29 struct super_block *i_sb;30 struct file_lock *i_flock;31 struct address_space *i_mapping;32 struct address_space i_data;33#ifdef CONFIG_QUOTA34 struct dquot *i_dquot[MAXQUOTAS];35#endif36 struct list_head i_devices;37 union {38 struct pipe_inode_info *i_pipe;39 struct block_device *i_bdev;40 struct cdev *i_cdev;41 };42 int i_cindex;4344 __u32 i_generation;4546#ifdef CONFIG_DNOTIFY47 unsigned long i_dnotify_mask; /* Directory notify events */48 struct dnotify_struct *i_dnotify; /* for directory notifications */49#endif5051#ifdef CONFIG_INOTIFY52 struct list_head inotify_watches; /* watches on this inode */53 struct mutex inotify_mutex; /* protects the watches list */54#endif5556 unsigned long i_state;57 unsigned long dirtied_when; /* jiffies of first dirtying */5859 unsigned int i_flags;6061 atomic_t i_writecount;62#ifdef CONFIG_SECURITY63 void *i_security;64#endif65 void *i_private; /* fs or device private pointer */66};第2行用于散列链表的指针第3行用于描述索引节点当前状态的链表的指针第4行用于超级块的索引节点链表的指针第5行引用索引节点的目录项对象链表的头第6行索引节点号第7行引用计数器第8行硬链接数目第9行所有者标识符第10行组标识符第11行实设备标识符第13行文件的字节数第17行上次访问文件的时间第18行上次写文件的时间第19行上次修改索引节点的时间第20行块的字节数第21行文件的块数第26行在直接I/O文件操作中避免出现竞争条件的读/写信号量第27行索引节点的操作第28行缺省文件操作第29行指向超级块对象的指针第30行指向文件锁链表的指针第31行指向address_space对象第32行文件的address_space对象第34行索引节点磁盘限额第36行用于具体的字符或块设备索引节点链表的指针第38行管道文件使用第39行指向块设备驱动程序的指针第40行指向字符设备驱动程序的指针第42行拥有一组次设备号的设备文件的索引第44行索引节点版本号第47行目录通知事件的位掩码第48行用于目录通知第56行索引节点的状态标志第57行索引节点的弄脏时间第59行文件系统的安装标志第61行用于写进程的引用计数器第63行指向索引节点安全结构的指针 索引结点的操作方法 01struct inode_operations {02 int (*create) (struct inode *,struct dentry *,int, struct nameidata *);03 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);04 int (*link) (struct dentry *,struct inode *,struct dentry *);05 int (*unlink) (struct inode *,struct dentry *);06 int (*symlink) (struct inode *,struct dentry *,const char *);07 int (*mkdir) (struct inode *,struct dentry *,int);08 int (*rmdir) (struct inode *,struct dentry *);09 int (*mknod) (struct inode *,struct dentry *,int,dev_t);10 int (*rename) (struct inode *, struct dentry *,11 struct inode *, struct dentry *);12 int (*readlink) (struct dentry *, char __user *,int);13 void * (*follow_link) (struct dentry *, struct nameidata *);14 void (*put_link) (struct dentry *, struct nameidata *, void *);15 void (*truncate) (struct inode *);16 int (*permission) (struct inode *, int);17 int (*setattr) (struct dentry *, struct iattr *);18 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);19 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);20 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);21 ssize_t (*listxattr) (struct dentry *, char *, size_t);22 int (*removexattr) (struct dentry *, const char *);23 void (*truncate_range)(struct inode *, loff_t, loff_t);24 long (*fallocate)(struct inode *inode, int mode, loff_t offset,25 loff_t len);26 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,27 u64 len);28};第2行为与目录项对象相关的普通文件创建一个新的磁盘索引节点第3行为包含在一个目录项对象中的文件名对应的索引节点查找目录第4行创建一个新的名为new_dentry的硬链接,它指向dir目录下名为old_dentry的文件。第5行从一个目录中删除目录项对象所指定文件的硬链接第6行在某个目录下,为与目录项对象相关的符号链接创建一个新的索引节点第7行在某个目录下,为与目录项对象相关的目录创建一个新的索引节点第8行从一个目录删除子目录,子目录的名称包含在目录项对象中。第9行在某个目录中,为与目录项对象相关的特定文件创建一个新磁盘索引节点。第10行将old_dir目录下由old_entry标识的文件移动new_dir目录下。第12行将目录项所指定的符号链接中对应的文件路径名拷贝到buffer所指定的用户态内存区第13行解析索引节点对象所指定的符号链接第14行释放由follow_link方法分配的用于解析符号链接的所有临时数据结构第15行修改与索引节点相关的文件长度第16行检查是否允许对索引节点所指的文件进行指定模式的访问。第17行在触及索引节点属性后通知一个”修改事件”第18行由一些文件系统用于读取索引节点属性第19行获取扩展属性名称的整个链表第20行删除索引节点的扩展属性。
PySdm :设置Ubuntu启动挂载硬盘分区Linux 根文件系统的挂载分析相关资讯 Linux知识
- 时光总是太匆匆!Linux已经诞生23 (08/29/2014 14:12:03)
- Linux虚拟文件系统之文件打开(sys (02/14/2012 11:41:54)
- 2012 年 Linux 峰会时间表 (02/14/2012 06:47:27)
| - 报告称当前 Linux 人才抢手 高薪也 (02/15/2012 06:35:56)
- 解析企业为何选择Linux及其特别之 (02/14/2012 08:17:59)
- Linux禁用字符闪烁的方法 (11/02/2011 10:28:25)
|
本文评论 查看全部评论 (0)