Thread (7 messages) flat view 7 messages, 4 authors, 2019-12-24

Re: [PATCH v5 2/3] pid: Introduce pidfd_getfd syscall

From: Sargun Dhillon <hidden>
Date: 2019-12-21 01:46:15
Also in: linux-fsdevel, lkml

On Fri, Dec 20, 2019 at 4:27 PM Aleksa Sarai [off-list ref] wrote:
On 2019-12-20, Sargun Dhillon [off-list ref] wrote:
quoted
diff --git a/include/uapi/linux/pidfd.h b/include/uapi/linux/pidfd.h
new file mode 100644
index 000000000000..0a3fc922661d
--- /dev/null
+++ b/include/uapi/linux/pidfd.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _UAPI_LINUX_PIDFD_H
+#define _UAPI_LINUX_PIDFD_H
+
+struct pidfd_getfd_options {};
Are empty structs well-defined in C (from memory, some compilers make
them non-zero in size)? Since we probably plan to add a flags field in
the future anyway, why not just have a __u64 flags which must be zeroed?
It's allowed in GCC:
https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Empty-Structures.html

I can add an __aligned_u64 flags for now, and just say something like
"reserved". This will also solve the latter issue, and I'll just use
copy_struct_from_user,
as long as Christian is okay with having an unused (reserved) flag member.

quoted
+     f = fdget(pidfd);
+     if (!f.file)
+             return -EBADF;
+
+     pid = pidfd_pid(f.file);
+     if (IS_ERR(pid)) {
+             ret = PTR_ERR(pid);
+             goto out;
+     }
+
+     ret = pidfd_getfd(pid, fd);
+
+out:
+     fdput(f);
+     return ret;
+}
--
2.20.1
--
Aleksa Sarai
Senior Software Engineer (Containers)
SUSE Linux GmbH
<https://www.cyphar.com/>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help