[vfs:work.open 39/44] fs/file_table.c:185:14: error: conflicting types for 'alloc_file_pseudo'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.open
head:   956b068e4bed1c13d0218ea7afaaa9ea0d345fc2
commit: 2e0cc644dea0b2f616879145cc0dd6c43373c475 [39/44] new wrapper: alloc_file_pseudo()
config: i386-tinyconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        git checkout 2e0cc644dea0b2f616879145cc0dd6c43373c475
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   In file included from fs/file_table.c:10:0:
   include/linux/file.h:23:46: warning: 'struct inode' declared inside parameter list will not be visible outside of this definition or declaration
    extern struct file *alloc_file_pseudo(struct inode *, struct vfsmount *,
                                                 ^~~~~
>> fs/file_table.c:185:14: error: conflicting types for 'alloc_file_pseudo'
    struct file *alloc_file_pseudo(struct inode *inode, struct vfsmount *mnt,
                 ^~~~~~~~~~~~~~~~~
   In file included from fs/file_table.c:10:0:
   include/linux/file.h:23:21: note: previous declaration of 'alloc_file_pseudo' was here
    extern struct file *alloc_file_pseudo(struct inode *, struct vfsmount *,
                        ^~~~~~~~~~~~~~~~~

vim +/alloc_file_pseudo +185 fs/file_table.c

  > 10	#include <linux/file.h>
    11	#include <linux/fdtable.h>
    12	#include <linux/init.h>
    13	#include <linux/module.h>
    14	#include <linux/fs.h>
    15	#include <linux/security.h>
    16	#include <linux/cred.h>
    17	#include <linux/eventpoll.h>
    18	#include <linux/rcupdate.h>
    19	#include <linux/mount.h>
    20	#include <linux/capability.h>
    21	#include <linux/cdev.h>
    22	#include <linux/fsnotify.h>
    23	#include <linux/sysctl.h>
    24	#include <linux/percpu_counter.h>
    25	#include <linux/percpu.h>
    26	#include <linux/task_work.h>
    27	#include <linux/ima.h>
    28	#include <linux/swap.h>
    29	
    30	#include <linux/atomic.h>
    31	
    32	#include "internal.h"
    33	
    34	/* sysctl tunables... */
    35	struct files_stat_struct files_stat = {
    36		.max_files = NR_FILE
    37	};
    38	
    39	/* SLAB cache for file structures */
    40	static struct kmem_cache *filp_cachep __read_mostly;
    41	
    42	static struct percpu_counter nr_files __cacheline_aligned_in_smp;
    43	
    44	static void file_free_rcu(struct rcu_head *head)
    45	{
    46		struct file *f = container_of(head, struct file, f_u.fu_rcuhead);
    47	
    48		put_cred(f->f_cred);
    49		kmem_cache_free(filp_cachep, f);
    50	}
    51	
    52	static inline void file_free(struct file *f)
    53	{
    54		percpu_counter_dec(&nr_files);
    55		call_rcu(&f->f_u.fu_rcuhead, file_free_rcu);
    56	}
    57	
    58	/*
    59	 * Return the total number of open files in the system
    60	 */
    61	static long get_nr_files(void)
    62	{
    63		return percpu_counter_read_positive(&nr_files);
    64	}
    65	
    66	/*
    67	 * Return the maximum number of open files in the system
    68	 */
    69	unsigned long get_max_files(void)
    70	{
    71		return files_stat.max_files;
    72	}
    73	EXPORT_SYMBOL_GPL(get_max_files);
    74	
    75	/*
    76	 * Handle nr_files sysctl
    77	 */
    78	#if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
    79	int proc_nr_files(struct ctl_table *table, int write,
    80	                     void __user *buffer, size_t *lenp, loff_t *ppos)
    81	{
    82		files_stat.nr_files = get_nr_files();
    83		return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
    84	}
    85	#else
    86	int proc_nr_files(struct ctl_table *table, int write,
    87	                     void __user *buffer, size_t *lenp, loff_t *ppos)
    88	{
    89		return -ENOSYS;
    90	}
    91	#endif
    92	
    93	/* Find an unused file structure and return a pointer to it.
    94	 * Returns an error pointer if some error happend e.g. we over file
    95	 * structures limit, run out of memory or operation is not permitted.
    96	 *
    97	 * Be very careful using this.  You are responsible for
    98	 * getting write access to any mount that you might assign
    99	 * to this filp, if it is opened for write.  If this is not
   100	 * done, you will imbalance int the mount's writer count
   101	 * and a warning at __fput() time.
   102	 */
   103	struct file *get_empty_filp(void)
   104	{
   105		const struct cred *cred = current_cred();
   106		static long old_max;
   107		struct file *f;
   108		int error;
   109	
   110		/*
   111		 * Privileged users can go above max_files
   112		 */
   113		if (get_nr_files() >= files_stat.max_files && !capable(CAP_SYS_ADMIN)) {
   114			/*
   115			 * percpu_counters are inaccurate.  Do an expensive check before
   116			 * we go and fail.
   117			 */
   118			if (percpu_counter_sum_positive(&nr_files) >= files_stat.max_files)
   119				goto over;
   120		}
   121	
   122		f = kmem_cache_zalloc(filp_cachep, GFP_KERNEL);
   123		if (unlikely(!f))
   124			return ERR_PTR(-ENOMEM);
   125	
   126		percpu_counter_inc(&nr_files);
   127		f->f_cred = get_cred(cred);
   128		error = security_file_alloc(f);
   129		if (unlikely(error)) {
   130			file_free(f);
   131			return ERR_PTR(error);
   132		}
   133	
   134		atomic_long_set(&f->f_count, 1);
   135		rwlock_init(&f->f_owner.lock);
   136		spin_lock_init(&f->f_lock);
   137		mutex_init(&f->f_pos_lock);
   138		eventpoll_init_file(f);
   139		/* f->f_version: 0 */
   140		return f;
   141	
   142	over:
   143		/* Ran out of filps - report that */
   144		if (get_nr_files() > old_max) {
   145			pr_info("VFS: file-max limit %lu reached\n", get_max_files());
   146			old_max = get_nr_files();
   147		}
   148		return ERR_PTR(-ENFILE);
   149	}
   150	
   151	/**
   152	 * alloc_file - allocate and initialize a 'struct file'
   153	 *
   154	 * @path: the (dentry, vfsmount) pair for the new file
   155	 * @mode: the mode with which the new file will be opened
   156	 * @fop: the 'struct file_operations' for the new file
   157	 */
   158	struct file *alloc_file(const struct path *path, fmode_t mode,
   159			const struct file_operations *fop)
   160	{
   161		struct file *file;
   162	
   163		file = get_empty_filp();
   164		if (IS_ERR(file))
   165			return file;
   166	
   167		file->f_path = *path;
   168		file->f_inode = path->dentry->d_inode;
   169		file->f_mapping = path->dentry->d_inode->i_mapping;
   170		file->f_wb_err = filemap_sample_wb_err(file->f_mapping);
   171		if ((mode & FMODE_READ) &&
   172		     likely(fop->read || fop->read_iter))
   173			mode |= FMODE_CAN_READ;
   174		if ((mode & FMODE_WRITE) &&
   175		     likely(fop->write || fop->write_iter))
   176			mode |= FMODE_CAN_WRITE;
   177		file->f_mode = mode;
   178		file->f_op = fop;
   179		if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
   180			i_readcount_inc(path->dentry->d_inode);
   181		return file;
   182	}
   183	EXPORT_SYMBOL(alloc_file);
   184	
 > 185	struct file *alloc_file_pseudo(struct inode *inode, struct vfsmount *mnt,
   186					const char *name, fmode_t mode,
   187					const struct file_operations *fops)
   188	{
   189		static const struct dentry_operations anon_ops = {
   190			.d_dname = simple_dname
   191		};
   192		struct qstr this = QSTR_INIT(name, strlen(name));
   193		struct path path;
   194		struct file *file;
   195	
   196		path.dentry = d_alloc_pseudo(mnt->mnt_sb, &this);
   197		if (!path.dentry)
   198			return ERR_PTR(-ENOMEM);
   199		if (!mnt->mnt_sb->s_d_op)
   200			d_set_d_op(path.dentry, &anon_ops);
   201		path.mnt = mntget(mnt);
   202		d_instantiate(path.dentry, inode);
   203		file = alloc_file(&path, mode | FMODE_OPENED, fops);
   204		if (IS_ERR(file)) {
   205			ihold(inode);
   206			path_put(&path);
   207		}
   208		return file;
   209	}
   210	EXPORT_SYMBOL(alloc_file_pseudo);
   211	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux