Skip to content

Commit 77ca910

Browse files
Add missing FreeBSD mount items
1 parent bb5b8ef commit 77ca910

File tree

2 files changed

+220
-0
lines changed

2 files changed

+220
-0
lines changed

libc-test/build.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,6 +2109,33 @@ fn test_freebsd(target: &str) {
21092109
// Added in FreeBSD 13.
21102110
"PS_FST_TYPE_EVENTFD" if Some(13) > freebsd_ver => true,
21112111

2112+
// Added in FreeBSD 14.
2113+
"MNT_RECURSE"
2114+
| "MNT_DEFERRED"
2115+
| "MNTK_RECURSE"
2116+
| "MNTK_UPPER_WAITER"
2117+
| "MNTK_TASKQUEUE_WAITER"
2118+
if Some(14) > freebsd_ver =>
2119+
{
2120+
true
2121+
}
2122+
2123+
// Added in FreeBSD 13.
2124+
"MNT_EXTLS" | "MNT_EXTLSCERT" | "MNT_EXTLSCERTUSER" | "MNT_NOCOVER"
2125+
| "MNT_EMPTYDIR" | "MNTK_NOMSYNC" | "MNTK_UNIONFS" | "MNTK_FPLOOKUP"
2126+
| "MNTK_SUSPEND_ALL"
2127+
if Some(13) > freebsd_ver =>
2128+
{
2129+
true
2130+
}
2131+
2132+
// Added in FreeBSD 12.
2133+
"MNT_UNTRUSTED" | "MNT_VERIFIED" | "MNTK_TEXT_REFS" | "MNTK_VMSETSIZE_BUG"
2134+
if Some(12) > freebsd_ver =>
2135+
{
2136+
true
2137+
}
2138+
21122139
_ => false,
21132140
}
21142141
});

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ pub type u_short = ::c_ushort;
3939

4040
pub type caddr_t = *mut ::c_char;
4141

42+
pub type fhandle_t = fhandle;
43+
4244
// It's an alias over "struct __kvm_t". However, its fields aren't supposed to be used directly,
4345
// making the type definition system dependent. Better not bind it exactly.
4446
pub type kvm_t = ::c_void;
@@ -645,6 +647,17 @@ s! {
645647
pub ph1: u64,
646648
pub ph2: u64,
647649
}
650+
651+
pub struct fid {
652+
pub fid_len: ::c_ushort,
653+
pub fid_data0: ::c_ushort,
654+
pub fid_data: [::c_char; ::MAXFIDSZ as usize],
655+
}
656+
657+
pub struct fhandle {
658+
pub fh_fsid: ::fsid_t,
659+
pub fh_fid: fid,
660+
}
648661
}
649662

