#include "stdio-util.h"
#include "string-util.h"
-static int have_pidfs = -1;
+static thread_local int have_pidfs = -1;
-static int pidfd_check_pidfs(int pid_fd) {
+int pidfd_check_pidfs(int pid_fd) {
/* NB: the passed fd *must* be acquired via pidfd_open(), i.e. must be a true pidfd! */
return 0;
}
-int pidfd_get_inode_id(int fd, uint64_t *ret) {
- static bool file_handle_supported = true;
+int pidfd_get_inode_id_impl(int fd, uint64_t *ret) {
+ static thread_local bool file_handle_supported = true;
int r;
assert(fd >= 0);
- r = pidfd_check_pidfs(fd);
- if (r < 0)
- return r;
- if (r == 0)
- return -EOPNOTSUPP;
-
if (file_handle_supported) {
union {
struct file_handle file_handle;
#endif
}
+int pidfd_get_inode_id(int fd, uint64_t *ret) {
+ int r;
+
+ assert(fd >= 0);
+
+ r = pidfd_check_pidfs(fd);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ return -EOPNOTSUPP;
+
+ return pidfd_get_inode_id_impl(fd, ret);
+}
+
int pidfd_get_inode_id_self_cached(uint64_t *ret) {
static thread_local uint64_t cached = 0;
static thread_local pid_t initialized = 0; /* < 0: cached error; == 0: invalid; > 0: valid and pid that was current */
int pidfd_get_uid(int fd, uid_t *ret);
int pidfd_get_cgroupid(int fd, uint64_t *ret);
+int pidfd_get_inode_id_impl(int fd, uint64_t *ret);
int pidfd_get_inode_id(int fd, uint64_t *ret);
-
int pidfd_get_inode_id_self_cached(uint64_t *ret);
+
+int pidfd_check_pidfs(int pid_fd);