Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc-test/semver/dragonfly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,7 @@ freezero
fsid_t
fstatfs
futimes
getdents
getdomainname
getdtablesize
getentropy
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/freebsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,7 @@ fsid_t
fstatfs
ftok
futimes
getdents
getdomainname
getdtablesize
getgrent
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/hurd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
getdents64
1 change: 1 addition & 0 deletions libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ fgetpwent_r
fgetspent_r
futimes
getauxval
getdents64
getentropy
getgrent_r
getloadavg
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/linux-musl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ euidaccess
explicit_bzero
futimes
getauxval
getdents
getdents64
getloadavg
getutxent
getutxid
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/netbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,7 @@ ftok
futimes
getbootfile
getbyteorder
getdents
getdiskrawname
getdistcookedname
getdomainname
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/openbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,7 @@ ftok
fusefs_args
futex
futimes
getdents
getdomainname
getdtablesize
getentropy
Expand Down
2 changes: 2 additions & 0 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,8 @@ extern "C" {
) -> c_int;

pub fn closefrom(lowfd: c_int) -> c_int;

pub fn getdents(fd: c_int, buf: *mut c_char, nbytes: c_int) -> c_int;
}

#[link(name = "rt")]
Expand Down
4 changes: 4 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4818,6 +4818,10 @@ cfg_if! {
}
}

extern "C" {
pub fn getdents(fd: c_int, buf: *mut c_char, nbytes: usize) -> isize;
}

extern "C" {
#[cfg_attr(doc, doc(alias = "__errno_location"))]
#[cfg_attr(doc, doc(alias = "errno"))]
Expand Down
2 changes: 2 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2957,6 +2957,8 @@ extern "C" {
pub fn flags_to_string(flags: c_ulong, def: *const c_char) -> c_int;

pub fn kinfo_getvmmap(pid: crate::pid_t, cntp: *mut size_t) -> *mut kinfo_vmentry;

pub fn getdents(fd: c_int, buf: *mut c_char, nbytes: usize) -> c_int;
}

#[link(name = "execinfo")]
Expand Down
2 changes: 2 additions & 0 deletions src/unix/bsd/netbsdlike/openbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,8 @@ extern "C" {
pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int;
pub fn getmntinfo(mntbufp: *mut *mut crate::statfs, flags: c_int) -> c_int;
pub fn getfsstat(buf: *mut statfs, bufsize: size_t, flags: c_int) -> c_int;

pub fn getdents(fd: c_int, buf: *mut c_void, nbytes: usize) -> c_int;
}

#[link(name = "execinfo")]
Expand Down
2 changes: 2 additions & 0 deletions src/unix/hurd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4282,6 +4282,8 @@ extern "C" {
pub fn seekdir(dirp: *mut crate::DIR, loc: c_long);
pub fn telldir(dirp: *mut crate::DIR) -> c_long;

pub fn getdents64(fd: c_int, buf: *mut c_void, nbytes: usize) -> isize;

pub fn dirfd(dirp: *mut crate::DIR) -> c_int;

#[link_name = "__xpg_strerror_r"]
Expand Down
7 changes: 7 additions & 0 deletions src/unix/linux_like/linux/gnu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,13 @@ extern "C" {
pub fn mempcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
}

extern "C" {
// There is no glibc wrapper for the getdents system call, and getdents64() is only available
// from 2.30 onwards.
/// `buffer` points to a buffer of [`crate::dirent64`] structs.
pub fn getdents64(fd: c_int, buffer: *mut c_void, nbytes: usize) -> isize;
}

cfg_if! {
if #[cfg(any(
target_arch = "x86",
Expand Down
5 changes: 5 additions & 0 deletions src/unix/linux_like/linux/musl/lfs64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ pub unsafe extern "C" fn readdir64_r(
crate::readdir_r(dirp, entry as *mut _, result as *mut _)
}

#[inline]
pub unsafe extern "C" fn getdents64(fd: c_int, buf: *mut crate::dirent64, len: usize) -> c_int {
crate::getdents(fd, buf as *mut _, len)
}

#[inline]
pub unsafe extern "C" fn sendfile64(
out_fd: c_int,
Expand Down
4 changes: 4 additions & 0 deletions src/unix/linux_like/linux/musl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,10 @@ extern "C" {
pub fn utmpxname(file: *const c_char) -> c_int;
}

extern "C" {
pub fn getdents(fd: c_int, buf: *mut crate::dirent, len: usize) -> c_int;
}

// Alias <foo> to <foo>64 to mimic glibc's LFS64 support
mod lfs64;
pub use self::lfs64::*;
Expand Down