mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
parent
55815e4a3a
commit
5f1a66b90c
@ -273,6 +273,7 @@ namespace Noux {
|
||||
|
||||
enum General_error { ERR_FD_INVALID, NUM_GENERAL_ERRORS };
|
||||
enum Stat_error { STAT_ERR_NO_ENTRY = NUM_GENERAL_ERRORS };
|
||||
enum Fchdir_error { FCHDIR_ERR_NOT_DIR = NUM_GENERAL_ERRORS };
|
||||
enum Fcntl_error { FCNTL_ERR_CMD_INVALID = NUM_GENERAL_ERRORS };
|
||||
enum Open_error { OPEN_ERR_UNACCESSIBLE, OPEN_ERR_NO_PERM };
|
||||
enum Execve_error { EXECVE_NONEXISTENT = NUM_GENERAL_ERRORS };
|
||||
@ -286,6 +287,7 @@ namespace Noux {
|
||||
union {
|
||||
General_error general;
|
||||
Stat_error stat;
|
||||
Fchdir_error fchdir;
|
||||
Fcntl_error fcntl;
|
||||
Open_error open;
|
||||
Execve_error execve;
|
||||
|
@ -983,8 +983,10 @@ namespace {
|
||||
{
|
||||
sysio()->fchdir_in.fd = noux_fd(fd->context);
|
||||
if (!noux()->syscall(Noux::Session::SYSCALL_FCHDIR)) {
|
||||
PERR("fchdir error");
|
||||
/* XXX set errno */
|
||||
switch (sysio()->error.fchdir) {
|
||||
case Noux::Sysio::FCHDIR_ERR_NOT_DIR: errno = ENOTDIR; break;
|
||||
default: errno = EPERM; break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,13 @@ namespace Noux {
|
||||
|
||||
bool fstat(Sysio *sysio)
|
||||
{
|
||||
return _fh->ds()->stat(sysio, _leaf_path.base());
|
||||
/*
|
||||
* 'sysio.stat_in' is not used in '_fh->ds()->stat()',
|
||||
* so no 'sysio' member translation is needed here
|
||||
*/
|
||||
bool result = _fh->ds()->stat(sysio, _leaf_path.base());
|
||||
sysio->fstat_out.st = sysio->stat_out.st;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool fcntl(Sysio *sysio)
|
||||
@ -78,6 +84,16 @@ namespace Noux {
|
||||
|
||||
bool fchdir(Sysio *sysio, Pwd *pwd)
|
||||
{
|
||||
sysio->fstat_in.fd = sysio->fchdir_in.fd;
|
||||
|
||||
fstat(sysio);
|
||||
|
||||
if ((sysio->fstat_out.st.mode & Sysio::STAT_MODE_DIRECTORY) !=
|
||||
Sysio::STAT_MODE_DIRECTORY) {
|
||||
sysio->error.fchdir = Sysio::FCHDIR_ERR_NOT_DIR;
|
||||
return false;
|
||||
}
|
||||
|
||||
pwd->pwd(_path.base());
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user