[libc] Add 'struct ucred' definition. (#213152) This is a Linux extension that allows to obtain credentials of a peer process connected to a socket, e.g. via passing `SO_PEERCRED` to `getsockopt` function. GitOrigin-RevId: 7d5dd438b286d4812a8d2e753262cb6db1c3be51
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 941c9c7..1c6c65f 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt
@@ -858,6 +858,7 @@ .llvm-libc-types.struct_msghdr .llvm-libc-types.struct_sockaddr .llvm-libc-types.struct_sockaddr_storage + .llvm-libc-types.struct_ucred ) add_header_macro(
diff --git a/include/llvm-libc-types/CMakeLists.txt b/include/llvm-libc-types/CMakeLists.txt index 0854507..3286ebe 100644 --- a/include/llvm-libc-types/CMakeLists.txt +++ b/include/llvm-libc-types/CMakeLists.txt
@@ -264,6 +264,7 @@ add_header(struct_ifreq HDR struct_ifreq.h DEPENDS libc.include.llvm-libc-macros.net_if_macros .struct_sockaddr) add_header(struct_iovec HDR struct_iovec.h DEPENDS .size_t) add_header(struct_linger HDR struct_linger.h) +add_header(struct_ucred HDR struct_ucred.h DEPENDS .pid_t .uid_t .gid_t) add_header(struct_cmsghdr HDR struct_cmsghdr.h DEPENDS .size_t) add_header(struct_msghdr HDR struct_msghdr.h DEPENDS .size_t .socklen_t .struct_iovec) add_header(struct_mmsghdr HDR struct_mmsghdr.h DEPENDS .struct_msghdr)
diff --git a/include/llvm-libc-types/struct_ucred.h b/include/llvm-libc-types/struct_ucred.h new file mode 100644 index 0000000..727e18f --- /dev/null +++ b/include/llvm-libc-types/struct_ucred.h
@@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// Definition of struct ucred. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBC_TYPES_STRUCT_UCRED_H +#define LLVM_LIBC_TYPES_STRUCT_UCRED_H + +#include "gid_t.h" +#include "pid_t.h" +#include "uid_t.h" + +// Credentials of a peer process connected to a socket. +struct ucred { + pid_t pid; + uid_t uid; + gid_t gid; +}; + +#endif // LLVM_LIBC_TYPES_STRUCT_UCRED_H
diff --git a/include/sys/socket.yaml b/include/sys/socket.yaml index fb121fa..64a3a56 100644 --- a/include/sys/socket.yaml +++ b/include/sys/socket.yaml
@@ -15,6 +15,9 @@ - type_name: struct_msghdr - type_name: struct_iovec - type_name: struct_linger + - type_name: struct_ucred + standards: + - linux - type_name: size_t - type_name: ssize_t enums: []