📄 vfs.txt
字号:
Definition:
struct inode *s_ibasket;
Purpose:
Unknown.
Description:
Seems to be of ext2 file system type origin, but is not refered
to by any kernel or file system code.
Status:
Optional. Set to NULL.
1.1.16 s_ibasket_count
-----------------------
Definition:
short int s_ibasket_count;
Purpose:
Unknown.
Description:
Seems to be of ext2 file system type origin, but is not refered
to by any kernel or file system code.
Status: Optional. Set to zero, so that future use can be detected.
1.1.17 s_ibasket_max
---------------------
Definition:
short int s_ibasket_max;
Purpose:
Unknown.
Description:
Seems to be of ext2 file system type origin, but is no refered
to by any kernel or file system code.
Status:
Optional. Set to zero.
1.1.18 s_dirty
---------------
Definition:
struct list_head s_dirty;
Purpose:
List of dirty inodes on this file system.
Description:
The list is traversed when syncing.
Status:
Required.
1.1.19 u
---------
Definition:
union {
struct minix_sb_info minix_sb;
struct ext2_sb_info ext2_sb;
struct hpfs_sb_info hpfs_sb;
struct msdos_sb_info msdos_sb;
struct isofs_sb_info isofs_sb;
struct nfs_sb_info nfs_sb;
struct sysv_sb_info sysv_sb;
struct affs_sb_info affs_sb;
struct ufs_sb_info ufs_sb;
struct romfs_sb_info romfs_sb;
struct smb_sb_info smbfs_sb;
void *generic_sbp;
} u;
Purpose:
All file system specific info that should be stored with the
super block.
Description:
Note the file system specific info structure naming scheme.
It is customary to define the filesystem specific super block
info structure in a header file named
include/linux/fstype_fs_sb.h
where "fstype" is the file system type abbreviation. This
header file must be included from include/linux/fs.h
If the filesystem specific info requires many bytes, then it
should be allocated memory and be refered to by the generic
pointer. This avoids wasting memory, as every super block
would otherwise contain enough space for file system specific
info, whether it was being used or not.
To make dealing with this union more convenient, it is common
to define a macro such as the following:
#define EXT2_SB(X) (&((X)->u.ext2_sb))
With such a definition, it is simple to change to an allocated
info structure should the need arise at a later date:
#define EXT2_SB(X) ((struct ext2_sb_info *)(X)->u.generic_sbp)
Memory for an allocated info structure should be allocated
using the kmalloc() routine, and should be done from the
read_super() routine [refer to section ?.?.?]. The memory is
later released by using the kfree() routine, which should be
done from the put_super() routine [refer to section ?.?.?].
1.2 Super Block Operations
---------------------------
The following definition of the super block operations structure can be
found in the header file linux/include/linux/fs.h
struct super_operations {
void (*read_inode) (struct inode *);
void (*write_inode) (struct inode *);
void (*put_inode) (struct inode *);
void (*delete_inode) (struct inode *);
int (*notify_change) (struct inode *, struct iattr *);
void (*put_super) (struct super_block *);
void (*write_super) (struct super_block *);
int (*statfs) (struct super_block *, struct statfs *, int);
int (*remount_fs) (struct super_block *, int *, char *);
};
1.2.1 read_inode
-----------------
Definition:
void (*read_inode) (struct inode *);
Purpose:
Read the specified inode from the specified file system.
1.2.2 write_inode
------------------
Definition:
void (*write_inode) (struct inode *);
1.2.3 put_inode
----------------
Definition:
void (*put_inode) (struct inode *);
1.2.4 delete_inode
-------------------
Definition:
void (*delete_inode) (struct inode *);
1.2.5 notify_change
--------------------
Definition:
int (*notify_change) (struct inode *, struct iattr *);
1.2.6 put_super
----------------
Definition:
void (*put_super) (struct super_block *);
1.2.7 write_super
------------------
Definition:
void (*write_super) (struct super_block *);
1.2.8 statfs
-------------
Definition:
int (*statfs) (struct super_block *, struct statfs *, int);
1.2.9 remount_fs
-----------------
Definition:
int (*remount_fs) (struct super_block *, int *, char *);
2. Inodes
----------
An inode contains data ("metadata") that describes the data in a file.
The standard types of files an inode represents are:
o Regular Files
o Directories
o Links
o Symbolic Links
o Block Devices
o Character Devices
o Named Pipes
o Un-named Pipes
o Communication Sockets
Both un-named pipes and communication sockets are kernel abstractions -
they operate like files, so it makes sense to handle them internally
like files - and they are not recorded on a files system. These two
will therefore not be covered in this document.
Note that it is possible for a filesystem to define files with none of
the characteristics of the standard file types, though this would be
highly unusual.
2.1 Inode Structure
--------------------
The following definition of the inode structure can be found in the
header file linux/include/linux/fs.h
struct inode {
struct list_head i_hash;
struct list_head i_list;
unsigned long i_ino;
kdev_t i_dev;
unsigned short i_count;
umode_t i_mode;
nlink_t i_nlink;
uid_t i_uid;
gid_t i_gid;
kdev_t i_rdev;
off_t i_size;
time_t i_atime;
time_t i_mtime;
time_t i_ctime;
unsigned long i_blksize;
unsigned long i_blocks;
unsigned long i_version;
unsigned long i_nrpages;
struct semaphore i_sem;
struct inode_operations *i_op;
struct super_block *i_sb;
struct wait_queue *i_wait;
struct file_lock *i_flock;
struct vm_area_struct *i_mmap;
struct page *i_pages;
struct dquot *i_dquot[MAXQUOTAS];
unsigned long i_state;
unsigned int i_flags;
unsigned char i_pipe;
unsigned char i_sock;
int i_writecount;
unsigned int i_attr_flags;
union {
struct pipe_inode_info pipe_i;
struct minix_inode_info minix_i;
struct ext2_inode_info ext2_i;
struct hpfs_inode_info hpfs_i;
struct msdos_inode_info msdos_i;
struct umsdos_inode_info umsdos_i;
struct iso_inode_info isofs_i;
struct nfs_inode_info nfs_i;
struct sysv_inode_info sysv_i;
struct affs_inode_info affs_i;
struct ufs_inode_info ufs_i;
struct romfs_inode_info romfs_i;
struct smb_inode_info smbfs_i;
struct socket socket_i;
void *generic_ip;
} u;
};
2.1.1 i_hash
-------------
Definition:
struct list_head i_hash;
Purpose:
The list of inodes that hash to the same value.
Description:
This field is used by the inode queue to locate an inode. When
two or more inodes hash to the same value, the inodes are put
in a list which can be searched linearly.
Status:
Required. The inode cache maintains the value of this field.
2.1.2 i_list
-------------
Definition:
struct list_head i_list;
Purpose:
The list of inodes on this file system.
Description:
Status:
2.1.3 i_ino
------------
Definition:
unsigned long i_ino;
Purpose:
The number of the inode.
Description:
The inode number must be unique on the file system.
An inode number is at least 32-bits wide.
It is common to use the inode number to store the location of
the file system inode which is recorded on the device (and may
be completely different than the kernel inode structure). This
only works if the inode location can fit into 32-bits, and it
is constant for a given file.
If more room is required for the inode location, it can be
stored with the inode by using the file system specific info
union [refer to section ?.?.?]. The inode number in this case
can be the location of the inode structure in memory, since
this is guaranteed to be unique. Note that with this strategy,
inode numbers are not constant for a given file.
Status:
Required.
2.1.4 i_dev
------------
Definition:
kdev_t i_dev;
Purpose:
Description:
Status:
2.1.5 i_count
-------------
Definition:
unsigned short i_count;
Purpose:
Description:
Status:
2.1.6 i_mode
-------------
Definition:
umode_t i_mode;
Purpose:
Description:
Status:
2.1.7 i_nlink
--------------
Definition:
nlink_t i_nlink;
Purpose:
Description:
Status:
2.1.8 i_uid
------------
Definition:
uid_t i_uid;
Purpose:
Description:
Status:
The ID of the user that owns this inode.
2.1.9 i_gid
------------
Definition:
gid_t i_gid;
Purpose:
Description:
Status:
The group ID for this inode.
2.1.10 i_rdev
--------------
Definition:
kdev_t i_rdev;
Purpose:
Description:
Status:
2.1.11 i_size
--------------
Definition:
off_t i_size;
Purpose:
Description:
Status:
The number of bytes of data used by this inode.
2.1.12 i_atime
---------------
Definition:
time_t i_atime;
Purpose:
Description:
Status:
The time this inode's data was last accessed.
2.1.13 i_mtime
---------------
Definition:
time_t i_mtime;
Purpose:
Description:
Status:
The time this inode's data was last modified.
2.1.14 i_ctime
---------------
Definition:
time_t i_ctime;
Purpose:
Description:
Status:
The time the inode structure was last changed.
2.1.15 i_blksize
-----------------
Definition:
unsigned long i_blksize;
Purpose:
Description:
Status:
The block size to use for this inode.
This field should normally be identical to the super block's
s_blocksize field [refer to section ?.?.?].
2.1.16 i_blocks
----------------
Definition:
unsigned long i_blocks;
Purpose:
The total number of blocks allocated to a file.
Description:
The total number includes any overhead blocks, for example:
direct, indirect, and data blocks. This allows for "holes",
which are blocks that are not recorded, but contain zero when
read [writing to a hole causes a block to be allocated].
If 0, an estimate is made based on the Minix file system.
The i_blocks field is used for handling quotas, so a file
system should endevour to make it accurate.
Status:
Optional.
2.1.17 i_version
-----------------
Definition:
unsigned long i_version;
Purpose:
Description:
Status:
The version of the inode.
This is useful for tracking changes to the inode.
2.1.18 i_nrpages
-----------------
Definition:
unsigned long i_nrpages;
Purpose:
Description:
Status:
Number of pages of memory allocated to this inode.
2.1.19 i_sem
-------------
Definition:
struct semaphore i_sem;
Purpose:
Description:
Status:
2.1.20 i_op
------------
Definition:
struct inode_operations *i_op;
Purpose:
Description:
Status:
A pointer to the inode operations structure for the inode.
2.1.21 i_sb
------------
Definition:
struct super_block *i_sb;
Purpose:
Description:
Status:
Pointer to the super block of the file system the inode belongs
to.
2.1.22 i_wait
--------------
Definition:
struct wait_queue *i_wait;
Purpose:
Description:
Status:
Pointer to the queue of processes waiting on the inode.
2.1.23 i_flock
---------------
Definition:
struct file_lock *i_flock;
Purpose:
Description:
Status:
2.1.24 i_mmap
--------------
Definition:
struct vm_area_struct *i_mmap;
Purpose:
Description:
Status:
2.1.25 i_pages
---------------
Definition:
struct page *i_pages;
Purpose:
Description:
Status:
Pointer to the pages being used to map the inode.
2.1.26 i_dquot
---------------
Definition:
struct dquot *i_dquot[MAXQUOTAS];
Purpose:
Description:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -