fs.h
来自「Linux Kernel 2.6.9 for OMAP1710」· C头文件 代码 · 共 1,645 行 · 第 1/4 页
H
1,645 行
#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_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; unsigned char i_sock; 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; unsigned long i_dnotify_mask; /* Directory notify events */ struct dnotify_struct *i_dnotify; /* for directory notifications */ 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 next_size; /* Next window size */ unsigned long prev_page; /* Cache last read() position */ unsigned long ahead_start; /* Ahead window */ unsigned long ahead_size; unsigned long currnt_wnd_hit; /* locality in the current window */ unsigned long average; /* size of next current window */ 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 */};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; int f_error; 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;};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) atomic_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 */};/* 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; } 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(struct file *, unsigned int, struct flock __user *);#if BITS_PER_LONG == 32extern int fcntl_getlk64(struct file *, struct flock64 __user *);extern int fcntl_setlk64(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);extern void locks_remove_flock(struct file *);extern struct file_lock *posix_test_lock(struct file *, struct file_lock *);extern int posix_lock_file(struct file *, struct file_lock *);extern int posix_lock_file_wait(struct file *, struct file_lock *);extern void posix_block_lock(struct file_lock *, struct file_lock *);extern void posix_unblock_lock(struct file *, struct file_lock *);extern int posix_locks_deadlock(struct file_lock *, struct file_lock *);extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);extern int __break_lease(struct inode *inode, unsigned int flags);extern void lease_get_mtime(struct inode *, struct timespec *time);extern int lock_may_read(struct inode *, loff_t start, unsigned long count);extern int lock_may_write(struct inode *, loff_t start, unsigned long count);extern void steal_locks(fl_owner_t from);struct fasync_struct { int magic; int fa_fd; struct fasync_struct *fa_next; /* singly linked list */ struct file *fa_file;};#define FASYNC_MAGIC 0x4601/* SMP safe fasync helpers: */extern int fasync_helper(int, struct file *, int, struct fasync_struct **);/* can be called from interrupts */extern void kill_fasync(struct fasync_struct **, int, int);/* only for net: no internal synchronization */extern void __kill_fasync(struct fasync_struct *, int, int);extern int f_setown(struct file *filp, unsigned long arg, int force);extern void f_delown(struct file *filp);extern int send_sigurg(struct fown_struct *fown);/* * Umount options */#define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */#define MNT_DETACH 0x00000002 /* Just detach from the tree */#define MNT_EXPIRE 0x00000004 /* Mark for expiry */extern struct list_head super_blocks;extern spinlock_t sb_lock;#define sb_entry(list) list_entry((list), struct super_block, s_list)#define S_BIAS (1<<30)struct super_block { struct list_head s_list; /* Keep this first */ dev_t s_dev; /* search index; _not_ kdev_t */ unsigned long s_blocksize; unsigned long s_old_blocksize; unsigned char s_blocksize_bits; unsigned char s_dirt; unsigned long long s_maxbytes; /* Max file size */ struct file_system_type *s_type; struct super_operations *s_op; struct dquot_operations *dq_op; struct quotactl_ops *s_qcop; struct export_operations *s_export_op; unsigned long s_flags; unsigned long s_magic; struct dentry *s_root; struct rw_semaphore s_umount; struct semaphore s_lock; int s_count; int s_syncing; int s_need_sync_fs; atomic_t s_active; void *s_security; struct list_head s_dirty; /* dirty inodes */ struct list_head s_io; /* parked for writeback */ struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */ struct list_head s_files; struct block_device *s_bdev; struct list_head s_instances; struct quota_info s_dquot; /* Diskquota specific options */ int s_frozen; wait_queue_head_t s_wait_unfrozen; char s_id[32]; /* Informational name */ void *s_fs_info; /* Filesystem private info */ /* * The next field is for VFS *only*. No filesystems have any business * even looking at it. You had been warned. */ struct semaphore s_vfs_rename_sem; /* Kludge */};/* * Snapshotting support. */enum { SB_UNFROZEN = 0, SB_FREEZE_WRITE = 1, SB_FREEZE_TRANS = 2,};#define vfs_check_frozen(sb, level) \ wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level)))/* * Superblock locking. */static inline void lock_super(struct super_block * sb){ down(&sb->s_lock);}static inline void unlock_super(struct super_block * sb){ up(&sb->s_lock);}/* * VFS helper functions.. */extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);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 *, int);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 *);/* * VFS dentry helper functions. */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?