From: Yu Watanabe Date: Tue, 3 Feb 2026 15:29:06 +0000 (+0900) Subject: pidfd-util: use fd_to_handle_u64() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2eab8fa1e4420b7c021b477b726038720511e5df;p=thirdparty%2Fsystemd.git pidfd-util: use fd_to_handle_u64() --- diff --git a/src/basic/pidfd-util.c b/src/basic/pidfd-util.c index 8c4c8324529..7bfe83d319d 100644 --- a/src/basic/pidfd-util.c +++ b/src/basic/pidfd-util.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include #include #include #include @@ -236,25 +235,10 @@ int pidfd_get_inode_id_impl(int fd, uint64_t *ret) { assert(fd >= 0); + /* Since kernel 6.14 (b3caba8f7a34a2bbaf45ffc6ff3a49b70afeb192), we can use name_to_handle_at(). */ if (file_handle_supported) { - union { - struct file_handle file_handle; - uint8_t space[MAX_HANDLE_SZ]; - } fh = { - .file_handle.handle_bytes = sizeof(uint64_t), - .file_handle.handle_type = FILEID_KERNFS, - }; - int mnt_id; - - r = RET_NERRNO(name_to_handle_at(fd, "", &fh.file_handle, &mnt_id, AT_EMPTY_PATH)); - if (r >= 0) { - if (ret) - /* Note, "struct file_handle" is 32bit aligned usually, but we need to read a 64bit value from it */ - *ret = unaligned_read_ne64(fh.file_handle.f_handle); - return 0; - } - assert(r != -EOVERFLOW); - if (is_name_to_handle_at_fatal_error(r)) + r = fd_to_handle_u64(fd, ret); + if (r >= 0 || is_name_to_handle_at_fatal_error(r)) return r; file_handle_supported = false;