Skip to content

Commit 586867d

Browse files
author
Kelsey Z
committed
feat(linux): add mntent struct and related functions
Useful when playing around with mounting points, sadly not a common interface
1 parent 4939bb2 commit 586867d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

libc-test/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ fn main() {
191191
}
192192

193193
if linux || emscripten {
194+
cfg.header("mntent.h");
194195
cfg.header("mqueue.h");
195196
cfg.header("ucontext.h");
196197
if !uclibc {
@@ -255,7 +256,7 @@ fn main() {
255256
cfg.header("sys/fsuid.h");
256257
cfg.header("linux/seccomp.h");
257258
cfg.header("linux/if_ether.h");
258-
259+
259260
// DCCP support
260261
if !uclibc && !musl && !emscripten {
261262
cfg.header("linux/dccp.h");

src/unix/notbsd/linux/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,15 @@ s! {
454454
pub uid: ::uid_t,
455455
pub gid: ::gid_t,
456456
}
457+
458+
pub struct mntent {
459+
pub mnt_fsname: *mut ::c_char,
460+
pub mnt_dir: *mut ::c_char,
461+
pub mnt_type: *mut ::c_char,
462+
pub mnt_opts: *mut ::c_char,
463+
pub mnt_freq: ::c_int,
464+
pub mnt_passno: ::c_int,
465+
}
457466
}
458467

459468
pub const ABDAY_1: ::nl_item = 0x20000;
@@ -1694,6 +1703,14 @@ extern {
16941703
) -> ::c_int>,
16951704
data: *mut ::c_void
16961705
) -> ::c_int;
1706+
1707+
pub fn setmntent(filename: *const ::c_char,
1708+
ty: *const ::c_char) -> *mut ::FILE;
1709+
pub fn getmntent(stream: *mut ::FILE) -> *mut ::mntent;
1710+
pub fn addmntent(stream: *mut ::FILE, mnt: *const ::mntent) -> ::c_int;
1711+
pub fn endmntent(streamp: *mut ::FILE) -> ::c_int;
1712+
pub fn hasmntopt(mnt: *const ::mntent,
1713+
opt: *const ::c_char) -> *mut ::c_char;
16971714
}
16981715

16991716
cfg_if! {

0 commit comments

Comments
 (0)