Skip to content

Commit 9f3c5bc

Browse files
committed
Auto merge of #3368 - 0323pin:main, r=JohnTitor
backtrace definitions and support for getmntinfo and getvfsstat After the failures of merging #3361 as a follow-up to #3359 I've spent sometime making sure everything is indeed supported and defined. ``` ~> grep -r "MNT_WAIT" /usr/include/sys/fstypes.h; grep -r "MNT_NOWAIT" /usr/include/sys/fstypes.h; grep -r "MNT_LAZY" /usr/include/sys/fstypes.h #define MNT_WAIT 1 /* synchronously wait for I/O to complete */ #define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */ #define MNT_LAZY 3 /* push data not written by filesystem syncer */ ``` ``` ~> grep -r "getmntinfo" /usr/include/sys/; grep -r "getvfsstat" /usr/include/sys/ /usr/include/sys/statvfs.h:int getmntinfo(struct statvfs **, int) /usr/include/sys/statvfs.h: __RENAME(__getmntinfo90); /usr/include/sys/fstypes.h: * waitfor flags to vfs_sync() and getvfsstat() /usr/include/sys/statvfs.h:int getvfsstat(struct statvfs *, size_t, int) /usr/include/sys/statvfs.h: __RENAME(__getvfsstat90); /usr/include/sys/syscall.h:/* syscall: "compat_90_getvfsstat" ret: "int" args: "struct statvfs90 *" "size_t" "int" */ /usr/include/sys/syscall.h:#define SYS_compat_90_getvfsstat 356 /usr/include/sys/syscall.h:/* syscall: "__getvfsstat90" ret: "int" args: "struct statvfs *" "size_t" "int" */ /usr/include/sys/syscall.h:#define SYS___getvfsstat90 483 /usr/include/sys/syscallargs.h:struct compat_90_sys_getvfsstat_args { /usr/include/sys/syscallargs.h:check_syscall_args(compat_90_sys_getvfsstat) /usr/include/sys/syscallargs.h:struct sys___getvfsstat90_args { /usr/include/sys/syscallargs.h:check_syscall_args(sys___getvfsstat90) /usr/include/sys/syscallargs.h:int compat_90_sys_getvfsstat(struct lwp *, const struct compat_90_sys_getvfsstat_args *, register_t *); /usr/include/sys/syscallargs.h:int sys___getvfsstat90(struct lwp *, const struct sys___getvfsstat90_args *, register_t *); ``` Also, I've made sure the code compiles with rustc 1.72.0 without warning or errors. ``` ~> cargo build --release Updating crates.io index Compiling libc v0.2.148 (/home/pin/Git/libc) Finished release [optimized] target(s) in 8.87s ``` Moreover, the _move to trash_ functionality has again been verified using [simp](https://github.com/Kl4rry/simp) compiled with this commit as patch, in combination with the patch submited to [trash-rs](Byron/trash-rs#84). `@JohnTitor` Please give bors another try
2 parents 9593176 + bd3b68d commit 9f3c5bc

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

libc-test/semver/netbsd.txt

+10
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,9 @@ MNT_RELATIME
671671
MNT_SOFTDEP
672672
MNT_SYMPERM
673673
MNT_UNION
674+
MNT_WAIT
675+
MNT_NOWAIT
676+
MNT_LAZY
674677
MOD_CLKA
675678
MOD_CLKB
676679
MOD_ESTERROR
@@ -1188,6 +1191,11 @@ arc4random
11881191
arc4random_buf
11891192
arc4random_uniform
11901193
arphdr
1194+
backtrace
1195+
backtrace_symbols
1196+
backtrace_symbols_fd
1197+
backtrace_symbols_fmt
1198+
backtrace_symbols_fd_fmt
11911199
bsearch
11921200
chflags
11931201
chroot
@@ -1275,6 +1283,7 @@ getitimer
12751283
getlastlogx
12761284
getline
12771285
getloadavg
1286+
getmntinfo
12781287
getnameinfo
12791288
getopt_long
12801289
getpeereid
@@ -1295,6 +1304,7 @@ getutmpx
12951304
getutxent
12961305
getutxid
12971306
getutxline
1307+
getvfsstat
12981308
getxattr
12991309
glob
13001310
glob_t

src/unix/bsd/netbsdlike/netbsd/mod.rs

+35
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,9 @@ pub const MNT_NODEVMTIME: ::c_int = 0x40000000;
18521852
pub const MNT_SOFTDEP: ::c_int = 0x80000000;
18531853
pub const MNT_POSIX1EACLS: ::c_int = 0x00000800;
18541854
pub const MNT_ACLS: ::c_int = MNT_POSIX1EACLS;
1855+
pub const MNT_WAIT: ::c_int = 1;
1856+
pub const MNT_NOWAIT: ::c_int = 2;
1857+
pub const MNT_LAZY: ::c_int = 3;
18551858

18561859
//<sys/timex.h>
18571860
pub const NTP_API: ::c_int = 4;
@@ -3154,6 +3157,38 @@ extern "C" {
31543157
pub fn kinfo_getvmmap(pid: ::pid_t, cntp: *mut ::size_t) -> *mut kinfo_vmentry;
31553158
}
31563159

3160+
#[link(name = "execinfo")]
3161+
extern "C" {
3162+
pub fn backtrace(addrlist: *mut *mut ::c_void, len: ::size_t) -> ::size_t;
3163+
pub fn backtrace_symbols(addrlist: *const *mut ::c_void, len: ::size_t) -> *mut *mut ::c_char;
3164+
pub fn backtrace_symbols_fd(
3165+
addrlist: *const *mut ::c_void,
3166+
len: ::size_t,
3167+
fd: ::c_int,
3168+
) -> ::c_int;
3169+
pub fn backtrace_symbols_fmt(
3170+
addrlist: *const *mut ::c_void,
3171+
len: ::size_t,
3172+
fmt: *const ::c_char,
3173+
) -> *mut *mut ::c_char;
3174+
pub fn backtrace_symbols_fd_fmt(
3175+
addrlist: *const *mut ::c_void,
3176+
len: ::size_t,
3177+
fd: ::c_int,
3178+
fmt: *const ::c_char,
3179+
) -> ::c_int;
3180+
}
3181+
3182+
cfg_if! {
3183+
if #[cfg(libc_union)] {
3184+
extern {
3185+
// these functions use statvfs:
3186+
pub fn getmntinfo(mntbufp: *mut *mut ::statvfs, flags: ::c_int) -> ::c_int;
3187+
pub fn getvfsstat(buf: *mut statvfs, bufsize: ::size_t, flags: ::c_int) -> ::c_int;
3188+
}
3189+
}
3190+
}
3191+
31573192
cfg_if! {
31583193
if #[cfg(target_arch = "aarch64")] {
31593194
mod aarch64;

0 commit comments

Comments
 (0)