📄 fs.h
字号:
union { struct list_head fu_list; struct rcu_head fu_rcuhead; } f_u; struct path f_path;#define f_dentry f_path.dentry#define f_vfsmnt f_path.mnt const 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;#ifdef CONFIG_SECURITY void *f_security;#endif /* 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_EXISTS 16 /* when unlocking, test for existence */#define FL_LEASE 32 /* lease held on this file */#define FL_CLOSE 64 /* unlock on close */#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)#endif#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/sync.c */extern int do_sync_file_range(struct file *file, loff_t offset, loff_t endbyte, unsigned int flags);/* 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 int posix_test_lock(struct file *, struct file_lock *, struct file_lock *);extern int posix_lock_file_conf(struct file *, struct file_lock *, 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 int posix_unblock_lock(struct file *, 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 setlease(struct file *, long, struct file_lock **);extern int lease_modify(struct file_lock **, int);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);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, struct pid *, enum pid_type, int force);extern int f_setown(struct file *filp, unsigned long arg, int force);extern void f_delown(struct file *filp);extern pid_t f_getown(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 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 mutex s_lock; int s_count; int s_syncing; int s_need_sync_fs; atomic_t s_active;#ifdef CONFIG_SECURITY void *s_security;#endif struct xattr_handler **s_xattr; struct list_head s_inodes; /* all inodes */ 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 mutex s_vfs_rename_mutex; /* Kludge */ /* Granularity of c/m/atime in ns. Cannot be worse than a second */ u32 s_time_gran;};extern struct timespec current_fs_time(struct super_block *sb);/* * 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)))#define get_fs_excl() atomic_inc(¤t->fs_excl)#define put_fs_excl() atomic_dec(¤t->fs_excl)#define has_fs_excl() atomic_read(¤t->fs_excl)/* not quite ready to be deprecated, but... */extern void lock_super(struct super_block *);extern void unlock_super(struct super_block *);/* * VFS helper functions.. */extern int vfs_permission(struct nameidata *, int);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. */extern void dentry_unhash(struct dentry *dentry);/* * VFS file helper functions. */extern int file_permission(struct file *, int);/* * File types * * NOTE! These match bits 12..15 of stat.st_mode * (ie "(i_mode >> 12) & 15"). */#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#define OSYNC_METADATA (1<<0)#define OSYNC_DATA (1<<1)#define OSYNC_INODE (1<<2)int generic_osync_inode(struct inode *, struct address_space *, int);/* * 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, loff_t, u64, 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); long (*unlocked_ioctl) (struct file *, unsigned, unsigned long); long (*compat_ioctl) (struct file *, unsigned, unsigned long); int (*direct_access) (struct block_device *, sector_t, unsigned long *); int (*media_changed) (struct gendisk *); int (*revalidate_disk) (struct gendisk *); int (*getgeo)(struct block_device *, struct hd_geometry *); struct module *owner;};/* * "descriptor" for what we're up to with a read for sendfile(). * This allows us to use the same read code yet * have multiple different users of the data that * we read from a file. * * The simplest case just copies the data to user * mode. */typedef struct { size_t written; size_t count; union { char __user * buf; void *data; } arg; int error;} read_descriptor_t;typedef int (*read_actor_t)(read_descriptor_t *, struct page *, unsigned long, unsigned long);/* These macros are for out of kernel modules to test that * the kernel supports the unlocked_ioctl and compat_ioctl * fields in struct file_operations. */#define HAVE_COMPAT_IOCTL 1#define HAVE_UNLOCKED_IOCTL 1/* * NOTE:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -