History

pid: move pidfd_get_pid() to pid.c

process_madvise syscall needs pidfd_get_pid function to translate pidfd to pid so this patch move the function to kernel/pid.c.

Minchan Kim committed 6 years ago

Commit 1aa92cd1 parent 0726b013 files · +20 −19Browse files

Unified · Split

3 files
  1. include/linux/pid.h +1 −0
  2. kernel/exit.c +0 −19
  3. kernel/pid.c +19 −0
include/linux/pid.h+1−0
@@ -77,6 +77,7 @@ extern const struct file_operations pidfd_fops; · 76 unmodified lines
7777 struct file;
7878
7979 extern struct pid *pidfd_pid(const struct file *file);
80+struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags);
8081
8182 static inline struct pid *get_pid(struct pid *pid)
8283 {
kernel/exit.c+0−19
@@ -1474,25 +1474,6 @@ end: · 1473 unmodified lines
14741474 return retval;
14751475 }
14761476
1477−static struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags)
1478−{
1479− struct fd f;
1480− struct pid *pid;
1481−
1482− f = fdget(fd);
1483− if (!f.file)
1484− return ERR_PTR(-EBADF);
1485−
1486− pid = pidfd_pid(f.file);
1487− if (!IS_ERR(pid)) {
1488− get_pid(pid);
1489− *flags = f.file->f_flags;
1490− }
1491−
1492− fdput(f);
1493− return pid;
1494−}
1495−
14961477 static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop,
14971478 int options, struct rusage *ru)
14981479 {
kernel/pid.c+19−0
@@ -520,6 +520,25 @@ struct pid *find_ge_pid(int nr, struct pid_namespace *ns) · 519 unmodified lines
520520 return idr_get_next(&ns->idr, &nr);
521521 }
522522
523+struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags)
524+{
525+ struct fd f;
526+ struct pid *pid;
527+
528+ f = fdget(fd);
529+ if (!f.file)
530+ return ERR_PTR(-EBADF);
531+
532+ pid = pidfd_pid(f.file);
533+ if (!IS_ERR(pid)) {
534+ get_pid(pid);
535+ *flags = f.file->f_flags;
536+ }
537+
538+ fdput(f);
539+ return pid;
540+}
541+
523542 /**
524543 * pidfd_create() - Create a new pid file descriptor.
525544 *

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t