fs.h

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

H
1,770
字号
static inline void touch_atime(struct vfsmount *mnt, struct dentry *dentry){	/* per-mountpoint checks will go here */	update_atime(dentry->d_inode);}static inline void file_accessed(struct file *file){	if (!(file->f_flags & O_NOATIME))		touch_atime(file->f_vfsmnt, file->f_dentry);}int sync_inode(struct inode *inode, struct writeback_control *wbc);/** * struct export_operations - for nfsd to communicate with file systems * @decode_fh:      decode a file handle fragment and return a &struct dentry * @encode_fh:      encode a file handle fragment from a dentry * @get_name:       find the name for a given inode in a given directory * @get_parent:     find the parent of a given directory * @get_dentry:     find a dentry for the inode given a file handle sub-fragment * * Description: *    The export_operations structure provides a means for nfsd to communicate *    with a particular exported file system  - particularly enabling nfsd and *    the filesystem to co-operate when dealing with file handles. * *    export_operations contains two basic operation for dealing with file *    handles, decode_fh() and encode_fh(), and allows for some other *    operations to be defined which standard helper routines use to get *    specific information from the filesystem. * *    nfsd encodes information use to determine which filesystem a filehandle *    applies to in the initial part of the file handle.  The remainder, termed *    a file handle fragment, is controlled completely by the filesystem.  The *    standard helper routines assume that this fragment will contain one or *    two sub-fragments, one which identifies the file, and one which may be *    used to identify the (a) directory containing the file. * *    In some situations, nfsd needs to get a dentry which is connected into a *    specific part of the file tree.  To allow for this, it passes the *    function acceptable() together with a @context which can be used to see *    if the dentry is acceptable.  As there can be multiple dentrys for a *    given file, the filesystem should check each one for acceptability before *    looking for the next.  As soon as an acceptable one is found, it should *    be returned. * * decode_fh: *    @decode_fh is given a &struct super_block (@sb), a file handle fragment *    (@fh, @fh_len) and an acceptability testing function (@acceptable, *    @context).  It should return a &struct dentry which refers to the same *    file that the file handle fragment refers to,  and which passes the *    acceptability test.  If it cannot, it should return a %NULL pointer if *    the file was found but no acceptable &dentries were available, or a *    %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or *    %ENOMEM). * * encode_fh: *    @encode_fh should store in the file handle fragment @fh (using at most *    @max_len bytes) information that can be used by @decode_fh to recover the *    file refered to by the &struct dentry @de.  If the @connectable flag is *    set, the encode_fh() should store sufficient information so that a good *    attempt can be made to find not only the file but also it's place in the *    filesystem.   This typically means storing a reference to de->d_parent in *    the filehandle fragment.  encode_fh() should return the number of bytes *    stored or a negative error code such as %-ENOSPC * * get_name: *    @get_name should find a name for the given @child in the given @parent *    directory.  The name should be stored in the @name (with the *    understanding that it is already pointing to a a %NAME_MAX+1 sized *    buffer.   get_name() should return %0 on success, a negative error code *    or error.  @get_name will be called without @parent->i_sem held. * * get_parent: *    @get_parent should find the parent directory for the given @child which *    is also a directory.  In the event that it cannot be found, or storage *    space cannot be allocated, a %ERR_PTR should be returned. * * get_dentry: *    Given a &super_block (@sb) and a pointer to a file-system specific inode *    identifier, possibly an inode number, (@inump) get_dentry() should find *    the identified inode and return a dentry for that inode.  Any suitable *    dentry can be returned including, if necessary, a new dentry created with *    d_alloc_root.  The caller can then find any other extant dentrys by *    following the d_alias links.  If a new dentry was created using *    d_alloc_root, DCACHE_NFSD_DISCONNECTED should be set, and the dentry *    should be d_rehash()ed. * *    If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code *    can be returned.  The @inump will be whatever was passed to *    nfsd_find_fh_dentry() in either the @obj or @parent parameters. * * Locking rules: *    get_parent is called with child->d_inode->i_sem down *    get_name is not (which is possibly inconsistent) */struct export_operations {	struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, int fh_len, int fh_type,			 int (*acceptable)(void *context, struct dentry *de),			 void *context);	int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len,			 int connectable);	/* the following are only called from the filesystem itself */	int (*get_name)(struct dentry *parent, char *name,			struct dentry *child);	struct dentry * (*get_parent)(struct dentry *child);	struct dentry * (*get_dentry)(struct super_block *sb, void *inump);	/* This is set by the exporting module to a standard helper */	struct dentry * (*find_exported_dentry)(		struct super_block *sb, void *obj, void *parent,		int (*acceptable)(void *context, struct dentry *de),		void *context);};extern struct dentry *find_exported_dentry(struct super_block *sb, void *obj, void *parent,		     int (*acceptable)(void *context, struct dentry *de),		     void *context);struct file_system_type {	const char *name;	int fs_flags;	struct super_block *(*get_sb) (struct file_system_type *, int,				       const char *, void *);	void (*kill_sb) (struct super_block *);	struct module *owner;	struct file_system_type * next;	struct list_head fs_supers;};struct super_block *get_sb_bdev(struct file_system_type *fs_type,	int flags, const char *dev_name, void *data,	int (*fill_super)(struct super_block *, void *, int));struct super_block *get_sb_single(struct file_system_type *fs_type,	int flags, void *data,	int (*fill_super)(struct super_block *, void *, int));struct super_block *get_sb_nodev(struct file_system_type *fs_type,	int flags, void *data,	int (*fill_super)(struct super_block *, void *, int));void generic_shutdown_super(struct super_block *sb);void kill_block_super(struct super_block *sb);void kill_anon_super(struct super_block *sb);void kill_litter_super(struct super_block *sb);void deactivate_super(struct super_block *sb);int set_anon_super(struct super_block *s, void *data);struct super_block *sget(struct file_system_type *type,			int (*test)(struct super_block *,void *),			int (*set)(struct super_block *,void *),			void *data);struct super_block *get_sb_pseudo(struct file_system_type *, char *,			struct super_operations *ops, unsigned long);int __put_super(struct super_block *sb);int __put_super_and_need_restart(struct super_block *sb);void unnamed_dev_init(void);/* Alas, no aliases. Too much hassle with bringing module.h everywhere */#define fops_get(fops) \	(((fops) && try_module_get((fops)->owner) ? (fops) : NULL))#define fops_put(fops) \	do { if (fops) module_put((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 int may_umount_tree(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 kstatfs *);#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;}extern int rw_verify_area(int, struct file *, loff_t *, size_t);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;}static inline int break_lease(struct inode *inode, unsigned int mode){	if (inode->i_flock)		return __break_lease(inode, mode);	return 0;}/* fs/open.c */extern int do_truncate(struct dentry *, loff_t start);extern long do_sys_open(const char __user *filename, int flags, int mode);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 __user *);/* fs/dcache.c */extern void __init vfs_caches_init_early(void);extern void __init vfs_caches_init(unsigned long);#define __getname()	kmem_cache_alloc(names_cachep, SLAB_KERNEL)#define __putname(name) kmem_cache_free(names_cachep, (void *)(name))#ifndef CONFIG_AUDITSYSCALL#define putname(name)   __putname(name)#elseextern void putname(const char *name);#endifextern int register_blkdev(unsigned int, const char *);extern int unregister_blkdev(unsigned int, const char *);extern struct block_device *bdget(dev_t);extern void bd_set_size(struct block_device *, loff_t size);extern void bd_forget(struct inode *inode);extern void bdput(struct block_device *);extern struct block_device *open_by_devnum(dev_t, unsigned);extern struct file_operations def_blk_fops;extern struct address_space_operations def_blk_aops;extern struct file_operations def_chr_fops;extern struct file_operations bad_sock_fops;extern struct file_operations def_fifo_fops;extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long);extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);extern int blkdev_get(struct block_device *, mode_t, unsigned);extern int blkdev_put(struct block_device *);extern int bd_claim(struct block_device *, void *);extern void bd_release(struct block_device *);/* fs/char_dev.c */extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);extern int register_chrdev_region(dev_t, unsigned, const char *);extern int register_chrdev(unsigned int, const char *,			   struct file_operations *);extern int unregister_chrdev(unsigned int, const char *);extern void unregister_chrdev_region(dev_t, unsigned);extern int chrdev_open(struct inode *, struct file *);/* fs/block_dev.c */#define BDEVNAME_SIZE	32	/* Largest string for a blockdev identifier */extern const char *__bdevname(dev_t, char *buffer);extern const char *bdevname(struct block_device *bdev, char *buffer);extern struct block_device *lookup_bdev(const char *);extern struct block_device *open_bdev_excl(const char *, int, void *);extern void close_bdev_excl(struct block_device *);extern void init_special_inode(struct inode *, umode_t, dev_t);/* 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 *);/* * return READ, READA, or WRITE */#define bio_rw(bio)		((bio)->bi_rw & (RW_MASK | RWA_MASK))/* * return data direction, READ or WRITE */#define bio_data_dir(bio)	((bio)->bi_rw & 1)extern int check_disk_change(struct block_device *);extern int invalidate_inodes(struct super_block *);extern int __invalidate_device(struct block_device *);extern int invalidate_partition(struct gendisk *, int);unsigned long invalidate_mapping_pages(struct address_space *mapping,					pgoff_t start, pgoff_t end);unsigned long invalidate_inode_pages(struct address_space *mapping);static inline void invalidate_remote_inode(struct inode *inode){	if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||	    S_ISLNK(inode->i_mode))		invalidate_inode_pages(inode->i_mapping);}extern int invalidate_inode_pages2(struct address_space *mapping);extern int invalidate_inode_pages2_range(struct address_space *mapping,					 pgoff_t start, pgoff_t end);extern int write_inode_now(struct inode *, int);extern int filemap_fdatawrite(struct address_space *);extern int filemap_flush(struct address_space *);extern int filemap_fdatawait(struct address_space *);extern int filemap_write_and_wait(struct address_space *mapping);extern int filemap_write_and_wait_range(struct address_space *mapping,				        loff_t lstart, loff_t lend);extern void sync_supers(void);extern void sync_filesystems(int wait);extern void emergency_sync(void);extern void emergency_remount(void);extern int do_remount_sb(struct super_block *sb, int flags,			 void *data, int force);extern sector_t bmap(struct inode *, sector_t);extern int notify_change(struct dentry *, struct iattr *);extern int permission(struct inode *, int, struct nameidata *);extern int generic_permission(struct inode *, int,		int (*check_acl)(struct inode *, int));extern int get_write_access(struct inode *);extern int deny_write_access(struct file *);static inline void put_write_access(struct inode * inode){	atomic_dec(&inode->i_writecount);}static inline void allow_write_access(struct file *file){	if (file)		atomic_inc(&file->f_dentry->d_inode->i_writecount);}extern int do_pipe(int *);extern int open_namei(const char *, int, int, struct nameidata *);extern int may_open(struct nameidata *, int, int);

⌨️ 快捷键说明

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