Commit c44dcc56d2b5c79ba3063d20f76e5347e2e418f6

Authored by Al Viro
1 parent cccc6bba3f

switch inotify_user to anon_inode

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 2 changed files with 6 additions and 54 deletions Side-by-side Diff

fs/notify/inotify/inotify_user.c
... ... @@ -29,14 +29,12 @@
29 29 #include <linux/init.h> /* module_init */
30 30 #include <linux/inotify.h>
31 31 #include <linux/kernel.h> /* roundup() */
32   -#include <linux/magic.h> /* superblock magic number */
33   -#include <linux/mount.h> /* mntget */
34 32 #include <linux/namei.h> /* LOOKUP_FOLLOW */
35   -#include <linux/path.h> /* struct path */
36 33 #include <linux/sched.h> /* struct user */
37 34 #include <linux/slab.h> /* struct kmem_cache */
38 35 #include <linux/syscalls.h>
39 36 #include <linux/types.h>
  37 +#include <linux/anon_inodes.h>
40 38 #include <linux/uaccess.h>
41 39 #include <linux/poll.h>
42 40 #include <linux/wait.h>
... ... @@ -45,8 +43,6 @@
45 43  
46 44 #include <asm/ioctls.h>
47 45  
48   -static struct vfsmount *inotify_mnt __read_mostly;
49   -
50 46 /* these are configurable via /proc/sys/fs/inotify/ */
51 47 static int inotify_max_user_instances __read_mostly;
52 48 static int inotify_max_queued_events __read_mostly;
... ... @@ -645,9 +641,7 @@
645 641 {
646 642 struct fsnotify_group *group;
647 643 struct user_struct *user;
648   - struct file *filp;
649   - struct path path;
650   - int fd, ret;
  644 + int ret;
651 645  
652 646 /* Check the IN_* constants for consistency. */
653 647 BUILD_BUG_ON(IN_CLOEXEC != O_CLOEXEC);
... ... @@ -656,10 +650,6 @@
656 650 if (flags & ~(IN_CLOEXEC | IN_NONBLOCK))
657 651 return -EINVAL;
658 652  
659   - fd = get_unused_fd_flags(flags & O_CLOEXEC);
660   - if (fd < 0)
661   - return fd;
662   -
663 653 user = get_current_user();
664 654 if (unlikely(atomic_read(&user->inotify_devs) >=
665 655 inotify_max_user_instances)) {
666 656  
667 657  
... ... @@ -676,27 +666,14 @@
676 666  
677 667 atomic_inc(&user->inotify_devs);
678 668  
679   - path.mnt = inotify_mnt;
680   - path.dentry = inotify_mnt->mnt_root;
681   - path_get(&path);
682   - filp = alloc_file(&path, FMODE_READ, &inotify_fops);
683   - if (!filp)
684   - goto Enfile;
  669 + ret = anon_inode_getfd("inotify", &inotify_fops, group,
  670 + O_RDONLY | flags);
  671 + if (ret >= 0)
  672 + return ret;
685 673  
686   - filp->f_flags = O_RDONLY | (flags & O_NONBLOCK);
687   - filp->private_data = group;
688   -
689   - fd_install(fd, filp);
690   -
691   - return fd;
692   -
693   -Enfile:
694   - ret = -ENFILE;
695   - path_put(&path);
696 674 atomic_dec(&user->inotify_devs);
697 675 out_free_uid:
698 676 free_uid(user);
699   - put_unused_fd(fd);
700 677 return ret;
701 678 }
702 679  
... ... @@ -783,20 +760,6 @@
783 760 return ret;
784 761 }
785 762  
786   -static int
787   -inotify_get_sb(struct file_system_type *fs_type, int flags,
788   - const char *dev_name, void *data, struct vfsmount *mnt)
789   -{
790   - return get_sb_pseudo(fs_type, "inotify", NULL,
791   - INOTIFYFS_SUPER_MAGIC, mnt);
792   -}
793   -
794   -static struct file_system_type inotify_fs_type = {
795   - .name = "inotifyfs",
796   - .get_sb = inotify_get_sb,
797   - .kill_sb = kill_anon_super,
798   -};
799   -
800 763 /*
801 764 * inotify_user_setup - Our initialization function. Note that we cannnot return
802 765 * error because we have compiled-in VFS hooks. So an (unlikely) failure here
... ... @@ -804,16 +767,6 @@
804 767 */
805 768 static int __init inotify_user_setup(void)
806 769 {
807   - int ret;
808   -
809   - ret = register_filesystem(&inotify_fs_type);
810   - if (unlikely(ret))
811   - panic("inotify: register_filesystem returned %d!\n", ret);
812   -
813   - inotify_mnt = kern_mount(&inotify_fs_type);
814   - if (IS_ERR(inotify_mnt))
815   - panic("inotify: kern_mount ret %ld!\n", PTR_ERR(inotify_mnt));
816   -
817 770 inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark_entry, SLAB_PANIC);
818 771 event_priv_cachep = KMEM_CACHE(inotify_event_private_data, SLAB_PANIC);
819 772  
include/linux/magic.h
... ... @@ -52,7 +52,6 @@
52 52 #define CGROUP_SUPER_MAGIC 0x27e0eb
53 53  
54 54 #define FUTEXFS_SUPER_MAGIC 0xBAD1DEA
55   -#define INOTIFYFS_SUPER_MAGIC 0x2BAD1DEA
56 55  
57 56 #define STACK_END_MAGIC 0x57AC6E9D
58 57