linux虚拟文件系统四大对象:

1)超级块(super block)

2)索引节点(inode)

3)目录项(dentry)

4)文件对象(file)

现在先介绍第一个

一、super_block的含义:

超级块代表了整个文件系统,超级块是文件系统的控制块,有整个文件系统信息,一个文件系统所有的inode都要连接到超级块上,可以说,一个超级块就代表了一个文件系统。

说到inode是啥?参照下一篇博客;

 struct super_block {
struct list_head s_list; /* Keep this first */
dev_t s_dev; /* search index; _not_ kdev_t */
unsigned char s_dirt;
unsigned char s_blocksize_bits;
unsigned long s_blocksize;
loff_t s_maxbytes; /* Max file size */
struct file_system_type *s_type;
const struct super_operations *s_op;
const struct dquot_operations *dq_op;
const struct quotactl_ops *s_qcop;
const struct export_operations *s_export_op;
unsigned long s_flags;
unsigned long s_magic;
struct dentry *s_root;
struct rw_semaphore s_umount;
struct mutex s_lock;
int s_count;
atomic_t s_active;
#ifdef CONFIG_SECURITY
void *s_security;
#endif
const struct xattr_handler **s_xattr; struct list_head s_inodes; /* all inodes */
struct hlist_bl_head s_anon; /* anonymous dentries for (nfs) exporting */
#ifdef CONFIG_SMP
struct list_head __percpu *s_files;
#else
struct list_head s_files;
#endif
struct list_head s_mounts; /* list of mounts; _not_ for fs use */
/* s_dentry_lru, s_nr_dentry_unused protected by dcache.c lru locks */
struct list_head s_dentry_lru; /* unused dentry lru */
int s_nr_dentry_unused; /* # of dentry on lru */ /* s_inode_lru_lock protects s_inode_lru and s_nr_inodes_unused */
spinlock_t s_inode_lru_lock ____cacheline_aligned_in_smp;
struct list_head s_inode_lru; /* unused inode lru */
int s_nr_inodes_unused; /* # of inodes on lru */ struct block_device *s_bdev;
struct backing_dev_info *s_bdi;
struct mtd_info *s_mtd;
struct hlist_node s_instances;
struct quota_info s_dquot; /* Diskquota specific options */ int s_frozen;
wait_queue_head_t s_wait_unfrozen; char s_id[]; /* Informational name */
u8 s_uuid[]; /* UUID */ void *s_fs_info; /* Filesystem private info */
unsigned int s_max_links;
fmode_t s_mode; /* Granularity of c/m/atime in ns.
Cannot be worse than a second */
u32 s_time_gran; /*
* The next field is for VFS *only*. No filesystems have any business
* even looking at it. You had been warned.
*/
struct mutex s_vfs_rename_mutex; /* Kludge */ /*
* Filesystem subtype. If non-empty the filesystem type field
* in /proc/mounts will be "type.subtype"
*/
char *s_subtype; /*
* Saved mount options for lazy filesystems using
* generic_show_options()
*/
char __rcu *s_options;
const struct dentry_operations *s_d_op; /* default d_op for dentries */ /*
* Saved pool identifier for cleancache (-1 means none)
*/
int cleancache_poolid; struct shrinker s_shrink; /* per-sb shrinker handle */ /* Number of inodes with nlink == 0 but still referenced */
atomic_long_t s_remove_count; /* Being remounted read-only */
int s_readonly_remount;
};

这个数据结构十分庞大,毕竟是聚集了一个文件系统的重要信息,我们关注一些比较重要的信息就行了。

 struct list_head    s_list;

s_list 这是第一个成员,是一个双向循环链表,把所有的super_block连接起来,一个super_block代表一个在linux上的文件系统,这个list上边的就是所有的在linux上记录的文件系统。

 dev_t s_dev;

s_dev:设备标识符

 unsigned char        s_dirt;
unsigned char s_blocksize_bits;
unsigned long s_blocksize;
loff_t s_maxbytes; /* Max file size */

s_dev:包含该具体文件系统的块设备标识符。例如,对于 /dev/hda1,其设备标识符为 0x301

s_blocksize:文件系统中数据块大小,以字节单位

s_blocksize_bits:上面的size大小占用位数,例如512字节就是9 bits

s_dirt:脏位,标识是否超级块被修改

 loff_t            s_maxbytes;    /* Max file size */

s_maxbytes:允许的最大的文件大小(字节数)

 struct file_system_type    *s_type;

struct file_system_type *s_type:文件系统类型(也就是当前这个文件系统属于哪个类型?ext2还是fat32)要区分“文件系统”和“文件系统类型”不一样!一个文件系统类型下可以包括很多文件系统即很多的super_block。

 const struct super_operations    *s_op;
const struct dquot_operations *dq_op;

struct super_operations *s_op:指向某个特定的具体文件系统的用于超级块操作的函数集合。

struct dquot_operations *dq_op:指向某个特定的具体文件系统用于限额操作的函数集合。

 const struct quotactl_ops    *s_qcop;

struct quotactl_ops     *s_qcop:用于配置磁盘限额的的方法,处理来自用户空间的请求。

 const struct export_operations *s_export_op;

struct export_operations *s_export_op:导出方法

1 unsigned long        s_flags;

s_flags:安装标识

1 unsigned long        s_magic;

s_magic:区别于其他文件系统的标识

 struct dentry        *s_root;

s_root:指向该具体文件系统安装目录的目录项

 struct rw_semaphore    s_umount;

s_umount:对超级块读写时进行同步

 struct mutex        s_lock;

s_lock:锁标志位,若置该位,则其它进程不能对该超级块操作

 int            s_count;

s_count:对超级块的使用计数

 atomic_t        s_active;

s_active:引用计数

s_dirty:已修改的索引节点inode形成的链表,一个文件系统中有很多的inode,有些inode节点的内容会被修改,那么会先被记录,然后写回磁盘。

s_locked_inodes:要进行同步的索引节点形成的链表

s_files:所有的已经打开文件的链表,这个file和实实在在的进程相关的

s_bdev:指向文件系统被安装的块设备

u:u 联合体域包括属于具体文件系统的超级块信息

s_instances:具体的意义后来会说的!(同一类型的文件系统通过这个子墩将所有的super_block连接起来)

s_dquot:磁盘限额相关选项

Reference:

http://www.linuxidc.com/Linux/2011-02/32127.htm

http://blog.csdn.net/shanshanpt/article/details/38943731

VFS四大对象之一 struct super_block的更多相关文章

  1. VFS四大对象之三 struct dentry

    继上一篇文章介绍了inode结构体:继续介绍目录项dentry: http://www.cnblogs.com/linhaostudy/p/7427794.html 三.dentry结构体 目录项:目 ...

  2. VFS四大对象之四-struct file

    继上一篇文章: http://www.cnblogs.com/linhaostudy/p/7428971.html 四.file结构体 文件对象:注意文件对象描述的是进程已经打开的文件.因为一个文件可 ...

  3. VFS四大对象之二 struct inode

    继上一篇文章:http://www.cnblogs.com/linhaostudy/p/7427027.html 二.inode结构体:(转自http://blog.csdn.net/shanshan ...

  4. Linux 虚拟文件系统四大对象:超级块、inode、dentry、file之间关系

    更多嵌入式原创文章,请关注公众号:一口Linux 一:文件系统 1. 什么是文件系统? 操作系统中负责管理和存储文件信息的软件机构称为文件管理系统,简称文件系统. 通常文件系统是用于存储和组织文件的一 ...

  5. PYTHON BS 四大对象

    BeautifulSoup是灵活又方便的网页解析库,处理搞笑,支持多种解析器利用它不用编写正则表达式即可方便地实现网页信息的提取BS的四大对象:1.TagTag就是HTML中的一个个标签,例如:< ...

  6. python学习之----BeautifulSoup的find()和findAll()及四大对象

    BeautifulSoup 里的find() 和findAll() 可能是你最常用的两个函数.借助它们,你可以通 过标签的不同属性轻松地过滤HTML 页面,查找需要的标签组或单个标签. 这两个函数非常 ...

  7. info.plist、pch和四大对象(UIApplication、UIApplicationDelegate、UIWindow、UIViewController)

    本文目录 1.程序配置文件info.plist,全局头文件pch 2.应用程序对象UIApplication介绍 3.UIApplicationDelegate介绍,程序启动过程 4.UIWindow ...

  8. 以相声之名说android四大对象

    当里个当,当里个当,Android此系统,易用有好用.谁为其奉献,只靠四巨头. 当里个当,当里个当,老大唤activity,界面缔造者.清水出芙蓉,天然来雕饰. 当里个当,当里个当,你若明白他,周期咋 ...

  9. jsp四大对象

    发送参数: <a href="deal.jsp?id=1&user=用户&pwd=">处理页</a> 接收参数: <% String ...

随机推荐

  1. jQuery里使用setinterval

    如果第一个参数是一个已写好的函数而不是匿名代码块,一定不要加引号,直接var ** = setinterval{myFunction ,500},只能这样,加括号会直接只调用一次,自然不行,加引号和括 ...

  2. Ubuntu 下 libgps 库的使用

    简介 一般 GPS 接收器会遵循美国国家海洋电子协会(National Marine Electronics Association)所指定的标准规格,其中包含传输资料的格式以及传输资料的通讯协议.那 ...

  3. Mybatis(基于SqlSessionTemplate的实现) + Spring 练习实战

    mybatis学习篇:上次使用映射接口实现Mybatis,有不方便指出就是需要接口,且需要保证接口上不能存在其他的代理.这次通过SqlSessionTemplate基于模板类实现Mybatis,总的来 ...

  4. IDEA热部署(一)---解析关键配置。

    本编博客转载自:因为自己在研究热部署,包括热部署那些文件,部署实现的包括那些操作.这一块,所以这篇好博客. http://www.mamicode.com/info-detail-1699044.ht ...

  5. Hue上的Oozie构建工作流和定时任务步骤

    Oozie是什么? Oozie是一种Java Web应用程序,它运行在Java servlet容器--即Tomcat--中,并使用数据库来存储以下内容: 工作流定义 当前运行的工作流实例,包括实例的状 ...

  6. JMeter循环控制器循环次数使用变量控制注意事项

    1.进入循环控制器之前变量要有值: 2.BeanShell处理文件,读取行数,赋值给变量,要有相应的Sampler,不然脚本不会运行. 对于单个线程来说,假如设置了循环2次,线程启动后,运行结束,此时 ...

  7. shell编辑crontab任务

    crontab是Linux下执行定时任务的工具,之前偶尔需要用到时都是通过执行crontab -e命令或者通过root身份直接编辑/etc/cron.*/下的文件来添加定时任务.这段时间遇到了需要通过 ...

  8. iOS 使用 CATransform3D 处理 3D 影像、制做互动立体旋转的效果

    1. Swift http://www.cocoachina.com/swift/20170518/19305.html domehttps://pan.baidu.com/s/1i4XXSkH OC ...

  9. vue.js之过滤器,自定义指令,自定义键盘信息以及监听数据变化

    一.监听数据变化 1.监听数据变化有两种,深度和浅度,形式如下: vm.$watch(name,fnCb); //浅度 vm.$watch(name,fnCb,{deep:true}); //深度监视 ...

  10. 跟我一起学JQuery插件开发教程

    在逛codeproject网站的时候,突然看到一篇文章:How to write plugin in Jquery. 如果对E文好的同学 ,可以看上面的连接.现在我把上面网站的及结合自己的想法写这篇文 ...