Skip to content
Merged
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
9 changes: 0 additions & 9 deletions options/ansi/generic/stdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,15 +496,6 @@ int rename(const char *path, const char *new_path) {
return 0;
}

int renameat(int olddirfd, const char *old_path, int newdirfd, const char *new_path) {
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_renameat, -1);
if(int e = mlibc::sys_renameat(olddirfd, old_path, newdirfd, new_path); e) {
errno = e;
return -1;
}
return 0;
}

FILE *tmpfile(void) {
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_unlinkat, nullptr);

Expand Down
1 change: 0 additions & 1 deletion options/ansi/include/mlibc/ansi-sysdeps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ int sys_clock_get(int clock, time_t *secs, long *nanos);
[[gnu::weak]] int sys_rmdir(const char *path);
[[gnu::weak]] int sys_unlinkat(int dirfd, const char *path, int flags);
[[gnu::weak]] int sys_rename(const char *path, const char *new_path);
[[gnu::weak]] int sys_renameat(int olddirfd, const char *old_path, int newdirfd, const char *new_path);

[[gnu::weak]] int sys_sigprocmask(int how, const sigset_t *__restrict set,
sigset_t *__restrict retrieve);
Expand Down
1 change: 0 additions & 1 deletion options/ansi/include/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ extern FILE *stdout;

int remove(const char *__filename);
int rename(const char *__old_path, const char *__new_path);
int renameat(int __olddirfd, const char *__old_path, int __newdirfd, const char *__new_path);
FILE *tmpfile(void);
char *tmpnam(char *__buffer);

