···3939 .d_dname = anon_inodefs_dname,4040};41414242-static struct dentry *anon_inodefs_mount(struct file_system_type *fs_type,4343- int flags, const char *dev_name, void *data)4444-{4545- return mount_pseudo(fs_type, "anon_inode:", NULL,4646- &anon_inodefs_dentry_operations, ANON_INODE_FS_MAGIC);4747-}4848-4949-static struct file_system_type anon_inode_fs_type = {5050- .name = "anon_inodefs",5151- .mount = anon_inodefs_mount,5252- .kill_sb = kill_anon_super,5353-};5454-5542/*5643 * nop .set_page_dirty method so that people can use .page_mkwrite on5744 * anon inodes.···50635164static const struct address_space_operations anon_aops = {5265 .set_page_dirty = anon_set_page_dirty,6666+};6767+6868+/*6969+ * A single inode exists for all anon_inode files. Contrary to pipes,7070+ * anon_inode inodes have no associated per-instance data, so we need7171+ * only allocate one of them.7272+ */7373+static struct inode *anon_inode_mkinode(struct super_block *s)7474+{7575+ struct inode *inode = new_inode_pseudo(s);7676+7777+ if (!inode)7878+ return ERR_PTR(-ENOMEM);7979+8080+ inode->i_ino = get_next_ino();8181+ inode->i_fop = &anon_inode_fops;8282+8383+ inode->i_mapping->a_ops = &anon_aops;8484+8585+ /*8686+ * Mark the inode dirty from the very beginning,8787+ * that way it will never be moved to the dirty8888+ * list because mark_inode_dirty() will think8989+ * that it already _is_ on the dirty list.9090+ */9191+ inode->i_state = I_DIRTY;9292+ inode->i_mode = S_IRUSR | S_IWUSR;9393+ inode->i_uid = current_fsuid();9494+ inode->i_gid = current_fsgid();9595+ inode->i_flags |= S_PRIVATE;9696+ inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;9797+ return inode;9898+}9999+100100+static struct dentry *anon_inodefs_mount(struct file_system_type *fs_type,101101+ int flags, const char *dev_name, void *data)102102+{103103+ struct dentry *root;104104+ root = mount_pseudo(fs_type, "anon_inode:", NULL,105105+ &anon_inodefs_dentry_operations, ANON_INODE_FS_MAGIC);106106+ if (!IS_ERR(root)) {107107+ struct super_block *s = root->d_sb;108108+ anon_inode_inode = anon_inode_mkinode(s);109109+ if (IS_ERR(anon_inode_inode)) {110110+ dput(root);111111+ deactivate_locked_super(s);112112+ root = ERR_CAST(anon_inode_inode);113113+ }114114+ }115115+ return root;116116+}117117+118118+static struct file_system_type anon_inode_fs_type = {119119+ .name = "anon_inodefs",120120+ .mount = anon_inodefs_mount,121121+ .kill_sb = kill_anon_super,53122};5412355124/**···223180}224181EXPORT_SYMBOL_GPL(anon_inode_getfd);225182226226-/*227227- * A single inode exists for all anon_inode files. Contrary to pipes,228228- * anon_inode inodes have no associated per-instance data, so we need229229- * only allocate one of them.230230- */231231-static struct inode *anon_inode_mkinode(void)232232-{233233- struct inode *inode = new_inode_pseudo(anon_inode_mnt->mnt_sb);234234-235235- if (!inode)236236- return ERR_PTR(-ENOMEM);237237-238238- inode->i_ino = get_next_ino();239239- inode->i_fop = &anon_inode_fops;240240-241241- inode->i_mapping->a_ops = &anon_aops;242242-243243- /*244244- * Mark the inode dirty from the very beginning,245245- * that way it will never be moved to the dirty246246- * list because mark_inode_dirty() will think247247- * that it already _is_ on the dirty list.248248- */249249- inode->i_state = I_DIRTY;250250- inode->i_mode = S_IRUSR | S_IWUSR;251251- inode->i_uid = current_fsuid();252252- inode->i_gid = current_fsgid();253253- inode->i_flags |= S_PRIVATE;254254- inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;255255- return inode;256256-}257257-258183static int __init anon_inode_init(void)259184{260185 int error;···235224 error = PTR_ERR(anon_inode_mnt);236225 goto err_unregister_filesystem;237226 }238238- anon_inode_inode = anon_inode_mkinode();239239- if (IS_ERR(anon_inode_inode)) {240240- error = PTR_ERR(anon_inode_inode);241241- goto err_mntput;242242- }243243-244227 return 0;245228246246-err_mntput:247247- kern_unmount(anon_inode_mnt);248229err_unregister_filesystem:249230 unregister_filesystem(&anon_inode_fs_type);250231err_exit: