⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vfs.txt

📁 linux 的 VFS 文件系统说明
💻 TXT
📖 第 1 页 / 共 3 页
字号:
	Status:


2.1.27  i_state
---------------

	Definition:
		unsigned long i_state;

	Purpose:

	Description:

	Status:


2.1.28  i_flags
---------------

	Definition:
		unsigned int i_flags;

	Purpose:

	Description:

	Status:


2.1.29  i_pipe
--------------

	Definition:
		unsigned char i_pipe;

	Purpose:

	Description:

	Status:


2.1.30  i_sock
--------------

	Definition:
		unsigned char i_sock;

	Purpose:

	Description:

	Status:


2.1.31  i_writecount
--------------------

	Definition:
		int i_writecount;

	Purpose:

	Description:

	Status:


2.1.32  i_attr_flags
--------------------

	Definition:
		unsigned int i_attr_flags;

	Purpose:

	Description:

	Status:


2.1.33  u
---------

	Definition:
		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;

	Purpose:

	Description:

	Status:


2.2  Inode Operations Structure
-------------------------------

	The following definition of the inode operations structure can be found
	in the header file linux/include/linux/fs.h

	struct inode_operations {
		struct file_operations * default_file_ops;
		int (*create) (struct inode *,struct dentry *,int);
		int (*lookup) (struct inode *,struct dentry *);
		int (*link) (struct inode *,struct inode *,struct dentry *);
		int (*unlink) (struct inode *,struct dentry *);
		int (*symlink) (struct inode *,struct dentry *,const char *);
		int (*mkdir) (struct inode *,struct dentry *,int);
		int (*rmdir) (struct inode *,struct dentry *);
		int (*mknod) (struct inode *,struct dentry *,int,int);
		int (*rename) (struct inode *,struct dentry *,struct inode *,
			struct dentry *);
		int (*readlink) (struct inode *,char *,int);
		struct dentry * (*follow_link) (struct inode *,
			struct dentry *);
		int (*readpage) (struct inode *, struct page *);
		int (*writepage) (struct inode *, struct page *);
		int (*bmap) (struct inode *,int);
		void (*truncate) (struct inode *);
		int (*permission) (struct inode *, int);
		int (*smap) (struct inode *,int);
		int (*updatepage) (struct inode *, struct page *, const char *,
				unsigned long, unsigned int, int);
		int (*revalidate) (struct inode *);
	};


2.2.1  default_file_ops
-----------------------

	struct file_operations * default_file_ops;


2.2.2  create
-------------

	int (*create) (struct inode *s, struct dentry *s, int);


2.2.3  lookup
-------------

	int (*lookup) (struct inode *,struct dentry *);


2.2.4  link
-----------

	int (*link) (struct inode *,struct inode *,struct dentry *);


2.2.5  unlink
-------------

	int (*unlink) (struct inode *,struct dentry *);


2.2.6  symlink
--------------

	int (*symlink) (struct inode *,struct dentry *,const char *);


2.2.7  mkdir
------------

	int (*mkdir) (struct inode *,struct dentry *,int);

2.2.8  rmdir
------------

	int (*rmdir) (struct inode *,struct dentry *);


2.2.9  mknod
------------

	int (*mknod) (struct inode *,struct dentry *,int,int);


2.2.10  rename
--------------

	int (*rename) (struct inode *,struct dentry *,struct inode *,
			struct dentry *);


2.2.11  readlink
----------------

	int (*readlink) (struct inode *,char *,int);


2.2.12  follow_link
-------------------

	struct dentry * (*follow_link) (struct inode *, struct dentry *);


2.2.13  readpage
----------------

	int (*readpage) (struct inode *, struct page *);


2.2.14  writepage
-----------------

	int (*writepage) (struct inode *, struct page *);


2.2.15  bmap
------------

	int (*bmap) (struct inode *,int);


2.2.16  truncate
----------------

	void (*truncate) (struct inode *);


2.2.17  permission
------------------

	int (*permission) (struct inode *, int);


2.2.18  smap
------------

	int (*smap) (struct inode *,int);


2.2.19  updatepage
------------------

	int (*updatepage) (struct inode *, struct page *, const char *,
		unsigned long, unsigned int, int);


2.2.20  revalidate
------------------

	int (*revalidate) (struct inode *);


3.0  File Data
--------------


3.1  File Structure
-------------------

	The definition of the file structure can be found in the header file
	linux/include/linux/fs.h

	struct file {
		struct file		*f_next, **f_pprev;
		struct dentry		*f_dentry;
		struct file_operations	*f_op;
		mode_t			f_mode;
		loff_t			f_pos;
		unsigned short 		f_count, f_flags;
		unsigned long 		f_reada, f_ramax, f_raend,
					f_ralen, f_rawin;
		struct fown_struct	f_owner;
		unsigned long		f_version;

		/* needed for tty driver, and maybe others */
		void			*private_data;
	};


