Skip to content

Commit 7491ac8

Browse files
willnodeJohnTitor
authored andcommitted
redox: Add *at and dirent functions
1 parent 88ea64b commit 7491ac8

3 files changed

Lines changed: 48 additions & 16 deletions

File tree

libc-test/semver/redox.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ ATF_COM
44
ATF_PERM
55
ATF_PUBL
66
ATF_USETRAILERS
7+
AT_EACCESS
8+
AT_EMPTY_PATH
79
AT_FDCWD
10+
AT_REMOVEDIR
11+
AT_SYMLINK_FOLLOW
12+
AT_SYMLINK_NOFOLLOW
813
B1000000
914
B1152000
1015
B1500000
@@ -140,6 +145,7 @@ O_NOCTTY
140145
O_PATH
141146
O_SHLOCK
142147
O_SYMLINK
148+
O_SYNC
143149
PTHREAD_MUTEX_DEFAULT
144150
PTHREAD_MUTEX_ERRORCHECK
145151
PTHREAD_MUTEX_ROBUST
@@ -199,6 +205,8 @@ TCSETS
199205
TIOCGPGRP
200206
TIOCSCTTY
201207
TIOCSPGRP
208+
UTIME_NOW
209+
UTIME_OMIT
202210
UTSLENGTH
203211
VDISCARD
204212
VLNEXT
@@ -291,6 +299,8 @@ __errno_location
291299
bsearch
292300
chroot
293301
clearerr
302+
clock_getres
303+
clock_gettime
294304
difftime
295305
dirfd
296306
endgrent
@@ -302,7 +312,9 @@ epoll_ctl
302312
epoll_event
303313
epoll_wait
304314
explicit_bzero
315+
faccessat
305316
fchdir
317+
fdopendir
306318
fmemopen
307319
getdtablesize
308320
getgrent
@@ -325,18 +337,22 @@ lockf
325337
login_tty
326338
madvise
327339
memalign
340+
mkdirat
341+
mknodat
328342
mkostemp
329343
mkostemps
330344
nice
331345
open_memstream
332346
open_wmemstream
347+
openat
333348
openpty
334349
pipe2
335350
pthread_condattr_setclock
336351
qsort
337352
reallocarray
338353
renameat2
339354
rlim_t
355+
seekdir
340356
sem_clockwait
341357
sem_destroy
342358
sem_getvalue
@@ -363,3 +379,4 @@ strncasecmp
363379
strndup
364380
strsignal
365381
ttyname_r
382+
utimensat

src/unix/mod.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,15 @@ extern "C" {
975975
)]
976976
#[cfg_attr(target_os = "netbsd", link_name = "__opendir30")]
977977
pub fn opendir(dirname: *const c_char) -> *mut crate::DIR;
978+
#[cfg_attr(
979+
all(target_os = "macos", target_arch = "x86_64"),
980+
link_name = "fdopendir$INODE64"
981+
)]
982+
#[cfg_attr(
983+
all(target_os = "macos", target_arch = "x86"),
984+
link_name = "fdopendir$INODE64$UNIX2003"
985+
)]
986+
pub fn fdopendir(fd: c_int) -> *mut crate::DIR;
978987

979988
#[cfg_attr(
980989
all(target_os = "macos", not(target_arch = "aarch64")),
@@ -1012,6 +1021,8 @@ extern "C" {
10121021
group: crate::gid_t,
10131022
flags: c_int,
10141023
) -> c_int;
1024+
#[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")]
1025+
pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int;
10151026
#[cfg_attr(
10161027
all(target_os = "macos", not(target_arch = "aarch64")),
10171028
link_name = "fstatat$INODE64"
@@ -1037,6 +1048,8 @@ extern "C" {
10371048
flags: c_int,
10381049
) -> c_int;
10391050
#[cfg(not(target_os = "l4re"))]
1051+
pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
1052+
#[cfg(not(target_os = "l4re"))]
10401053
pub fn renameat(
10411054
olddirfd: c_int,
10421055
oldpath: *const c_char,
@@ -2214,22 +2227,6 @@ cfg_if! {
22142227
link_name = "pause$UNIX2003"
22152228
)]
22162229
pub fn pause() -> c_int;
2217-
2218-
#[cfg(not(target_os = "l4re"))]
2219-
pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
2220-
#[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")]
2221-
pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int;
2222-
2223-
#[cfg_attr(
2224-
all(target_os = "macos", target_arch = "x86_64"),
2225-
link_name = "fdopendir$INODE64"
2226-
)]
2227-
#[cfg_attr(
2228-
all(target_os = "macos", target_arch = "x86"),
2229-
link_name = "fdopendir$INODE64$UNIX2003"
2230-
)]
2231-
pub fn fdopendir(fd: c_int) -> *mut crate::DIR;
2232-
22332230
#[cfg_attr(
22342231
all(target_os = "macos", not(target_arch = "aarch64")),
22352232
link_name = "readdir_r$INODE64"

src/unix/redox/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,11 @@ pub const F_TLOCK: c_int = 2;
345345
pub const F_TEST: c_int = 3;
346346

347347
pub const AT_FDCWD: c_int = -100;
348+
pub const AT_SYMLINK_NOFOLLOW: c_int = 0x200;
349+
pub const AT_REMOVEDIR: c_int = 0x200;
350+
pub const AT_SYMLINK_FOLLOW: c_int = 0x2000;
351+
pub const AT_EMPTY_PATH: c_int = 0x4000;
352+
pub const AT_EACCESS: c_int = 0x400;
348353

349354
// FIXME(redox): relibc {
350355
pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut();
@@ -516,6 +521,7 @@ pub const O_SHLOCK: c_int = 0x0010_0000;
516521
pub const O_EXLOCK: c_int = 0x0020_0000;
517522
pub const O_ASYNC: c_int = 0x0040_0000;
518523
pub const O_FSYNC: c_int = 0x0080_0000;
524+
pub const O_SYNC: c_int = O_FSYNC;
519525
pub const O_CLOEXEC: c_int = 0x0100_0000;
520526
pub const O_CREAT: c_int = 0x0200_0000;
521527
pub const O_TRUNC: c_int = 0x0400_0000;
@@ -725,6 +731,8 @@ pub const S_IRWXO: c_int = 0o0007;
725731
pub const S_IROTH: c_int = 0o0004;
726732
pub const S_IWOTH: c_int = 0o0002;
727733
pub const S_IXOTH: c_int = 0o0001;
734+
pub const UTIME_NOW: c_long = 0xffffffff;
735+
pub const UTIME_OMIT: c_long = 0xfffffffe;
728736

729737
// stdlib.h
730738
pub const EXIT_SUCCESS: c_int = 0;
@@ -1204,8 +1212,10 @@ extern "C" {
12041212

12051213
// dirent.h
12061214
pub fn dirfd(dirp: *mut crate::DIR) -> c_int;
1215+
pub fn seekdir(dirp: *mut crate::DIR, loc: c_long);
12071216

12081217
// unistd.h
1218+
pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int;
12091219
pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int;
12101220
pub fn getdtablesize() -> c_int;
12111221
pub fn getresgid(
@@ -1406,6 +1416,13 @@ extern "C" {
14061416

14071417
// sys/stat.h
14081418
pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int;
1419+
pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
1420+
pub fn utimensat(
1421+
dirfd: c_int,
1422+
path: *const c_char,
1423+
times: *const crate::timespec,
1424+
flag: c_int,
1425+
) -> c_int;
14091426

14101427
// sys/uio.h
14111428
pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
@@ -1418,6 +1435,7 @@ extern "C" {
14181435

14191436
// time.h
14201437
pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int;
1438+
pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
14211439
pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
14221440
pub fn strftime(
14231441
s: *mut c_char,

0 commit comments

Comments
 (0)