Kernel: Fix directory permissions
We did not care about X bit in directories and instead used only the R bit for search/read.
This commit is contained in:
@@ -58,7 +58,7 @@ DIR* fdopendir(int fd)
|
||||
|
||||
DIR* opendir(const char* dirname)
|
||||
{
|
||||
int fd = open(dirname, O_SEARCH);
|
||||
int fd = open(dirname, O_RDONLY);
|
||||
if (fd == -1)
|
||||
return nullptr;
|
||||
return fdopendir(fd);
|
||||
|
||||
@@ -52,6 +52,8 @@ __BEGIN_DECLS
|
||||
#define SYS_SET_PGID 45
|
||||
#define SYS_FCNTL 46
|
||||
#define SYS_NANOSLEEP 47
|
||||
#define SYS_FSTATAT 48
|
||||
#define SYS_STAT 49 // stat/lstat
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
@@ -11,38 +11,15 @@ int fstat(int fildes, struct stat* buf)
|
||||
|
||||
int fstatat(int fd, const char* __restrict path, struct stat* __restrict buf, int flag)
|
||||
{
|
||||
if (flag == AT_SYMLINK_NOFOLLOW)
|
||||
flag = O_NOFOLLOW;
|
||||
else if (flag)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int target = openat(fd, path, O_SEARCH | flag);
|
||||
if (target == -1)
|
||||
return -1;
|
||||
int ret = fstat(target, buf);
|
||||
close(target);
|
||||
return ret;
|
||||
return syscall(SYS_FSTATAT, fd, path, buf, flag);
|
||||
}
|
||||
|
||||
int lstat(const char* __restrict path, struct stat* __restrict buf)
|
||||
{
|
||||
int fd = open(path, O_SEARCH | O_NOFOLLOW);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
int ret = fstat(fd, buf);
|
||||
close(fd);
|
||||
return ret;
|
||||
return syscall(SYS_STAT, path, buf, AT_SYMLINK_NOFOLLOW);
|
||||
}
|
||||
|
||||
int stat(const char* __restrict path, struct stat* __restrict buf)
|
||||
{
|
||||
int fd = open(path, O_SEARCH);
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
int ret = fstat(fd, buf);
|
||||
close(fd);
|
||||
return ret;
|
||||
return syscall(SYS_STAT, path, buf, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user