Skip to content

Commit

Permalink
Add klogctl to linux and android
Browse files Browse the repository at this point in the history
For android, we also add the `KLOG_*` constants. For linux, they are
defined in source but not exported to user space.
  • Loading branch information
sgasse committed Aug 14, 2024
1 parent f5d998e commit ece907b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,7 @@ fn test_android(target: &str) {
"sys/fsuid.h",
"sys/inotify.h",
"sys/ioctl.h",
"sys/klog.h",
"sys/mman.h",
"sys/mount.h",
"sys/personality.h",
Expand Down Expand Up @@ -3351,6 +3352,7 @@ fn test_linux(target: &str) {
"sys/eventfd.h",
"sys/file.h",
"sys/fsuid.h",
"sys/klog.h",
"sys/inotify.h",
"sys/ioctl.h",
"sys/ipc.h",
Expand Down
12 changes: 12 additions & 0 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,17 @@ KEXEC_ON_CRASH
KEXEC_PRESERVE_CONTEXT
KEY_CNT
KEY_MAX
KLOG_CLOSE
KLOG_OPEN
KLOG_READ
KLOG_READ_ALL
KLOG_READ_CLEAR
KLOG_CLEAR
KLOG_CONSOLE_OFF
KLOG_CONSOLE_ON
KLOG_CONSOLE_LEVEL
KLOG_SIZE_UNREAD
KLOG_SIZE_BUFFER
LC_ADDRESS
LC_ADDRESS_MASK
LC_ALL
Expand Down Expand Up @@ -3361,6 +3372,7 @@ itimerval
key_t
kill
killpg
klogctl
lastlog
lchown
lconv
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3663,6 +3663,7 @@ j1939_filter
jrand48
key_t
killpg
klogctl
labs
lcong48
lgetxattr
Expand Down
14 changes: 14 additions & 0 deletions src/unix/linux_like/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3508,6 +3508,18 @@ pub const PF_MEMALLOC_PIN: ::c_int = 0x10000000;

pub const PF_SUSPEND_TASK: ::c_int = 0x80000000;

pub const KLOG_CLOSE: ::c_int = 0;
pub const KLOG_OPEN: ::c_int = 1;
pub const KLOG_READ: ::c_int = 2;
pub const KLOG_READ_ALL: ::c_int = 3;
pub const KLOG_READ_CLEAR: ::c_int = 4;
pub const KLOG_CLEAR: ::c_int = 5;
pub const KLOG_CONSOLE_OFF: ::c_int = 6;
pub const KLOG_CONSOLE_ON: ::c_int = 7;
pub const KLOG_CONSOLE_LEVEL: ::c_int = 8;
pub const KLOG_SIZE_UNREAD: ::c_int = 9;
pub const KLOG_SIZE_BUFFER: ::c_int = 10;

// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the
// following are only available on newer Linux versions than the versions
// currently used in CI in some configurations, so we define them here.
Expand Down Expand Up @@ -4096,6 +4108,8 @@ extern "C" {
mask: ::c_uint,
statxbuf: *mut statx,
) -> ::c_int;

pub fn klogctl(syslog_type: ::c_int, bufp: *mut ::c_char, len: ::c_int) -> ::c_int;
}

cfg_if! {
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6123,6 +6123,8 @@ extern "C" {
len: ::size_t,
flags: ::c_uint,
) -> ::ssize_t;

pub fn klogctl(syslog_type: ::c_int, bufp: *mut ::c_char, len: ::c_int) -> ::c_int;
}

// LFS64 extensions
Expand Down

0 comments on commit ece907b

Please sign in to comment.