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

📄 fs.h

📁 讲述linux的初始化过程
💻 H
📖 第 1 页 / 共 4 页
字号:
	struct semaphore s_vfs_rename_sem;	/* Kludge */	/* The next field is used by knfsd when converting a (inode number based)	 * file handle into a dentry. As it builds a path in the dcache tree from	 * the bottom up, there may for a time be a subpath of dentrys which is not	 * connected to the main tree.  This semaphore ensure that there is only ever	 * one such free path per filesystem.  Note that unconnected files (or other	 * non-directories) are allowed, but not unconnected diretories.	 */	struct semaphore s_nfsd_free_path_sem;};/* * VFS helper functions.. */extern int vfs_create(struct inode *, struct dentry *, int);extern int vfs_mkdir(struct inode *, struct dentry *, int);extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);extern int vfs_symlink(struct inode *, struct dentry *, const char *);extern int vfs_link(struct dentry *, struct inode *, struct dentry *);extern int vfs_rmdir(struct inode *, struct dentry *);extern int vfs_unlink(struct inode *, struct dentry *);extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);/* * File types */#define DT_UNKNOWN	0#define DT_FIFO		1#define DT_CHR		2#define DT_DIR		4#define DT_BLK		6#define DT_REG		8#define DT_LNK		10#define DT_SOCK		12#define DT_WHT		14/* * This is the "filldir" function type, used by readdir() to let * the kernel specify what kind of dirent layout it wants to have. * This allows the kernel to read directories into kernel space or * to have different dirent layouts depending on the binary type. */typedef int (*filldir_t)(void *, const char *, int, off_t, ino_t, unsigned);struct block_device_operations {	int (*open) (struct inode *, struct file *);	int (*release) (struct inode *, struct file *);	int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);	int (*check_media_change) (kdev_t);	int (*revalidate) (kdev_t);};/* * NOTE: * read, write, poll, fsync, readv, writev can be called *   without the big kernel lock held in all filesystems. */struct file_operations {	struct module *owner;	loff_t (*llseek) (struct file *, loff_t, int);	ssize_t (*read) (struct file *, char *, size_t, loff_t *);	ssize_t (*write) (struct file *, const char *, size_t, loff_t *);	int (*readdir) (struct file *, void *, filldir_t);	unsigned int (*poll) (struct file *, struct poll_table_struct *);	int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);	int (*mmap) (struct file *, struct vm_area_struct *);	int (*open) (struct inode *, struct file *);	int (*flush) (struct file *);	int (*release) (struct inode *, struct file *);	int (*fsync) (struct file *, struct dentry *, int datasync);	int (*fasync) (int, struct file *, int);	int (*lock) (struct file *, int, struct file_lock *);	ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);	ssize_t (*writev) (struct file *, const struct iovec *, unsigned long, loff_t *);};struct inode_operations {	int (*create) (struct inode *,struct dentry *,int);	struct dentry * (*lookup) (struct inode *,struct dentry *);	int (*link) (struct dentry *,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 dentry *, char *,int);	int (*follow_link) (struct dentry *, struct nameidata *);	void (*truncate) (struct inode *);	int (*permission) (struct inode *, int);	int (*revalidate) (struct dentry *);	int (*setattr) (struct dentry *, struct iattr *);	int (*getattr) (struct dentry *, struct iattr *);};/* * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called * without the big kernel lock held in all filesystems. */struct super_operations {	void (*read_inode) (struct inode *);	void (*write_inode) (struct inode *, int);	void (*put_inode) (struct inode *);	void (*delete_inode) (struct inode *);	void (*put_super) (struct super_block *);	void (*write_super) (struct super_block *);	int (*statfs) (struct super_block *, struct statfs *);	int (*remount_fs) (struct super_block *, int *, char *);	void (*clear_inode) (struct inode *);	void (*umount_begin) (struct super_block *);};struct dquot_operations {	void (*initialize) (struct inode *, short);	void (*drop) (struct inode *);	int (*alloc_block) (const struct inode *, unsigned long, char);	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 dentry *, struct iattr *);};struct file_system_type {	const char *name;	int fs_flags;	struct super_block *(*read_super) (struct super_block *, void *, int);	struct module *owner;	struct vfsmount *kern_mnt; /* For kernel mount, if it's FS_SINGLE fs */	struct file_system_type * next;};#define DECLARE_FSTYPE(var,type,read,flags) \struct file_system_type var = { \	name:		type, \	read_super:	read, \	fs_flags:	flags, \	owner:		THIS_MODULE, \}#define DECLARE_FSTYPE_DEV(var,type,read) \	DECLARE_FSTYPE(var,type,read,FS_REQUIRES_DEV)/* Alas, no aliases. Too much hassle with bringing module.h everywhere */#define fops_get(fops) \	(((fops) && (fops)->owner)	\		? ( try_inc_mod_count((fops)->owner) ? (fops) : NULL ) \		: (fops))#define fops_put(fops) \do {	\	if ((fops) && (fops)->owner) \		__MOD_DEC_USE_COUNT((fops)->owner);	\} while(0)extern int register_filesystem(struct file_system_type *);extern int unregister_filesystem(struct file_system_type *);extern struct vfsmount *kern_mount(struct file_system_type *);extern void kern_umount(struct vfsmount *);extern int may_umount(struct vfsmount *);extern long do_mount(char *, char *, char *, unsigned long, void *);extern int vfs_statfs(struct super_block *, struct statfs *);/* Return value for VFS lock functions - tells locks.c to lock conventionally * REALLY kosha for root NFS and nfs_lock */ #define LOCK_USE_CLNT 1#define FLOCK_VERIFY_READ  1#define FLOCK_VERIFY_WRITE 2extern int locks_mandatory_locked(struct inode *);extern int locks_mandatory_area(int, struct inode *, struct file *, loff_t, size_t);/* * Candidates for mandatory locking have the setgid bit set * but no group execute bit -  an otherwise meaningless combination. */#define MANDATORY_LOCK(inode) \	(IS_MANDLOCK(inode) && ((inode)->i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)static inline int locks_verify_locked(struct inode *inode){	if (MANDATORY_LOCK(inode))		return locks_mandatory_locked(inode);	return 0;}static inline int locks_verify_area(int read_write, struct inode *inode,				    struct file *filp, loff_t offset,				    size_t count){	if (inode->i_flock && MANDATORY_LOCK(inode))		return locks_mandatory_area(read_write, inode, filp, offset, count);	return 0;}static inline int locks_verify_truncate(struct inode *inode,				    struct file *filp,				    loff_t size){	if (inode->i_flock && MANDATORY_LOCK(inode))		return locks_mandatory_area(			FLOCK_VERIFY_WRITE, inode, filp,			size < inode->i_size ? size : inode->i_size,			(size < inode->i_size ? inode->i_size - size			 : size - inode->i_size)		);	return 0;}extern inline int get_lease(struct inode *inode, unsigned int mode){	if (inode->i_flock && (inode->i_flock->fl_flags & FL_LEASE))		return __get_lease(inode, mode);	return 0;}/* fs/open.c */asmlinkage long sys_open(const char *, int, int);asmlinkage long sys_close(unsigned int);	/* yes, it's really unsigned */extern int do_truncate(struct dentry *, loff_t start);extern struct file *filp_open(const char *, int, int);extern struct file * dentry_open(struct dentry *, struct vfsmount *, int);extern int filp_close(struct file *, fl_owner_t id);extern char * getname(const char *);/* fs/dcache.c */extern void vfs_caches_init(unsigned long);#define __getname()	kmem_cache_alloc(names_cachep, SLAB_KERNEL)#define putname(name)	kmem_cache_free(names_cachep, (void *)(name))enum {BDEV_FILE, BDEV_SWAP, BDEV_FS, BDEV_RAW};extern int register_blkdev(unsigned int, const char *, struct block_device_operations *);extern int unregister_blkdev(unsigned int, const char *);extern struct block_device *bdget(dev_t);extern void bdput(struct block_device *);extern int blkdev_open(struct inode *, struct file *);extern struct file_operations def_blk_fops;extern struct file_operations def_fifo_fops;extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);extern int blkdev_get(struct block_device *, mode_t, unsigned, int);extern int blkdev_put(struct block_device *, int);/* fs/devices.c */extern const struct block_device_operations *get_blkfops(unsigned int);extern int register_chrdev(unsigned int, const char *, struct file_operations *);extern int unregister_chrdev(unsigned int, const char *);extern int chrdev_open(struct inode *, struct file *);extern const char * bdevname(kdev_t);extern const char * cdevname(kdev_t);extern const char * kdevname(kdev_t);extern void init_special_inode(struct inode *, umode_t, int);/* Invalid inode operations -- fs/bad_inode.c */extern void make_bad_inode(struct inode *);extern int is_bad_inode(struct inode *);extern struct file_operations read_fifo_fops;extern struct file_operations write_fifo_fops;extern struct file_operations rdwr_fifo_fops;extern struct file_operations read_pipe_fops;extern struct file_operations write_pipe_fops;extern struct file_operations rdwr_pipe_fops;extern int fs_may_remount_ro(struct super_block *);extern int try_to_free_buffers(struct page *, int);extern void refile_buffer(struct buffer_head * buf);#define BUF_CLEAN	0#define BUF_LOCKED	1	/* Buffers scheduled for write */#define BUF_DIRTY	2	/* Dirty buffers, not yet scheduled for write */#define BUF_PROTECTED	3	/* Ramdisk persistent storage */#define NR_LIST		4/* * This is called by bh->b_end_io() handlers when I/O has completed. */static inline void mark_buffer_uptodate(struct buffer_head * bh, int on){	if (on)		set_bit(BH_Uptodate, &bh->b_state);	else		clear_bit(BH_Uptodate, &bh->b_state);}#define atomic_set_buffer_clean(bh) test_and_clear_bit(BH_Dirty, &(bh)->b_state)static inline void __mark_buffer_clean(struct buffer_head *bh){	refile_buffer(bh);}static inline void mark_buffer_clean(struct buffer_head * bh){	if (atomic_set_buffer_clean(bh))		__mark_buffer_clean(bh);}#define atomic_set_buffer_protected(bh) test_and_set_bit(BH_Protected, &(bh)->b_state)static inline void __mark_buffer_protected(struct buffer_head *bh){	refile_buffer(bh);}static inline void mark_buffer_protected(struct buffer_head * bh){	if (!atomic_set_buffer_protected(bh))		__mark_buffer_protected(bh);}extern void FASTCALL(__mark_buffer_dirty(struct buffer_head *bh));extern void FASTCALL(mark_buffer_dirty(struct buffer_head *bh));#define atomic_set_buffer_dirty(bh) test_and_set_bit(BH_Dirty, &(bh)->b_state)/* * If an error happens during the make_request, this function * has to be recalled. It marks the buffer as clean and not * uptodate, and it notifys the upper layer about the end * of the I/O. */static inline void buffer_IO_error(struct buffer_head * bh){	mark_buffer_clean(bh);	/*	 * b_end_io has to clear the BH_Uptodate bitflag in the error case!	 */	bh->b_end_io(bh, 0);}extern void buffer_insert_inode_queue(struct buffer_head *, struct inode *);static inline void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode){	mark_buffer_dirty(bh);	buffer_insert_inode_queue(bh, inode);}extern void balance_dirty(kdev_t);extern int check_disk_change(kdev_t);extern int invalidate_inodes(struct super_block *);extern void invalidate_inode_pages(struct inode *);extern void invalidate_inode_buffers(struct inode *);#define invalidate_buffers(dev)	__invalidate_buffers((dev), 0)#define destroy_buffers(dev)	__invalidate_buffers((dev), 1)extern void __invalidate_buffers(kdev_t dev, int);extern void sync_inodes(kdev_t);extern void write_inode_now(struct inode *, int);extern void sync_dev(kdev_t);

⌨️ 快捷键说明

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