Skip to content

Commit 6decc5f

Browse files
authored
Remove linux-raw-sys and libc from public API (#956)
* Remove linux-raw-sys and libc from public API This prevents libc and linux-raw-sys from affecting the semver status of this crate. Signed-off-by: John Nunley <dev@notgull.net> * Fix compile errors Signed-off-by: John Nunley <dev@notgull.net> --------- Signed-off-by: John Nunley <dev@notgull.net>
1 parent 2a70730 commit 6decc5f

26 files changed

+184
-206
lines changed

src/backend/libc/fs/syscalls.rs

+32-30
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use crate::backend::c;
99
use crate::backend::conv::ret_usize;
1010
use crate::backend::conv::{borrowed_fd, c_str, ret, ret_c_int, ret_off_t, ret_owned_fd};
1111
use crate::fd::{BorrowedFd, OwnedFd};
12-
use crate::ffi::CStr;
1312
#[cfg(apple)]
1413
use crate::ffi::CString;
14+
use crate::ffi::{self, CStr};
1515
#[cfg(not(any(target_os = "espidf", target_os = "vita")))]
1616
use crate::fs::Access;
1717
#[cfg(not(any(
@@ -90,7 +90,7 @@ use {
9090
};
9191

9292
#[cfg(all(target_env = "gnu", fix_y2038))]
93-
weak!(fn __utimensat64(c::c_int, *const c::c_char, *const LibcTimespec, c::c_int) -> c::c_int);
93+
weak!(fn __utimensat64(c::c_int, *const ffi::c_char, *const LibcTimespec, c::c_int) -> c::c_int);
9494
#[cfg(all(target_env = "gnu", fix_y2038))]
9595
weak!(fn __futimens64(c::c_int, *const LibcTimespec) -> c::c_int);
9696

@@ -123,7 +123,7 @@ fn open_via_syscall(path: &CStr, oflags: OFlags, mode: Mode) -> io::Result<Owned
123123
unsafe {
124124
syscall! {
125125
fn open(
126-
pathname: *const c::c_char,
126+
pathname: *const ffi::c_char,
127127
oflags: c::c_int,
128128
mode: c::mode_t
129129
) via SYS_open -> c::c_int
@@ -178,7 +178,7 @@ fn openat_via_syscall(
178178
syscall! {
179179
fn openat(
180180
base_dirfd: c::c_int,
181-
pathname: *const c::c_char,
181+
pathname: *const ffi::c_char,
182182
oflags: c::c_int,
183183
mode: c::mode_t
184184
) via SYS_openat -> c::c_int
@@ -268,9 +268,11 @@ pub(crate) fn statvfs(filename: &CStr) -> io::Result<StatVfs> {
268268
#[inline]
269269
pub(crate) fn readlink(path: &CStr, buf: &mut [u8]) -> io::Result<usize> {
270270
unsafe {
271-
ret_usize(
272-
c::readlink(c_str(path), buf.as_mut_ptr().cast::<c::c_char>(), buf.len()) as isize,
273-
)
271+
ret_usize(c::readlink(
272+
c_str(path),
273+
buf.as_mut_ptr().cast::<ffi::c_char>(),
274+
buf.len(),
275+
) as isize)
274276
}
275277
}
276278

@@ -285,7 +287,7 @@ pub(crate) fn readlinkat(
285287
ret_usize(c::readlinkat(
286288
borrowed_fd(dirfd),
287289
c_str(path),
288-
buf.as_mut_ptr().cast::<c::c_char>(),
290+
buf.as_mut_ptr().cast::<ffi::c_char>(),
289291
buf.len(),
290292
) as isize)
291293
}
@@ -345,9 +347,9 @@ pub(crate) fn linkat(
345347
weak! {
346348
fn linkat(
347349
c::c_int,
348-
*const c::c_char,
350+
*const ffi::c_char,
349351
c::c_int,
350-
*const c::c_char,
352+
*const ffi::c_char,
351353
c::c_int
352354
) -> c::c_int
353355
}
@@ -402,7 +404,7 @@ pub(crate) fn unlinkat(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io
402404
weak! {
403405
fn unlinkat(
404406
c::c_int,
405-
*const c::c_char,
407+
*const ffi::c_char,
406408
c::c_int
407409
) -> c::c_int
408410
}
@@ -455,9 +457,9 @@ pub(crate) fn renameat(
455457
weak! {
456458
fn renameat(
457459
c::c_int,
458-
*const c::c_char,
460+
*const ffi::c_char,
459461
c::c_int,
460-
*const c::c_char
462+
*const ffi::c_char
461463
) -> c::c_int
462464
}
463465
// If we have `renameat`, use it.
@@ -499,9 +501,9 @@ pub(crate) fn renameat2(
499501
weak_or_syscall! {
500502
fn renameat2(
501503
olddirfd: c::c_int,
502-
oldpath: *const c::c_char,
504+
oldpath: *const ffi::c_char,
503505
newdirfd: c::c_int,
504-
newpath: *const c::c_char,
506+
newpath: *const ffi::c_char,
505507
flags: c::c_uint
506508
) via SYS_renameat2 -> c::c_int
507509
}
@@ -538,9 +540,9 @@ pub(crate) fn renameat2(
538540
syscall! {
539541
fn renameat2(
540542
olddirfd: c::c_int,
541-
oldpath: *const c::c_char,
543+
oldpath: *const ffi::c_char,
542544
newdirfd: c::c_int,
543-
newpath: *const c::c_char,
545+
newpath: *const ffi::c_char,
544546
flags: c::c_uint
545547
) via SYS_renameat2 -> c::c_int
546548
}
@@ -741,7 +743,7 @@ pub(crate) fn accessat(
741743
weak! {
742744
fn faccessat(
743745
c::c_int,
744-
*const c::c_char,
746+
*const ffi::c_char,
745747
c::c_int,
746748
c::c_int
747749
) -> c::c_int
@@ -848,14 +850,14 @@ pub(crate) fn utimensat(
848850
weak! {
849851
fn utimensat(
850852
c::c_int,
851-
*const c::c_char,
853+
*const ffi::c_char,
852854
*const c::timespec,
853855
c::c_int
854856
) -> c::c_int
855857
}
856858
extern "C" {
857859
fn setattrlist(
858-
path: *const c::c_char,
860+
path: *const ffi::c_char,
859861
attr_list: *const Attrlist,
860862
attr_buf: *const c::c_void,
861863
attr_buf_size: c::size_t,
@@ -1040,7 +1042,7 @@ pub(crate) fn chmodat(
10401042
syscall! {
10411043
fn fchmodat(
10421044
base_dirfd: c::c_int,
1043-
pathname: *const c::c_char,
1045+
pathname: *const ffi::c_char,
10441046
mode: c::mode_t
10451047
) via SYS_fchmodat -> c::c_int
10461048
}
@@ -1070,7 +1072,7 @@ pub(crate) fn fclonefileat(
10701072
fn fclonefileat(
10711073
srcfd: BorrowedFd<'_>,
10721074
dst_dirfd: BorrowedFd<'_>,
1073-
dst: *const c::c_char,
1075+
dst: *const ffi::c_char,
10741076
flags: c::c_int
10751077
) via SYS_fclonefileat -> c::c_int
10761078
}
@@ -1703,15 +1705,15 @@ pub(crate) fn memfd_create(name: &CStr, flags: MemfdFlags) -> io::Result<OwnedFd
17031705
#[cfg(target_os = "freebsd")]
17041706
weakcall! {
17051707
fn memfd_create(
1706-
name: *const c::c_char,
1708+
name: *const ffi::c_char,
17071709
flags: c::c_uint
17081710
) -> c::c_int
17091711
}
17101712

17111713
#[cfg(linux_kernel)]
17121714
weak_or_syscall! {
17131715
fn memfd_create(
1714-
name: *const c::c_char,
1716+
name: *const ffi::c_char,
17151717
flags: c::c_uint
17161718
) via SYS_memfd_create -> c::c_int
17171719
}
@@ -1732,7 +1734,7 @@ pub(crate) fn openat2(
17321734
syscall! {
17331735
fn openat2(
17341736
base_dirfd: c::c_int,
1735-
pathname: *const c::c_char,
1737+
pathname: *const ffi::c_char,
17361738
how: *mut open_how,
17371739
size: usize
17381740
) via SYS_OPENAT2 -> c::c_int
@@ -1922,12 +1924,12 @@ fn stat64_to_stat(s64: c::stat64) -> io::Result<Stat> {
19221924
#[cfg(linux_kernel)]
19231925
#[allow(non_upper_case_globals)]
19241926
mod sys {
1925-
use super::{c, BorrowedFd, Statx};
1927+
use super::{c, ffi, BorrowedFd, Statx};
19261928

19271929
weak_or_syscall! {
19281930
pub(super) fn statx(
19291931
dirfd_: BorrowedFd<'_>,
1930-
path: *const c::c_char,
1932+
path: *const ffi::c_char,
19311933
flags: c::c_int,
19321934
mask: c::c_uint,
19331935
buf: *mut Statx
@@ -2405,7 +2407,7 @@ pub(crate) fn fsetxattr(
24052407
}
24062408

24072409
#[cfg(any(apple, linux_kernel))]
2408-
pub(crate) fn listxattr(path: &CStr, list: &mut [c::c_char]) -> io::Result<usize> {
2410+
pub(crate) fn listxattr(path: &CStr, list: &mut [ffi::c_char]) -> io::Result<usize> {
24092411
#[cfg(not(apple))]
24102412
unsafe {
24112413
ret_usize(c::listxattr(path.as_ptr(), list.as_mut_ptr(), list.len()))
@@ -2423,7 +2425,7 @@ pub(crate) fn listxattr(path: &CStr, list: &mut [c::c_char]) -> io::Result<usize
24232425
}
24242426

24252427
#[cfg(any(apple, linux_kernel))]
2426-
pub(crate) fn llistxattr(path: &CStr, list: &mut [c::c_char]) -> io::Result<usize> {
2428+
pub(crate) fn llistxattr(path: &CStr, list: &mut [ffi::c_char]) -> io::Result<usize> {
24272429
#[cfg(not(apple))]
24282430
unsafe {
24292431
ret_usize(c::llistxattr(path.as_ptr(), list.as_mut_ptr(), list.len()))
@@ -2441,7 +2443,7 @@ pub(crate) fn llistxattr(path: &CStr, list: &mut [c::c_char]) -> io::Result<usiz
24412443
}
24422444

24432445
#[cfg(any(apple, linux_kernel))]
2444-
pub(crate) fn flistxattr(fd: BorrowedFd<'_>, list: &mut [c::c_char]) -> io::Result<usize> {
2446+
pub(crate) fn flistxattr(fd: BorrowedFd<'_>, list: &mut [ffi::c_char]) -> io::Result<usize> {
24452447
let fd = borrowed_fd(fd);
24462448

24472449
#[cfg(not(apple))]

src/backend/libc/mount/types.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::backend::c;
2+
use crate::ffi;
23
use bitflags::bitflags;
34

45
#[cfg(linux_kernel)]
@@ -8,7 +9,7 @@ bitflags! {
89
/// [`mount`]: crate::mount::mount
910
#[repr(transparent)]
1011
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
11-
pub struct MountFlags: c::c_ulong {
12+
pub struct MountFlags: ffi::c_ulong {
1213
/// `MS_BIND`
1314
const BIND = c::MS_BIND;
1415

@@ -90,7 +91,7 @@ bitflags! {
9091
/// [`fsopen`]: crate::mount::fsopen
9192
#[repr(transparent)]
9293
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
93-
pub struct FsOpenFlags: c::c_uint {
94+
pub struct FsOpenFlags: ffi::c_uint {
9495
/// `FSOPEN_CLOEXEC`
9596
const FSOPEN_CLOEXEC = 0x0000_0001;
9697

@@ -107,7 +108,7 @@ bitflags! {
107108
/// [`fsmount`]: crate::mount::fsmount
108109
#[repr(transparent)]
109110
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
110-
pub struct FsMountFlags: c::c_uint {
111+
pub struct FsMountFlags: ffi::c_uint {
111112
/// `FSMOUNT_CLOEXEC`
112113
const FSMOUNT_CLOEXEC = 0x0000_0001;
113114

@@ -155,7 +156,7 @@ bitflags! {
155156
/// [`fsmount`]: crate::mount::fsmount
156157
#[repr(transparent)]
157158
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
158-
pub struct MountAttrFlags: c::c_uint {
159+
pub struct MountAttrFlags: ffi::c_uint {
159160
/// `MOUNT_ATTR_RDONLY`
160161
const MOUNT_ATTR_RDONLY = 0x0000_0001;
161162

@@ -205,7 +206,7 @@ bitflags! {
205206
/// [`move_mount`]: crate::mount::move_mount
206207
#[repr(transparent)]
207208
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
208-
pub struct MoveMountFlags: c::c_uint {
209+
pub struct MoveMountFlags: ffi::c_uint {
209210
/// `MOVE_MOUNT_F_EMPTY_PATH`
210211
const MOVE_MOUNT_F_SYMLINKS = 0x0000_0001;
211212

@@ -247,7 +248,7 @@ bitflags! {
247248
/// [`open_tree`]: crate::mount::open_tree
248249
#[repr(transparent)]
249250
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
250-
pub struct OpenTreeFlags: c::c_uint {
251+
pub struct OpenTreeFlags: ffi::c_uint {
251252
/// `OPENTREE_CLONE`
252253
const OPEN_TREE_CLONE = 1;
253254

@@ -279,7 +280,7 @@ bitflags! {
279280
/// [`fspick`]: crate::mount::fspick
280281
#[repr(transparent)]
281282
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
282-
pub struct FsPickFlags: c::c_uint {
283+
pub struct FsPickFlags: ffi::c_uint {
283284
/// `FSPICK_CLOEXEC`
284285
const FSPICK_CLOEXEC = 0x0000_0001;
285286

@@ -304,7 +305,7 @@ bitflags! {
304305
/// [`mount_change`]: crate::mount::mount_change
305306
#[repr(transparent)]
306307
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
307-
pub struct MountPropagationFlags: c::c_ulong {
308+
pub struct MountPropagationFlags: ffi::c_ulong {
308309
/// `MS_SILENT`
309310
const SILENT = c::MS_SILENT;
310311
/// `MS_SHARED`

src/backend/libc/thread/syscalls.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ pub(crate) fn clock_nanosleep_relative(id: ClockId, request: &Timespec) -> Nanos
8282
let flags = 0;
8383
let mut remain = MaybeUninit::<Timespec>::uninit();
8484

85-
match c::clock_nanosleep(id as c::clockid_t, flags, request, remain.as_mut_ptr()) {
85+
match c::clock_nanosleep(
86+
id as c::clockid_t,
87+
flags,
88+
request as *const Timespec as *const libc::timespec,
89+
remain.as_mut_ptr().cast(),
90+
) {
8691
0 => NanosleepRelativeResult::Ok,
8792
err if err == io::Errno::INTR.0 => {
8893
NanosleepRelativeResult::Interrupted(remain.assume_init())
@@ -179,7 +184,14 @@ pub(crate) fn clock_nanosleep_absolute(id: ClockId, request: &Timespec) -> io::R
179184
{
180185
let flags = c::TIMER_ABSTIME;
181186

182-
match unsafe { c::clock_nanosleep(id as c::clockid_t, flags as _, request, null_mut()) } {
187+
match unsafe {
188+
c::clock_nanosleep(
189+
id as c::clockid_t,
190+
flags as _,
191+
request as *const Timespec as *const libc::timespec,
192+
null_mut(),
193+
)
194+
} {
183195
0 => Ok(()),
184196
err => Err(io::Errno(err)),
185197
}
@@ -237,7 +249,10 @@ pub(crate) fn nanosleep(request: &Timespec) -> NanosleepRelativeResult {
237249
unsafe {
238250
let mut remain = MaybeUninit::<Timespec>::uninit();
239251

240-
match ret(c::nanosleep(request, remain.as_mut_ptr())) {
252+
match ret(c::nanosleep(
253+
request as *const Timespec as *const libc::timespec,
254+
remain.as_mut_ptr().cast(),
255+
)) {
241256
Ok(()) => NanosleepRelativeResult::Ok,
242257
Err(io::Errno::INTR) => NanosleepRelativeResult::Interrupted(remain.assume_init()),
243258
Err(err) => NanosleepRelativeResult::Err(err),

0 commit comments

Comments
 (0)