3.1.1  f_next
-------------

	struct file *f_next;


3.1.2  f_pprev
--------------

	struct file **f_pprev;


3.1.3  f_dentry
---------------

	struct dentry *f_dentry;


3.1.4  f_op
-----------

	struct file_operations *f_op;


3.1.5  f_mode
-------------

	mode_t mode;


3.1.6  f_pos
------------

	loff_t f_pos;


3.1.7  f_count
--------------

	unsigned short f_count;


3.1.8  f_flags
--------------

	unsigned shore f_flags;


3.1.9	f_reada
---------------

	unsigned long f_reada;


3.1.10  f_ramax
---------------

	unsigned long f_ramax;


3.1.11  f_raend
---------------

	unsigned long f_raend;


3.1.12  f_ralen
---------------

	unsigned long f_ralen;


3.1.13  f_rawin
---------------

	unsigned long f_rawin;


3.1.14  f_owner
---------------

	struct fown_struct *f_owner;


3.1.15  f_version
-----------------

	unsigned long f_version;


3.1.16  private_data
--------------------

	void *private_data;


3.2  File Operations Structure
------------------------------

	The definition of the file operations structure can be found in the
	header file linux/include/linux/fs.h

	struct file_operations {
		long long (*llseek) (struct inode *, struct file *, long long,
			int);
		long (*read) (struct inode *, struct file *, char *,
			unsigned long);
		long (*write) (struct inode *, struct file *, const char *,
			unsigned long);
		int (*readdir) (struct inode *, struct file *, void *,
			filldir_t);
		unsigned int (*poll) (struct file *, poll_table *);
		int (*ioctl) (struct inode *, struct file *, unsigned int,
			unsigned long);
		int (*mmap) (struct inode *, struct file *,
			struct vm_area_struct *);
		int (*open) (struct inode *, struct file *);
		int (*release) (struct inode *, struct file *);
		int (*fsync) (struct inode *, struct file *);
		int (*fasync) (struct inode *, struct file *, int);
		int (*check_media_change) (kdev_t dev);
		int (*revalidate) (kdev_t dev);
		int (*lock) (struct inode *, struct file *, int,
			struct file_lock *);
	};


3.2.1  llseek
-------------

	long long (*llseek) (struct inode *, struct file *, long long, int);


3.2.2  read
-----------

	long (*read) (struct inode *, struct file *, char *, unsigned long);


3.2.3  write
------------

	long (*write) (struct inode *, struct file *, const char *,
		unsigned long);


3.2.4  readdir
--------------

	int (*readdir) (struct inode *, struct file *, void *, filldir_t);


3.2.5  poll
-----------

	unsigned int (*poll) (struct file *, poll_table *);


3.2.6  ioctl
------------

	int (*ioctl) (struct inode *, struct file *, unsigned int,
		unsigned long);


3.2.7  mmap
-----------

	int (*mmap) (struct inode *, struct file *, struct vm_area_struct *);


3.2.8  open
-----------

	int (*open) (struct inode *, struct file *);


3.2.9  release
--------------

	int (*release) (struct inode *, struct file *);
	

3.2.10  fsync
-------------

	int (*fsync) (struct inode *, struct file *);


3.2.11 fasync
-------------

	int (*fasync) (struct inode *, struct file *, int);


3.2.12  check_media_change
--------------------------

	int (*check_media_change) (kdev_t dev);


3.2.13  revalidate
------------------

	int (*revalidate) (kdev_t dev);


3.2.14  lock
------------

	int (*lock) (struct inode *, struct file *, int, struct file_lock *);


4.0  The Directory Entry Cache
------------------------------

	The directory entry cache (dcache) is a relatively new feature in the
	Linux kernel.  It is quite simple in concept: the dcache speeds up
	file name to inode look-ups.  Since an inode can have multiple names,
	there can be multiple dcache entries (dentries) pointing to the same
	inode.  When an inode is in use (i_count > 0) at least one dentry will
	exist for it.


4.1  Directory Entry Structure
------------------------------

	The definition of the directory entry structure can be found in the
	header file linux/include/linux/dcache.h

	struct dentry {
		int d_count;
		unsigned int d_flags;
		struct inode  * d_inode;	/* Where the name belongs to - NULL is negative */
		struct dentry * d_parent;	/* parent directory */
		struct dentry * d_mounts;	/* mount information */
		struct dentry * d_covers;
		struct list_head d_hash;	/* lookup hash list */
		struct list_head d_lru;		/* d_count = 0 LRU list */
		struct qstr d_name;
		unsigned long d_time;		/* used by d_revalidate */
		struct dentry_operations  *d_op;
		struct super_block * d_sb;	/* The root of the dentry tree */
	};


