mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +00:00
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.
This commit is contained in:
parent
ad53f6afd3
commit
c30e2c8d44
22 changed files with 156 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#define __ENUMERATE_ALL_ERRORS \
|
||||
__ERROR(ESUCCESS, "Success (not an error)") \
|
||||
__ERROR(EPERM, "Operation not permitted") \
|
||||
__ERROR(ENOENT, "No such file or directory") \
|
||||
__ERROR(ESRCH, "No such process") \
|
||||
|
|
|
@ -15,5 +15,11 @@ int mkdir(const char* pathname, mode_t 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ typedef uint32_t ino_t;
|
|||
typedef int32_t off_t;
|
||||
|
||||
typedef uint32_t dev_t;
|
||||
typedef uint32_t mode_t;
|
||||
typedef uint16_t mode_t;
|
||||
typedef uint32_t nlink_t;
|
||||
typedef uint32_t blksize_t;
|
||||
typedef uint32_t blkcnt_t;
|
||||
|
|
|
@ -97,7 +97,7 @@ int open(const char* path, int options, ...)
|
|||
{
|
||||
va_list ap;
|
||||
va_start(ap, options);
|
||||
int rc = syscall(SC_open, path, options, va_arg(ap, mode_t));
|
||||
int rc = syscall(SC_open, path, options, (mode_t)va_arg(ap, unsigned));
|
||||
va_end(ap);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue