#include <linux/keyctl.h>
#include <sched.h>
#include <stdint.h>
+#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/syscall.h>
#include <sys/types.h>
/*
* mount_setattr()
*/
-struct lxc_mount_attr {
+#if !HAVE_STRUCT_MOUNT_ATTR
+struct mount_attr {
__u64 attr_set;
__u64 attr_clr;
__u64 propagation;
__u64 userns_fd;
};
+#endif
#if !HAVE_MOUNT_SETATTR
static inline int mount_setattr(int dfd, const char *path, unsigned int flags,
- struct lxc_mount_attr *attr, size_t size)
+ struct mount_attr *attr, size_t size)
{
return syscall(__NR_mount_setattr, dfd, path, flags, attr, size);
}
return (cookie > 0) && (cookie != INVALID_SCHED_CORE_COOKIE);
}
-static inline __u64 core_scheduling_cookie_get(pid_t pid)
+static inline int core_scheduling_cookie_get(pid_t pid, __u64 *cookie)
{
- __u64 cookie;
int ret;
+ if (!cookie)
+ return ret_errno(EINVAL);
+
ret = prctl(PR_SCHED_CORE, PR_SCHED_CORE_GET, pid,
- PR_SCHED_CORE_SCOPE_THREAD, (unsigned long)&cookie);
- if (ret)
- return INVALID_SCHED_CORE_COOKIE;
+ PR_SCHED_CORE_SCOPE_THREAD, (unsigned long)cookie);
+ if (ret) {
+ *cookie = INVALID_SCHED_CORE_COOKIE;
+ return -errno;
+ }
- return cookie;
+ return 0;
}
static inline int core_scheduling_cookie_create_threadgroup(pid_t pid)