Skip to content

Commit 3280331

Browse files
sgassetgross35
authored andcommitted
Add klogctl to linux and android
For android, we also add the `KLOG_*` constants. For linux, they are defined in source but not exported to user space. (backport <#3777>) (cherry picked from commit ece907b)
1 parent 3f102f3 commit 3280331

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,7 @@ fn test_android(target: &str) {
16561656
"sys/fsuid.h",
16571657
"sys/inotify.h",
16581658
"sys/ioctl.h",
1659+
"sys/klog.h",
16591660
"sys/mman.h",
16601661
"sys/mount.h",
16611662
"sys/personality.h",
@@ -3433,6 +3434,7 @@ fn test_linux(target: &str) {
34333434
"sys/eventfd.h",
34343435
"sys/file.h",
34353436
"sys/fsuid.h",
3437+
"sys/klog.h",
34363438
"sys/inotify.h",
34373439
"sys/ioctl.h",
34383440
"sys/ipc.h",

libc-test/semver/android.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,17 @@ KEXEC_ON_CRASH
10731073
KEXEC_PRESERVE_CONTEXT
10741074
KEY_CNT
10751075
KEY_MAX
1076+
KLOG_CLOSE
1077+
KLOG_OPEN
1078+
KLOG_READ
1079+
KLOG_READ_ALL
1080+
KLOG_READ_CLEAR
1081+
KLOG_CLEAR
1082+
KLOG_CONSOLE_OFF
1083+
KLOG_CONSOLE_ON
1084+
KLOG_CONSOLE_LEVEL
1085+
KLOG_SIZE_UNREAD
1086+
KLOG_SIZE_BUFFER
10761087
LC_ADDRESS
10771088
LC_ADDRESS_MASK
10781089
LC_ALL
@@ -3341,6 +3352,7 @@ itimerval
33413352
key_t
33423353
kill
33433354
killpg
3355+
klogctl
33443356
lastlog
33453357
lchown
33463358
lconv

libc-test/semver/linux.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3562,6 +3562,7 @@ j1939_filter
35623562
jrand48
35633563
key_t
35643564
killpg
3565+
klogctl
35653566
labs
35663567
lcong48
35673568
lgetxattr

src/unix/linux_like/android/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3523,6 +3523,18 @@ pub const PF_MEMALLOC_PIN: ::c_int = 0x10000000;
35233523

35243524
pub const PF_SUSPEND_TASK: ::c_int = 0x80000000;
35253525

3526+
pub const KLOG_CLOSE: ::c_int = 0;
3527+
pub const KLOG_OPEN: ::c_int = 1;
3528+
pub const KLOG_READ: ::c_int = 2;
3529+
pub const KLOG_READ_ALL: ::c_int = 3;
3530+
pub const KLOG_READ_CLEAR: ::c_int = 4;
3531+
pub const KLOG_CLEAR: ::c_int = 5;
3532+
pub const KLOG_CONSOLE_OFF: ::c_int = 6;
3533+
pub const KLOG_CONSOLE_ON: ::c_int = 7;
3534+
pub const KLOG_CONSOLE_LEVEL: ::c_int = 8;
3535+
pub const KLOG_SIZE_UNREAD: ::c_int = 9;
3536+
pub const KLOG_SIZE_BUFFER: ::c_int = 10;
3537+
35263538
// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the
35273539
// following are only available on newer Linux versions than the versions
35283540
// currently used in CI in some configurations, so we define them here.
@@ -4095,6 +4107,8 @@ extern "C" {
40954107
) -> ::size_t;
40964108
pub fn fflush_unlocked(stream: *mut ::FILE) -> ::c_int;
40974109
pub fn fgets_unlocked(buf: *mut ::c_char, size: ::c_int, stream: *mut ::FILE) -> *mut ::c_char;
4110+
4111+
pub fn klogctl(syslog_type: ::c_int, bufp: *mut ::c_char, len: ::c_int) -> ::c_int;
40984112
}
40994113

41004114
cfg_if! {

src/unix/linux_like/linux/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5626,6 +5626,8 @@ extern "C" {
56265626
len: ::size_t,
56275627
flags: ::c_uint,
56285628
) -> ::ssize_t;
5629+
5630+
pub fn klogctl(syslog_type: ::c_int, bufp: *mut ::c_char, len: ::c_int) -> ::c_int;
56295631
}
56305632

56315633
// LFS64 extensions

0 commit comments

Comments
 (0)