650663
s_no_extra_traits! {
@@ -3125,6 +3138,152 @@ pub const PS_FST_FFLAG_DIRECT: ::c_int = 0x1000;
31253138
pub const PS_FST_FFLAG_EXEC: ::c_int = 0x2000;
31263139
pub const PS_FST_FFLAG_HASLOCK: ::c_int = 0x4000;
31273140

3141+
// sys/mount.h
3142+
3143+
/// File identifier.
3144+
/// These are unique per filesystem on a single machine.
3145+
///
3146+
/// Note that the offset of fid_data is 4 bytes, so care must be taken to avoid
3147+
/// undefined behavior accessing unaligned fields within an embedded struct.
3148+
pub const MAXFIDSZ: ::c_int = 16;
3149+
/// Length of type name including null.
3150+
pub const MFSNAMELEN: ::c_int = 16;
3151+
/// Size of on/from name bufs.
3152+
pub const MNAMELEN: ::c_int = 1024;
3153+
3154+
/// Using journaled soft updates.
3155+
pub const MNT_SUJ: u64 = 0x100000000;
3156+
/// Mounted by automountd(8).
3157+
pub const MNT_AUTOMOUNTED: u64 = 0x200000000;
3158+
/// Filesys metadata untrusted.
3159+
pub const MNT_UNTRUSTED: u64 = 0x800000000;
3160+
3161+
/// Require TLS.
3162+
pub const MNT_EXTLS: u64 = 0x4000000000;
3163+
/// Require TLS with client cert.
3164+
pub const MNT_EXTLSCERT: u64 = 0x8000000000;
3165+
/// Require TLS with user cert.
3166+
pub const MNT_EXTLSCERTUSER: u64 = 0x10000000000;
3167+
3168+
/// Filesystem is stored locally.
3169+
pub const MNT_LOCAL: u64 = 0x000001000;
3170+
/// Quotas are enabled on fs.
3171+
pub const MNT_QUOTA: u64 = 0x000002000;
3172+
/// Identifies the root fs.
3173+
pub const MNT_ROOTFS: u64 = 0x000004000;
3174+
/// Mounted by a user.
3175+
pub const MNT_USER: u64 = 0x000008000;
3176+
/// Do not show entry in df.
3177+
pub const MNT_IGNORE: u64 = 0x000800000;
3178+
/// Filesystem is verified.
3179+
pub const MNT_VERIFIED: u64 = 0x400000000;
3180+
3181+
/// Do not cover a mount point.
3182+
pub const MNT_NOCOVER: u64 = 0x001000000000;
3183+
/// Only mount on empty dir.
3184+
pub const MNT_EMPTYDIR: u64 = 0x002000000000;
3185+
/// Recursively unmount uppers.
3186+
pub const MNT_RECURSE: u64 = 0x100000000000;
3187+
/// Unmount in async context.
3188+
pub const MNT_DEFERRED: u64 = 0x200000000000;
3189+
3190+
/// Forced unmount in progress.
3191+
pub const MNTK_UNMOUNTF: u32 = 0x00000001;
3192+
/// Filtered async flag.
3193+
pub const MNTK_ASYNC: u32 = 0x00000002;
3194+
/// Async disabled by softdep.
3195+
pub const MNTK_SOFTDEP: u32 = 0x00000004;
3196+
/// Don't do msync.
3197+
pub const MNTK_NOMSYNC: u32 = 0x00000008;
3198+
/// Lock draining is happening.
3199+
pub const MNTK_DRAINING: u32 = 0x00000010;
3200+
/// Refcount expiring is happening.
3201+
pub const MNTK_REFEXPIRE: u32 = 0x00000020;
3202+
/// Allow shared locking for more ops.
3203+
pub const MNTK_EXTENDED_SHARED: u32 = 0x00000040;
3204+
/// Allow shared locking for writes.
3205+
pub const MNTK_SHARED_WRITES: u32 = 0x00000080;
3206+
/// Disallow page faults during reads and writes. Filesystem shall properly handle i/o
3207+
/// state on EFAULT.
3208+
pub const MNTK_NO_IOPF: u32 = 0x00000100;
3209+
/// Pending recursive unmount.
3210+
pub const MNTK_RECURSE: u32 = 0x00000200;
3211+
/// Waiting to drain MNTK_UPPER_PENDING.
3212+
pub const MNTK_UPPER_WAITER: u32 = 0x00000400;
3213+
pub const MNTK_LOOKUP_EXCL_DOTDOT: u32 = 0x00000800;
3214+
pub const MNTK_UNMAPPED_BUFS: u32 = 0x00002000;
3215+
/// FS uses the buffer cache.
3216+
pub const MNTK_USES_BCACHE: u32 = 0x00004000;
3217+
/// Keep use ref for text.
3218+
pub const MNTK_TEXT_REFS: u32 = 0x00008000;
3219+
pub const MNTK_VMSETSIZE_BUG: u32 = 0x00010000;
3220+
/// A hack for F_ISUNIONSTACK.
3221+
pub const MNTK_UNIONFS: u32 = 0x00020000;
3222+
/// fast path lookup is supported.
3223+
pub const MNTK_FPLOOKUP: u32 = 0x00040000;
3224+
/// Suspended by all-fs suspension.
3225+
pub const MNTK_SUSPEND_ALL: u32 = 0x00080000;
3226+
/// Waiting on unmount taskqueue.
3227+
pub const MNTK_TASKQUEUE_WAITER: u32 = 0x00100000;
3228+
/// Disable async.
3229+
pub const MNTK_NOASYNC: u32 = 0x00800000;
3230+
/// Unmount in progress.
3231+
pub const MNTK_UNMOUNT: u32 = 0x01000000;
3232+
/// Waiting for unmount to finish.
3233+
pub const MNTK_MWAIT: u32 = 0x02000000;
3234+
/// Request write suspension.
3235+
pub const MNTK_SUSPEND: u32 = 0x08000000;
3236+
/// Block secondary writes.
3237+
pub const MNTK_SUSPEND2: u32 = 0x04000000;
3238+
/// Write operations are suspended.
3239+
pub const MNTK_SUSPENDED: u32 = 0x10000000;
3240+
/// auto disable cache for nullfs mounts over this fs.
3241+
pub const MNTK_NULL_NOCACHE: u32 = 0x20000000;
3242+
/// FS supports shared lock lookups.
3243+
pub const MNTK_LOOKUP_SHARED: u32 = 0x40000000;
3244+
/// Don't send KNOTEs from VOP hooks.
3245+
pub const MNTK_NOKNOTE: u32 = 0x80000000;
3246+
3247+
/// Get configured filesystems.
3248+
pub const VFS_VFSCONF: ::c_int = 0;
3249+
/// Generic filesystem information.
3250+
pub const VFS_GENERIC: ::c_int = 0;
3251+
3252+
/// int: highest defined filesystem type.
3253+
pub const VFS_MAXTYPENUM: ::c_int = 1;
3254+
/// struct: vfsconf for filesystem given as next argument.
3255+
pub const VFS_CONF: ::c_int = 2;
3256+
3257+
/// Synchronously wait for I/O to complete.
3258+
pub const MNT_WAIT: ::c_int = 1;
3259+
/// Start all I/O, but do not wait for it.
3260+
pub const MNT_NOWAIT: ::c_int = 2;
3261+
/// Push data not written by filesystem syncer.
3262+
pub const MNT_LAZY: ::c_int = 3;
3263+
/// Suspend file system after sync.
3264+
pub const MNT_SUSPEND: ::c_int = 4;
3265+
3266+
pub const MAXSECFLAVORS: ::c_int = 5;
3267+
3268+
/// Statically compiled into kernel.
3269+
pub const VFCF_STATIC: ::c_int = 0x00010000;
3270+
/// May get data over the network.
3271+
pub const VFCF_NETWORK: ::c_int = 0x00020000;
3272+
/// Writes are not implemented.
3273+
pub const VFCF_READONLY: ::c_int = 0x00040000;
3274+
/// Data does not represent real files.
3275+
pub const VFCF_SYNTHETIC: ::c_int = 0x00080000;
3276+
/// Aliases some other mounted FS.
3277+
pub const VFCF_LOOPBACK: ::c_int = 0x00100000;
3278+
/// Stores file names as Unicode.
3279+
pub const VFCF_UNICODE: ::c_int = 0x00200000;
3280+
/// Can be mounted from within a jail.
3281+
pub const VFCF_JAIL: ::c_int = 0x00400000;
3282+
/// Supports delegated administration.
3283+
pub const VFCF_DELEGADMIN: ::c_int = 0x00800000;
3284+
/// Stop at Boundary: defer stop requests to kernel->user (AST) transition.
3285+
pub const VFCF_SBDRY: ::c_int = 0x01000000;
3286+
31283287
const_fn! {
31293288
{const} fn _ALIGN(p: usize) -> usize {
31303289
(p + _ALIGNBYTES) & !_ALIGNBYTES
@@ -3228,6 +3387,26 @@ safe_f! {
32283387
}
32293388
}
32303389

3390+
cfg_if! {
3391+
if #[cfg(not(any(freebsd10, freebsd11)))] {
3392+
extern "C" {
3393+
pub fn fhlink(fhp: *mut fhandle_t, to: *const ::c_char) -> ::c_int;
3394+
pub fn fhlinkat(fhp: *mut fhandle_t, tofd: ::c_int, to: *const ::c_char) -> ::c_int;
3395+
pub fn fhreadlink(
3396+
fhp: *mut fhandle_t,
3397+
buf: *mut ::c_char,
3398+
bufsize: ::size_t,
3399+
) -> ::c_int;
3400+
pub fn getfhat(
3401+
fd: ::c_int,
3402+
path: *mut ::c_char,
3403+
fhp: *mut fhandle,
3404+
flag: ::c_int,
3405+
) -> ::c_int;
3406+
}
3407+
}
3408+
}
3409+
32313410
extern "C" {
32323411
pub fn __error() -> *mut ::c_int;
32333412

@@ -3520,7 +3699,21 @@ extern "C" {
35203699
needlelen: ::size_t,
35213700
) -> *mut ::c_void;
35223701

3702+
pub fn fhopen(fhp: *const fhandle_t, flags: ::c_int) -> ::c_int;
3703+
pub fn fhstat(fhp: *const fhandle, buf: *mut ::stat) -> ::c_int;
3704+
pub fn fhstatfs(fhp: *const fhandle_t, buf: *mut ::statfs) -> ::c_int;
3705+
pub fn getfh(path: *const ::c_char, fhp: *mut fhandle_t) -> ::c_int;
3706+
pub fn lgetfh(path: *const ::c_char, fhp: *mut fhandle_t) -> ::c_int;
3707+
pub fn getfsstat(buf: *mut ::statfs, bufsize: ::c_long, mode: ::c_int) -> ::c_int;
3708+
pub fn getmntinfo(mntbufp: *mut *mut ::statfs, mode: ::c_int) -> ::c_int;
3709+
pub fn mount(
3710+
type_: *const ::c_char,
3711+
dir: *const ::c_char,
3712+
flags: ::c_int,
3713+
data: *mut ::c_void,
3714+
) -> ::c_int;
35233715
pub fn nmount(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int) -> ::c_int;
3716+
35243717
pub fn setproctitle(fmt: *const ::c_char, ...);
35253718
pub fn rfork(flags: ::c_int) -> ::c_int;
35263719
pub fn cpuset_getaffinity(

0 commit comments

Comments
 (0)