pidfd: add pidfs
[linux-2.6-block.git] / kernel / fork.c
index 662a61f340ce86bb97e0f2669ccaa268cf623a83..2f839c290dcf2967ede43ed6d1fe039daa015bc2 100644 (file)
 #include <linux/iommu.h>
 #include <linux/rseq.h>
 #include <uapi/linux/pidfd.h>
+#include <linux/pidfs.h>
 
 #include <asm/pgalloc.h>
 #include <linux/uaccess.h>
@@ -1985,14 +1986,6 @@ static inline void rcu_copy_process(struct task_struct *p)
 #endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
 }
 
-struct pid *pidfd_pid(const struct file *file)
-{
-       if (file->f_op == &pidfd_fops)
-               return file->private_data;
-
-       return ERR_PTR(-EBADF);
-}
-
 /**
  * __pidfd_prepare - allocate a new pidfd_file and reserve a pidfd
  * @pid:   the struct pid for which to create a pidfd
@@ -2030,13 +2023,11 @@ static int __pidfd_prepare(struct pid *pid, unsigned int flags, struct file **re
        if (pidfd < 0)
                return pidfd;
 
-       pidfd_file = anon_inode_getfile("[pidfd]", &pidfd_fops, pid,
-                                       flags | O_RDWR);
+       pidfd_file = pidfs_alloc_file(pid, flags | O_RDWR);
        if (IS_ERR(pidfd_file)) {
                put_unused_fd(pidfd);
                return PTR_ERR(pidfd_file);
        }
-       get_pid(pid); /* held by pidfd_file now */
        /*
         * anon_inode_getfile() ignores everything outside of the
         * O_ACCMODE | O_NONBLOCK mask, set PIDFD_THREAD manually.