Expand Down
12 changes: 12 additions & 0 deletions options/linux/include/sys/quota.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
extern "C" {
#endif

struct dqblk {
uint64_t dqb_bhardlimit;
uint64_t dqb_bsoftlimit;
uint64_t dqb_curspace;
uint64_t dqb_ihardlimit;
uint64_t dqb_isoftlimit;
uint64_t dqb_curinodes;
uint64_t dqb_btime;
uint64_t dqb_itime;
uint32_t dqb_valid;
};

#ifndef __MLIBC_ABI_ONLY

int quotactl(int __cmd, const char *__special, int __id, __caddr_t __addr);
Expand Down
4 changes: 4 additions & 0 deletions options/posix/generic/dirent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,8 @@ int versionsort(const struct dirent **a, const struct dirent **b) {
return strverscmp((*a)->d_name, (*b)->d_name);
}

ssize_t getdents64(int fd, void *dirp, size_t count) {
return posix_getdents(fd, dirp, count, 0);
}

#endif // __MLIBC_GLIBC_OPTION
5 changes: 5 additions & 0 deletions options/posix/generic/mqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ mqd_t mq_open(const char *, int, ...) {
__ensure(!"Not implemented");
__builtin_unreachable();
}

ssize_t mq_receive(mqd_t, char *, size_t, unsigned int *) {
__ensure(!"Not implemented");
__builtin_unreachable();
}
14 changes: 14 additions & 0 deletions options/posix/generic/posix_stdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,17 @@ FILE *fopencookie(void *cookie, const char *__restrict mode, cookie_io_functions
return frg::construct<mlibc::cookie_file>(getAllocator(), cookie, flags, funcs,
mlibc::file_dispose_cb<mlibc::cookie_file>);
}

int renameat(int olddirfd, const char *old_path, int newdirfd, const char *new_path) {
MLIBC_CHECK_OR_ENOSYS(mlibc::sys_renameat, -1);
if(int e = mlibc::sys_renameat(olddirfd, old_path, newdirfd, new_path); e) {
errno = e;
return -1;
}
return 0;
}

int renameat2(int, const char *, int, const char *, unsigned int) {
__ensure(!"Not implemented");
__builtin_unreachable();
}
8 changes: 8 additions & 0 deletions options/posix/include/bits/posix/posix_stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ FILE *open_memstream(char **__buf, size_t *__sizeloc);
int fseeko(FILE *__stream, off_t __offset, int __whence);
off_t ftello(FILE *__stream);

#ifdef __MLIBC_POSIX2008
int renameat(int __olddirfd, const char *__old_path, int __newdirfd, const char *__new_path);
#endif /* __MLIBC_POSIX2008 */

#if __MLIBC_LINUX_OPTION && defined(_GNU_SOURCE)
int renameat2(int __olddirfd, const char *__old_path, int __newdirfd, const char *__new_path, unsigned int __flags);
#endif /* !__MLIBC_LINUX_OPTION && defined(_GNU_SOURCE) */

#if __MLIBC_LINUX_OPTION && defined(_LARGEFILE64_SOURCE)
int fseeko64(FILE *__stream, off64_t __offset, int __whence);
off64_t ftello64(FILE *__stream);
Expand Down
1 change: 1 addition & 0 deletions options/posix/include/dirent.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ long telldir(DIR *__dirp);

#if __MLIBC_GLIBC_OPTION && defined(_GNU_SOURCE)
int versionsort(const struct dirent **__a, const struct dirent **__b);
ssize_t getdents64(int __fd, void *__dirp, size_t __count);
#endif /* __MLIBC_GLIBC_OPTION && defined(_GNU_SOURCE) */

#endif /* !__MLIBC_ABI_ONLY */
Expand Down
3 changes: 3 additions & 0 deletions options/posix/include/mqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define _MQUEUE_H

#include <abi-bits/mqueue.h>
#include <bits/size_t.h>
#include <bits/ssize_t.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -15,6 +17,7 @@ int mq_getattr(mqd_t __mqdes, struct mq_attr *__attr);
int mq_setattr(mqd_t __mqdes, const struct mq_attr *__restrict__ __newattr, struct mq_attr *__restrict__ __oldattr);
int mq_unlink(const char *__name);
mqd_t mq_open(const char *__name, int __flags, ...);
ssize_t mq_receive(mqd_t __mqdes, char *__msg_ptr, size_t __msg_len, unsigned int *__msg_prio);

#endif /* !__MLIBC_ABI_ONLY */

Expand Down
19 changes: 13 additions & 6 deletions sysdeps/linux/generic/sysdeps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,17 @@ int sys_ppoll(struct pollfd *fds, nfds_t count, const struct timespec *ts, const
return 0;
}

int sys_renameat(int old_dirfd, const char *old_path, int new_dirfd, const char *new_path) {
#ifdef SYS_renameat2
auto ret = do_syscall(SYS_renameat2, old_dirfd, old_path, new_dirfd, new_path, 0);
#else
auto ret = do_syscall(SYS_renameat, old_dirfd, old_path, new_dirfd, new_path);
#endif /* defined(SYS_renameat2) */
if (int e = sc_error(ret); e)
return e;
return 0;
}

#endif // __MLIBC_LINUX_OPTION

int sys_times(struct tms *tms, clock_t *out) {
Expand Down Expand Up @@ -2207,14 +2218,10 @@ int sys_fchdir(int fd) {
}

int sys_rename(const char *old_path, const char *new_path) {
return sys_renameat(AT_FDCWD, old_path, AT_FDCWD, new_path);
}

int sys_renameat(int old_dirfd, const char *old_path, int new_dirfd, const char *new_path) {
#ifdef SYS_renameat2
auto ret = do_syscall(SYS_renameat2, old_dirfd, old_path, new_dirfd, new_path, 0);
auto ret = do_syscall(SYS_renameat2, AT_FDCWD, old_path, AT_FDCWD, new_path, 0);
#else
auto ret = do_syscall(SYS_renameat, old_dirfd, old_path, new_dirfd, new_path);
auto ret = do_syscall(SYS_renameat, AT_FDCWD, old_path, AT_FDCWD, new_path);
#endif /* defined(SYS_renameat2) */
if (int e = sc_error(ret); e)
return e;
Expand Down