serenity/LibC/stat.cpp
Andreas Kling c30e2c8d44 Implement basic chmod() syscall and /bin/chmod helper.
Only raw octal modes are supported right now.
This patch also changes mode_t from 32-bit to 16-bit to match the on-disk
type used by Ext2FS.

I also ran into EPERM being errno=0 which was confusing, so I inserted an
ESUCCESS in its place.
2019-01-29 04:55:08 +01:00

26 lines
424 B
C++

#include <sys/stat.h>
#include <errno.h>
#include <Kernel/Syscall.h>
extern "C" {
mode_t umask(mode_t mask)
{
return syscall(SC_umask, mask);
}
int mkdir(const char* pathname, mode_t mode)
{
int rc = syscall(SC_mkdir, pathname, mode);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int chmod(const char* pathname, mode_t mode)
{
int rc = syscall(SC_chmod, pathname, mode);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}