Skip to content

Commit

Permalink
[orbis-kernel] sys_stat: check for dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekotekina committed Jul 18, 2023
1 parent ebb6c58 commit a7b18c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions orbis-kernel/src/sys/sys_descrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ orbis::SysResult orbis::sys_closefrom(Thread *thread, sint lowfd) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_fstat(Thread *thread, sint fd, ptr<Stat> ub) {
ORBIS_LOG_TODO(__FUNCTION__, fd, ub);
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_nfstat(Thread *thread, sint fd,
Expand Down
21 changes: 14 additions & 7 deletions orbis-kernel/src/sys/sys_vfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ orbis::SysResult orbis::sys_eaccess(Thread *thread, ptr<char> path,
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_stat(Thread *thread, ptr<char> path, ptr<Stat> ub) {
ORBIS_LOG_TODO(__FUNCTION__, path, ub);
ORBIS_LOG_WARNING(__FUNCTION__, path, ub);
auto result = sys_open(thread, path, 0, 0);
if (result.isError()) {
return result;
return ErrorCode::NOENT;
}

auto fd = thread->retval[0];
Expand All @@ -119,11 +119,18 @@ orbis::SysResult orbis::sys_stat(Thread *thread, ptr<char> path, ptr<Stat> ub) {
}

auto len = thread->retval[0];
*ub = {};
ub->size = len;
ub->blksize = 1;
ub->blocks = len;
ub->mode = 0777 | 0x8000;
result = sys_pread(thread, fd, ub, 1, 0);
if (result.isError()) {
*ub = {};
ub->mode = 0777 | 0x4000;
} else {
*ub = {};
ub->size = len;
ub->blksize = 1;
ub->blocks = len;
ub->mode = 0777 | 0x8000;
}

sys_close(thread, fd);
thread->retval[0] = 0;
return {};
Expand Down

0 comments on commit a7b18c7

Please sign in to comment.