From 3cffa6fcaf6ef57969e56fc28bebe0ef5b80ae2d Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 18 Jul 2021 15:08:15 +0100 Subject: [PATCH] android system prop api update. --- libc-test/build.rs | 4 +++- libc-test/semver/android.txt | 8 ++++++++ src/unix/linux_like/android/mod.rs | 17 ++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index b3944536388a4..e4bf177694a77 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1658,7 +1658,9 @@ fn test_android(target: &str) { // signalfd had SIGSYS fields added in Android 4.19, but CI does not have that version yet. (struct_ == "signalfd_siginfo" && (field == "ssi_syscall" || field == "ssi_call_addr" || - field == "ssi_arch")) + field == "ssi_arch")) || + // serial field is a volatile. + (struct_ == "prop_info" && field == "serial") }); cfg.skip_field(|struct_, field| { diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 89e831ce5a596..caa2c48595d8b 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -1621,6 +1621,8 @@ PRIO_PGRP PRIO_PROCESS PRIO_USER PROC_SUPER_MAGIC +PROP_NAME_MAX +PROP_VALUE_MAX PROT_EXEC PROT_GROWSDOWN PROT_GROWSUP @@ -2562,6 +2564,11 @@ __kernel_pid_t __sched_cpualloc __sched_cpucount __sched_cpufree +__system_property_find +__system_property_find_nth +__system_property_foreach +__system_property_get +__system_property_set _exit abort accept @@ -2939,6 +2946,7 @@ prlimit prlimit64 process_vm_readv process_vm_writev +prop_info protoent pselect pthread_atfork diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index f48cd49fd11ea..61d566140f399 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -46,6 +46,8 @@ pub type Elf64_Off = u64; pub type Elf64_Word = u32; pub type Elf64_Xword = u64; +pub type prop_info = __prop_info; + s! { pub struct stack_t { pub ss_sp: *mut ::c_void, @@ -422,6 +424,12 @@ s_no_extra_traits! { pub ivlen: u32, pub iv: [::c_uchar; 0], } + + pub struct __prop_info { + pub name: [::c_char; PROP_NAME_MAX], + pub serial: ::c_uint, + pub value: [::c_char; PROP_VALUE_MAX], + } } cfg_if! { @@ -2409,7 +2417,8 @@ pub const PF_NFC: ::c_int = AF_NFC; pub const PF_VSOCK: ::c_int = AF_VSOCK; // sys/system_properties.h -pub const PROP_VALUE_MAX: ::c_int = 92; +pub const PROP_VALUE_MAX: ::size_t = 92; +pub const PROP_NAME_MAX: ::size_t = 32; f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, @@ -2862,6 +2871,12 @@ extern "C" { pub fn __system_property_set(__name: *const ::c_char, __value: *const ::c_char) -> ::c_int; pub fn __system_property_get(__name: *const ::c_char, __value: *mut ::c_char) -> ::c_int; + pub fn __system_property_find(__name: *const ::c_char) -> *const prop_info; + pub fn __system_property_find_nth(__n: ::c_uint) -> *const prop_info; + pub fn __system_property_foreach( + __callback: unsafe extern "C" fn(__pi: *const prop_info, __cookie: *mut ::c_void), + __cookie: *mut ::c_void, + ) -> ::c_int; // #include /// Only available in API Version 21+