4.2  Dentry Operations
----------------------

	The definition of the dentry operations structure can be found in the
	header file linux/include/linux/dcache.h

	struct dentry_operations {
		int (*d_revalidate)(struct dentry *);
		int (*d_hash) (struct dentry *,struct qstr *);
		int (*d_compare) (struct dentry *,struct qstr *, struct qstr *);
		void (*d_delete)(struct dentry *);
	};

4.3  Quick Strings
------------------

	A "quick string" (qstr) eases parameter passing, but more imporantly
	saves metadata about the string (ie length and hash value) in one
	place.


4.3.1 Quick String Structure
----------------------------

	The definition of the quick string structure can be found in the header
	file linux/include/linux/dcache.h

	struct qstr {
		const unsigned char * name;
		unsigned int len, hash;
	};


4.3.2  Hashing Quick Strings
----------------------------

	There are three steps to hashing a qstr:

		1. hash = init_name_hash()
		2. hash = partial_name_hash(c, hash)
		3. hash = end_name_hash(unsigned long hash)

	Step 2 is repeated for every character in the string.


11.0 Quotas
-----------


11.1 Quota Operations Structure
-------------------------------

	As of kernel 2.1.61, the quota operations structure is defined as:

	struct dquot_operations {
		void (*initialize) (struct inode *, short);
		void (*drop) (struct inode *);
		int (*alloc_block) (const struct inode *, unsigned long);
		int (*alloc_inode) (const struct inode *, unsigned long);
		void (*free_block) (const struct inode *, unsigned long);
		void (*free_inode) (const struct inode *, unsigned long);
		int (*transfer) (struct inode *, struct iattr *, char);
	};


12.0  The VFS Character Set
---------------------------

	What character set(s) the kernel and file systems should use is a
	subject of great debate in the Linux developer community.  A unified
	character set would be a great idea, assuming everyone could agree on
	on one.

	The closest to agreement that has been reached is to use any 8-bit
	character set desired, as long as it preserves the meaning of the
	string terminator 0x00 and the path separator 0x2f.  Multi-byte
	character sets can use UTF-8 encoding.

	This is not a perfect solution, as it sacrifices media portability
	and multi-language support for coding efficiency.


12.1.0  Encoding with UTF-8
---------------------------

	UTF-8 is thoroughly covered in The Internet Engineering Task Force's
	(IETF) Request For Comments document RFC ????.

	The encoding is quite simple [characters values in hex, UTF-8 code in
	binary]:

	Characters: 0x00000000-0x0000007F
	UTF-8 Code: 0*******

	Characters: 0x00000080-0x000007FF
	UTF-8 Code: 110***** 10******

	Characters: 0x00000800-0x0000FFFF
	UTF-8 Code: 1110**** 10****** 10******

	Characters: 0x00010000-0x003FFFFF
	UTF-8 Code: 11110*** 10****** 10****** 10******

	Characters: 0x00400000-0x03FFFFFF
	UTF-8 Code: 111110** 10****** 10****** 10****** 10******

	Characters: 0x04000000-0x7FFFFFFF
	UTF-8 Code: 1111110* 10****** 10****** 10****** 10****** 10******

	Where * represents a single bit from the multi-byte character.


Appendix ?
----------
	sys_mount
	sys_umount
	sys_open
	sys_close
	sys_read
	sys_write
	sys_llseek
	sys_mkdir
	sys_mknod
	sys_link
	sys_symlink
	sys_unlink
	sys_rename
	sys_sync
	sys_ioctl
	sys_getdents


About the Author
----------------

	Andrew E. Mileski resides in Ottawa, the capital of Canada - also known
	as Silicon Valley North - has an honors diploma in Computer Science and
	Technology, and has a some background in Electrical Engineering.

	He is an avid amateur Linux kernel hacker, maintains a modular loop
	device driver with advanced encryption capabilites, and works on adding
	kernel support for Plug-and-Play devices.  Mr. Mileski is also know for
	his work as a member of the XFree86 Matrox X server development team,
	and has contributed to the Internet News server package [INN], as well
	as other software packages.

	He is currently working on implementing a Linux filesystem driver that
	supports the complex but portable Universal Disk Format [UDF] specified
	by the Optical Storage Technology Association [OSTA], and commonly used
	with DVD, CD-R, and CD-RW media.

	In his remaining spare time, he particularly enjoys flying his 99"
	wingspan Adante radio controlled aerobatic model sailplane - though he
	obtained licences to pilot full-size sailplanes and single engine
	aircraft by age 17.


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -