Skip to content

Commit c4731a0

Browse files
committed
NetBSD: Introduce statvfs.rs
Move statvfs types to the `new` module. Link: https://github.com/NetBSD/src/blob/6ace5fed3bd010695a1b88ca6c1f8a5af7793ffb/sys/sys/statvfs.h#L66-L101
1 parent c4a86e0 commit c4731a0

File tree

6 files changed

+57
-37
lines changed

6 files changed

+57
-37
lines changed

src/new/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ cfg_if! {
182182
pub use net::route::*;
183183
} else if #[cfg(target_vendor = "apple")] {
184184
pub use signal::*;
185+
} else if #[cfg(target_os = "netbsd")] {
186+
pub use sys::statvfs::*;
185187
}
186188
}
187189

src/new/netbsd/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! NetBSD libc.
22
//!
3+
//! * Headers: <https://github.com/NetBSD/src/tree/trunk/include>
4+
//! * Sys headers: <https://github.com/NetBSD/src/tree/trunk/sys/sys>
35
//! * Manual pages: <https://man.netbsd.org/>
46
7+
pub(crate) mod sys;
58
pub(crate) mod unistd;

src/new/netbsd/sys/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//! Directory: `sys/`
2+
//!
3+
//! https://github.com/NetBSD/src/tree/trunk/sys/sys
4+
5+
pub(crate) mod statvfs;

src/new/netbsd/sys/statvfs.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//! Header: `sys/statvfs.h`
2+
//!
3+
//! <https://github.com/NetBSD/src/blob/trunk/sys/sys/statvfs.h>
4+
5+
use crate::prelude::*;
6+
7+
const _VFS_NAMELEN: usize = 32;
8+
const _VFS_MNAMELEN: usize = 1024;
9+
10+
s! {
11+
pub struct statvfs {
12+
pub f_flag: c_ulong,
13+
pub f_bsize: c_ulong,
14+
pub f_frsize: c_ulong,
15+
pub f_iosize: c_ulong,
16+
17+
pub f_blocks: crate::fsblkcnt_t,
18+
pub f_bfree: crate::fsblkcnt_t,
19+
pub f_bavail: crate::fsblkcnt_t,
20+
pub f_bresvd: crate::fsblkcnt_t,
21+
22+
pub f_files: crate::fsfilcnt_t,
23+
pub f_ffree: crate::fsfilcnt_t,
24+
pub f_favail: crate::fsfilcnt_t,
25+
pub f_fresvd: crate::fsfilcnt_t,
26+
27+
pub f_syncreads: u64,
28+
pub f_syncwrites: u64,
29+
30+
pub f_asyncreads: u64,
31+
pub f_asyncwrites: u64,
32+
33+
pub f_fsidx: crate::fsid_t,
34+
pub f_fsid: c_ulong,
35+
pub f_namemax: c_ulong,
36+
pub f_owner: crate::uid_t,
37+
38+
pub f_spare: [u32; 4],
39+
40+
pub f_fstypename: [c_char; _VFS_NAMELEN],
41+
pub f_mntonname: [c_char; _VFS_MNAMELEN],
42+
pub f_mntfromname: [c_char; _VFS_MNAMELEN],
43+
}
44+
}

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

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -851,40 +851,6 @@ s! {
851851
pub d_name: [c_char; 512],
852852
}
853853

854-
pub struct statvfs {
855-
pub f_flag: c_ulong,
856-
pub f_bsize: c_ulong,
857-
pub f_frsize: c_ulong,
858-
pub f_iosize: c_ulong,
859-
860-
pub f_blocks: crate::fsblkcnt_t,
861-
pub f_bfree: crate::fsblkcnt_t,
862-
pub f_bavail: crate::fsblkcnt_t,
863-
pub f_bresvd: crate::fsblkcnt_t,
864-
865-
pub f_files: crate::fsfilcnt_t,
866-
pub f_ffree: crate::fsfilcnt_t,
867-
pub f_favail: crate::fsfilcnt_t,
868-
pub f_fresvd: crate::fsfilcnt_t,
869-
870-
pub f_syncreads: u64,
871-
pub f_syncwrites: u64,
872-
873-
pub f_asyncreads: u64,
874-
pub f_asyncwrites: u64,
875-
876-
pub f_fsidx: crate::fsid_t,
877-
pub f_fsid: c_ulong,
878-
pub f_namemax: c_ulong,
879-
pub f_owner: crate::uid_t,
880-
881-
pub f_spare: [u32; 4],
882-
883-
pub f_fstypename: [c_char; 32],
884-
pub f_mntonname: [c_char; 1024],
885-
pub f_mntfromname: [c_char; 1024],
886-
}
887-
888854
pub struct sockaddr_storage {
889855
pub ss_len: u8,
890856
pub ss_family: crate::sa_family_t,
@@ -2459,7 +2425,7 @@ extern "C" {
24592425
) -> c_int;
24602426
#[link_name = "__getmntinfo13"]
24612427
pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int;
2462-
pub fn getvfsstat(buf: *mut statvfs, bufsize: size_t, flags: c_int) -> c_int;
2428+
pub fn getvfsstat(buf: *mut crate::statvfs, bufsize: size_t, flags: c_int) -> c_int;
24632429

24642430
// Added in `NetBSD` 10.0
24652431
pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int;

src/unix/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,9 +1556,9 @@ extern "C" {
15561556
pub fn sem_trywait(sem: *mut sem_t) -> c_int;
15571557
pub fn sem_post(sem: *mut sem_t) -> c_int;
15581558
#[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")]
1559-
pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> c_int;
1559+
pub fn statvfs(path: *const c_char, buf: *mut crate::statvfs) -> c_int;
15601560
#[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")]
1561-
pub fn fstatvfs(fd: c_int, buf: *mut statvfs) -> c_int;
1561+
pub fn fstatvfs(fd: c_int, buf: *mut crate::statvfs) -> c_int;
15621562

15631563
#[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")]
15641564
pub fn sigemptyset(set: *mut sigset_t) -> c_int;

0 commit comments

Comments
 (0)