diff options
Diffstat (limited to 'fs/anon_inodes.c')
| -rw-r--r-- | fs/anon_inodes.c | 146 | 
1 files changed, 8 insertions, 138 deletions
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c index 85c96184995..80ef38c73e5 100644 --- a/fs/anon_inodes.c +++ b/fs/anon_inodes.c @@ -24,7 +24,6 @@  static struct vfsmount *anon_inode_mnt __read_mostly;  static struct inode *anon_inode_inode; -static const struct file_operations anon_inode_fops;  /*   * anon_inodefs_dname() is called from d_path(). @@ -39,67 +38,11 @@ static const struct dentry_operations anon_inodefs_dentry_operations = {  	.d_dname	= anon_inodefs_dname,  }; -/* - * nop .set_page_dirty method so that people can use .page_mkwrite on - * anon inodes. - */ -static int anon_set_page_dirty(struct page *page) -{ -	return 0; -}; - -static const struct address_space_operations anon_aops = { -	.set_page_dirty = anon_set_page_dirty, -}; - -/* - * A single inode exists for all anon_inode files. Contrary to pipes, - * anon_inode inodes have no associated per-instance data, so we need - * only allocate one of them. - */ -static struct inode *anon_inode_mkinode(struct super_block *s) -{ -	struct inode *inode = new_inode_pseudo(s); - -	if (!inode) -		return ERR_PTR(-ENOMEM); - -	inode->i_ino = get_next_ino(); -	inode->i_fop = &anon_inode_fops; - -	inode->i_mapping->a_ops = &anon_aops; - -	/* -	 * Mark the inode dirty from the very beginning, -	 * that way it will never be moved to the dirty -	 * list because mark_inode_dirty() will think -	 * that it already _is_ on the dirty list. -	 */ -	inode->i_state = I_DIRTY; -	inode->i_mode = S_IRUSR | S_IWUSR; -	inode->i_uid = current_fsuid(); -	inode->i_gid = current_fsgid(); -	inode->i_flags |= S_PRIVATE; -	inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; -	return inode; -} -  static struct dentry *anon_inodefs_mount(struct file_system_type *fs_type,  				int flags, const char *dev_name, void *data)  { -	struct dentry *root; -	root = mount_pseudo(fs_type, "anon_inode:", NULL, +	return mount_pseudo(fs_type, "anon_inode:", NULL,  			&anon_inodefs_dentry_operations, ANON_INODE_FS_MAGIC); -	if (!IS_ERR(root)) { -		struct super_block *s = root->d_sb; -		anon_inode_inode = anon_inode_mkinode(s); -		if (IS_ERR(anon_inode_inode)) { -			dput(root); -			deactivate_locked_super(s); -			root = ERR_CAST(anon_inode_inode); -		} -	} -	return root;  }  static struct file_system_type anon_inode_fs_type = { @@ -109,72 +52,6 @@ static struct file_system_type anon_inode_fs_type = {  };  /** - * anon_inode_getfile_private - creates a new file instance by hooking it up to an - *                      anonymous inode, and a dentry that describe the "class" - *                      of the file - * - * @name:    [in]    name of the "class" of the new file - * @fops:    [in]    file operations for the new file - * @priv:    [in]    private data for the new file (will be file's private_data) - * @flags:   [in]    flags - * - * - * Similar to anon_inode_getfile, but each file holds a single inode. - * - */ -struct file *anon_inode_getfile_private(const char *name, -					const struct file_operations *fops, -					void *priv, int flags) -{ -	struct qstr this; -	struct path path; -	struct file *file; -	struct inode *inode; - -	if (fops->owner && !try_module_get(fops->owner)) -		return ERR_PTR(-ENOENT); - -	inode = anon_inode_mkinode(anon_inode_mnt->mnt_sb); -	if (IS_ERR(inode)) { -		file = ERR_PTR(-ENOMEM); -		goto err_module; -	} - -	/* -	 * Link the inode to a directory entry by creating a unique name -	 * using the inode sequence number. -	 */ -	file = ERR_PTR(-ENOMEM); -	this.name = name; -	this.len = strlen(name); -	this.hash = 0; -	path.dentry = d_alloc_pseudo(anon_inode_mnt->mnt_sb, &this); -	if (!path.dentry) -		goto err_module; - -	path.mnt = mntget(anon_inode_mnt); - -	d_instantiate(path.dentry, inode); - -	file = alloc_file(&path, OPEN_FMODE(flags), fops); -	if (IS_ERR(file)) -		goto err_dput; - -	file->f_mapping = inode->i_mapping; -	file->f_flags = flags & (O_ACCMODE | O_NONBLOCK); -	file->private_data = priv; - -	return file; - -err_dput: -	path_put(&path); -err_module: -	module_put(fops->owner); -	return file; -} -EXPORT_SYMBOL_GPL(anon_inode_getfile_private); - -/**   * anon_inode_getfile - creates a new file instance by hooking it up to an   *                      anonymous inode, and a dentry that describe the "class"   *                      of the file @@ -287,22 +164,15 @@ EXPORT_SYMBOL_GPL(anon_inode_getfd);  static int __init anon_inode_init(void)  { -	int error; - -	error = register_filesystem(&anon_inode_fs_type); -	if (error) -		goto err_exit;  	anon_inode_mnt = kern_mount(&anon_inode_fs_type); -	if (IS_ERR(anon_inode_mnt)) { -		error = PTR_ERR(anon_inode_mnt); -		goto err_unregister_filesystem; -	} -	return 0; +	if (IS_ERR(anon_inode_mnt)) +		panic("anon_inode_init() kernel mount failed (%ld)\n", PTR_ERR(anon_inode_mnt)); -err_unregister_filesystem: -	unregister_filesystem(&anon_inode_fs_type); -err_exit: -	panic(KERN_ERR "anon_inode_init() failed (%d)\n", error); +	anon_inode_inode = alloc_anon_inode(anon_inode_mnt->mnt_sb); +	if (IS_ERR(anon_inode_inode)) +		panic("anon_inode_init() inode allocation failed (%ld)\n", PTR_ERR(anon_inode_inode)); + +	return 0;  }  fs_initcall(anon_inode_init);  | 
