feat(stat): stat/mkdir/chmod and mode macros

This commit is contained in:
2026-09-05 16:35:50 -04:00
parent 87ab610a9b
commit 98f4c3169c
11 changed files with 935 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/stat.h>
#include "../internal/syscall.h"
#include "stat_impl.h"
#if VLIBC_LEVEL_GE(2)
/*
* mknod/mknodat over SYS_mknodat (XSI, level 2). The mode argument must
* carry a file-type bit (S_IFIFO, S_IFCHR, S_IFBLK, S_IFREG, ...); dev is
* the raw device id for the S_IFCHR/S_IFBLK cases and is otherwise
* ignored by the kernel. Creating device nodes requires privilege
* (CAP_MKNOD); creating a FIFO or a regular file does not.
*/
int
mknodat(int fd, const char *path, mode_t mode, dev_t dev)
{
return syscall_ret(__syscall4(SYS_mknodat, fd, (long)path, (long)mode, (long)dev));
}
int
mknod(const char *path, mode_t mode, dev_t dev)
{
return mknodat(VLIBC_STAT_AT_FDCWD, path, mode, dev);
}
#endif /* VLIBC_LEVEL_GE(2) */