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
77struct file;77struct file;
78 78
79extern struct pid *pidfd_pid(const struct file *file);79extern struct pid *pidfd_pid(const struct file *file);
80struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags);
80 81
81static inline struct pid *get_pid(struct pid *pid)82static inline struct pid *get_pid(struct pid *pid)
82{83{
kernel/exit.c+0−19
@@ -1474,25 +1474,6 @@ end: · 1473 unmodified lines
1474 return retval;1474 return retval;
1475}1475}
1476 1476
1477static 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
1496static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop,1477static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop,
1497 int options, struct rusage *ru)1478 int options, struct rusage *ru)
1498{1479{
kernel/pid.c+19−0
@@ -520,6 +520,25 @@ struct pid *find_ge_pid(int nr, struct pid_namespace *ns) · 519 unmodified lines
520 return idr_get_next(&ns->idr, &nr);520 return idr_get_next(&ns->idr, &nr);
521}521}
522 522
523struct 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
523/**542/**
524 * pidfd_create() - Create a new pid file descriptor.543 * pidfd_create() - Create a new pid file descriptor.
525 *544 *

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