fs.h

来自「此工具是arm-linux-GCC交叉编译工具(cross-3.4.4)」· C头文件 代码 · 共 1,770 行 · 第 1/5 页

H
1,770
字号
struct block_device {	dev_t			bd_dev;  /* not a kdev_t - it's a search key */	struct inode *		bd_inode;	/* will die */	int			bd_openers;	struct semaphore	bd_sem;	/* open/close mutex */	struct semaphore	bd_mount_sem;	/* mount mutex */	struct list_head	bd_inodes;	void *			bd_holder;	int			bd_holders;	struct block_device *	bd_contains;	unsigned		bd_block_size;	struct hd_struct *	bd_part;	/* number of times partitions within this device have been opened. */	unsigned		bd_part_count;	int			bd_invalidated;	struct gendisk *	bd_disk;	struct list_head	bd_list;	struct backing_dev_info *bd_inode_backing_dev_info;	/*	 * Private data.  You must have bd_claim'ed the block_device	 * to use this.  NOTE:  bd_claim allows an owner to claim	 * the same device multiple times, the owner must take special	 * care to not mess up bd_private for that case.	 */	unsigned long		bd_private;};/* * Radix-tree tags, for tagging dirty and writeback pages within the pagecache * radix trees */#define PAGECACHE_TAG_DIRTY	0#define PAGECACHE_TAG_WRITEBACK	1int mapping_tagged(struct address_space *mapping, int tag);/* * Might pages of this file be mapped into userspace? */static inline int mapping_mapped(struct address_space *mapping){	return	!prio_tree_empty(&mapping->i_mmap) ||		!list_empty(&mapping->i_mmap_nonlinear);}/* * Might pages of this file have been modified in userspace? * Note that i_mmap_writable counts all VM_SHARED vmas: do_mmap_pgoff * marks vma as VM_SHARED if it is shared, and the file was opened for * writing i.e. vma may be mprotected writable even if now readonly. */static inline int mapping_writably_mapped(struct address_space *mapping){	return mapping->i_mmap_writable != 0;}/* * Use sequence counter to get consistent i_size on 32-bit processors. */#if BITS_PER_LONG==32 && defined(CONFIG_SMP)#include <linux/seqlock.h>#define __NEED_I_SIZE_ORDERED#define i_size_ordered_init(inode) seqcount_init(&inode->i_size_seqcount)#else#define i_size_ordered_init(inode) do { } while (0)#endifstruct inode {	struct hlist_node	i_hash;	struct list_head	i_list;	struct list_head	i_sb_list;	struct list_head	i_dentry;	unsigned long		i_ino;	atomic_t		i_count;	umode_t			i_mode;	unsigned int		i_nlink;	uid_t			i_uid;	gid_t			i_gid;	dev_t			i_rdev;	loff_t			i_size;	struct timespec		i_atime;	struct timespec		i_mtime;	struct timespec		i_ctime;	unsigned int		i_blkbits;	unsigned long		i_blksize;	unsigned long		i_version;	unsigned long		i_blocks;	unsigned short          i_bytes;	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */	struct semaphore	i_sem;	struct rw_semaphore	i_alloc_sem;	struct inode_operations	*i_op;	struct file_operations	*i_fop;	/* former ->i_op->default_file_ops */	struct super_block	*i_sb;	struct file_lock	*i_flock;	struct address_space	*i_mapping;	struct address_space	i_data;#ifdef CONFIG_QUOTA	struct dquot		*i_dquot[MAXQUOTAS];#endif	/* These three should probably be a union */	struct list_head	i_devices;	struct pipe_inode_info	*i_pipe;	struct block_device	*i_bdev;	struct cdev		*i_cdev;	int			i_cindex;	__u32			i_generation;#ifdef CONFIG_DNOTIFY	unsigned long		i_dnotify_mask; /* Directory notify events */	struct dnotify_struct	*i_dnotify; /* for directory notifications */#endif#ifdef CONFIG_INOTIFY	struct list_head	inotify_watches; /* watches on this inode */	struct semaphore	inotify_sem;	/* protects the watches list */#endif	unsigned long		i_state;	unsigned long		dirtied_when;	/* jiffies of first dirtying */	unsigned int		i_flags;	atomic_t		i_writecount;	void			*i_security;	union {		void		*generic_ip;	} u;#ifdef __NEED_I_SIZE_ORDERED	seqcount_t		i_size_seqcount;#endif};/* * NOTE: in a 32bit arch with a preemptable kernel and * an UP compile the i_size_read/write must be atomic * with respect to the local cpu (unlike with preempt disabled), * but they don't need to be atomic with respect to other cpus like in * true SMP (so they need either to either locally disable irq around * the read or for example on x86 they can be still implemented as a * cmpxchg8b without the need of the lock prefix). For SMP compiles * and 64bit archs it makes no difference if preempt is enabled or not. */static inline loff_t i_size_read(struct inode *inode){#if BITS_PER_LONG==32 && defined(CONFIG_SMP)	loff_t i_size;	unsigned int seq;	do {		seq = read_seqcount_begin(&inode->i_size_seqcount);		i_size = inode->i_size;	} while (read_seqcount_retry(&inode->i_size_seqcount, seq));	return i_size;#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)	loff_t i_size;	preempt_disable();	i_size = inode->i_size;	preempt_enable();	return i_size;#else	return inode->i_size;#endif}static inline void i_size_write(struct inode *inode, loff_t i_size){#if BITS_PER_LONG==32 && defined(CONFIG_SMP)	write_seqcount_begin(&inode->i_size_seqcount);	inode->i_size = i_size;	write_seqcount_end(&inode->i_size_seqcount);#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)	preempt_disable();	inode->i_size = i_size;	preempt_enable();#else	inode->i_size = i_size;#endif}static inline unsigned iminor(struct inode *inode){	return MINOR(inode->i_rdev);}static inline unsigned imajor(struct inode *inode){	return MAJOR(inode->i_rdev);}extern struct block_device *I_BDEV(struct inode *inode);struct fown_struct {	rwlock_t lock;          /* protects pid, uid, euid fields */	int pid;		/* pid or -pgrp where SIGIO should be sent */	uid_t uid, euid;	/* uid/euid of process setting the owner */	void *security;	int signum;		/* posix.1b rt signal to be delivered on IO */};/* * Track a single file's readahead state */struct file_ra_state {	unsigned long start;		/* Current window */	unsigned long size;	unsigned long flags;		/* ra flags RA_FLAG_xxx*/	unsigned long cache_hit;	/* cache hit count*/	unsigned long prev_page;	/* Cache last read() position */	unsigned long ahead_start;	/* Ahead window */	unsigned long ahead_size;	unsigned long ra_pages;		/* Maximum readahead window */	unsigned long mmap_hit;		/* Cache hit stat for mmap accesses */	unsigned long mmap_miss;	/* Cache miss stat for mmap accesses */};#define RA_FLAG_MISS 0x01	/* a cache miss occured against this file */#define RA_FLAG_INCACHE 0x02	/* file is already in cache */struct file {	struct list_head	f_list;	struct dentry		*f_dentry;	struct vfsmount         *f_vfsmnt;	struct file_operations	*f_op;	atomic_t		f_count;	unsigned int 		f_flags;	mode_t			f_mode;	loff_t			f_pos;	struct fown_struct	f_owner;	unsigned int		f_uid, f_gid;	struct file_ra_state	f_ra;	unsigned long		f_version;	void			*f_security;	/* needed for tty driver, and maybe others */	void			*private_data;#ifdef CONFIG_EPOLL	/* Used by fs/eventpoll.c to link all the hooks to this file */	struct list_head	f_ep_links;	spinlock_t		f_ep_lock;#endif /* #ifdef CONFIG_EPOLL */	struct address_space	*f_mapping;	struct rcu_head 	f_rcuhead;};extern spinlock_t files_lock;#define file_list_lock() spin_lock(&files_lock);#define file_list_unlock() spin_unlock(&files_lock);#define get_file(x)	rcuref_inc(&(x)->f_count)#define file_count(x)	atomic_read(&(x)->f_count)#define	MAX_NON_LFS	((1UL<<31) - 1)/* Page cache limit. The filesystems should put that into their s_maxbytes    limits, otherwise bad things can happen in VM. */ #if BITS_PER_LONG==32#define MAX_LFS_FILESIZE	(((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) #elif BITS_PER_LONG==64#define MAX_LFS_FILESIZE 	0x7fffffffffffffffUL#endif#define FL_POSIX	1#define FL_FLOCK	2#define FL_ACCESS	8	/* not trying to lock, just looking */#define FL_LOCKD	16	/* lock held by rpc.lockd */#define FL_LEASE	32	/* lease held on this file */#define FL_SLEEP	128	/* A blocking lock *//* * The POSIX file lock owner is determined by * the "struct files_struct" in the thread group * (or NULL for no owner - BSD locks). * * Lockd stuffs a "host" pointer into this. */typedef struct files_struct *fl_owner_t;struct file_lock_operations {	void (*fl_insert)(struct file_lock *);	/* lock insertion callback */	void (*fl_remove)(struct file_lock *);	/* lock removal callback */	void (*fl_copy_lock)(struct file_lock *, struct file_lock *);	void (*fl_release_private)(struct file_lock *);};struct lock_manager_operations {	int (*fl_compare_owner)(struct file_lock *, struct file_lock *);	void (*fl_notify)(struct file_lock *);	/* unblock callback */	void (*fl_copy_lock)(struct file_lock *, struct file_lock *);	void (*fl_release_private)(struct file_lock *);	void (*fl_break)(struct file_lock *);	int (*fl_mylease)(struct file_lock *, struct file_lock *);	int (*fl_change)(struct file_lock **, int);};/* that will die - we need it for nfs_lock_info */#include <linux/nfs_fs_i.h>struct file_lock {	struct file_lock *fl_next;	/* singly linked list for this inode  */	struct list_head fl_link;	/* doubly linked list of all locks */	struct list_head fl_block;	/* circular list of blocked processes */	fl_owner_t fl_owner;	unsigned int fl_pid;	wait_queue_head_t fl_wait;	struct file *fl_file;	unsigned char fl_flags;	unsigned char fl_type;	loff_t fl_start;	loff_t fl_end;	struct fasync_struct *	fl_fasync; /* for lease break notifications */	unsigned long fl_break_time;	/* for nonblocking lease breaks */	struct file_lock_operations *fl_ops;	/* Callbacks for filesystems */	struct lock_manager_operations *fl_lmops;	/* Callbacks for lockmanagers */	union {		struct nfs_lock_info	nfs_fl;		struct nfs4_lock_info	nfs4_fl;	} fl_u;};/* The following constant reflects the upper bound of the file/locking space */#ifndef OFFSET_MAX#define INT_LIMIT(x)	(~((x)1 << (sizeof(x)*8 - 1)))#define OFFSET_MAX	INT_LIMIT(loff_t)#define OFFT_OFFSET_MAX	INT_LIMIT(off_t)#endifextern struct list_head file_lock_list;#include <linux/fcntl.h>extern int fcntl_getlk(struct file *, struct flock __user *);extern int fcntl_setlk(unsigned int, struct file *, unsigned int,			struct flock __user *);#if BITS_PER_LONG == 32extern int fcntl_getlk64(struct file *, struct flock64 __user *);extern int fcntl_setlk64(unsigned int, struct file *, unsigned int,			struct flock64 __user *);#endifextern void send_sigio(struct fown_struct *fown, int fd, int band);extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);extern int fcntl_getlease(struct file *filp);/* fs/locks.c */extern void locks_init_lock(struct file_lock *);extern void locks_copy_lock(struct file_lock *, struct file_lock *);extern void locks_remove_posix(struct file *, fl_owner_t);

⌨️ 快捷键说明

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