diff --git a/os/sb/common/dirent.h b/os/sb/common/dirent.h index 9c936d4a9..44e00f97c 100644 --- a/os/sb/common/dirent.h +++ b/os/sb/common/dirent.h @@ -42,6 +42,16 @@ #define _DIRENT_HAVE_D_TYPE /** @} */ +/** + * @name File types + * @{ + */ +#define DT_REG IFTODT(S_IFREG) +#define DT_DIR IFTODT(S_IFDIR) +#define DT_CHR IFTODT(S_IFCHR) +#define DT_FIFO IFTODT(S_IFIFO) +/** @} */ + /*===========================================================================*/ /* Module pre-compile time settings. */ /*===========================================================================*/ diff --git a/os/sb/user/sbuser.h b/os/sb/user/sbuser.h index 56fe206e6..056dd5092 100644 --- a/os/sb/user/sbuser.h +++ b/os/sb/user/sbuser.h @@ -34,6 +34,7 @@ #include #include "errcodes.h" +#include "dirent.h" #include "sbsysc.h" /*===========================================================================*/ @@ -287,6 +288,19 @@ static inline off_t sbSeek(int fd, off_t offset, int whence) { return (off_t)r0; } +/** + * @brief Posix-style directory read. + * @param[in] fd file descriptor + * @param[in] buf buffer pointer + * @param[in] count number of bytes + * @return The number of bytes really transferred or an error. + */ +static inline ssize_t sbPosixGetdents(int fd, void *buf, size_t count) { + + __syscall4r(0, SB_POSIX_GETDENTS, fd, buf, count); + return (ssize_t)r0; +} + /** * @brief Terminates the sandbox. *