genodelabs/genode — Issue #68: Noux: chdir seems broken/not implemented?
Author: blitz
Created: 2012-01-08 22:41:57+00:00
State: open

chdir/fchdir doesn't seem to work. stat on directories (at least /) seems broken as well. chdir/fchdir don't set errno on failure.

Consider the following test program:

```C
// -*- Mode: C++ -*-

#include
#include
#include

#include
#include
#include

int main(int argc, char **argv)
{
struct stat st;
printf("stat(/) -> %d\n", stat("/", &st));
printf("errno = %x\n", errno); errno = 0xDEAD;

printf("chdir -> %d\n", chdir("/"));
printf("errno = %x\n", errno); errno = 0xDEAD;

int fd = open("/", O_RDONLY);
printf("open -> %d\n", fd);
printf("errno = %x\n", errno); errno = 0xDEAD;
printf("fchdir -> %d\n", fchdir(fd));
printf("errno = %x\n", errno); errno = 0xDEAD;
return 0;
}

// EOF
```

Output on Linux (errno is meaningless, because no syscall failed):
stat(/) -> 0
errno = 0
chdir -> 0
errno = dead
open -> 3
errno = dead
fchdir -> 0
errno = dead

Output with noux:
stat(/) -> -1
errno = 2
chdir -> -1
errno = dead
open -> -1
errno = 2
fchdir -> -1
errno = dead

After each failed syscall errno should be something other than DEAD.

Noux log:
[init -> noux] --- noux started ---
[init] child "uart_drv" announces service "Terminal"
[init -> noux] created tar file system at ""
[init -> noux] tar archive 'jlibc.tar' local at 8000, size is 81920
[init -> timer] Timer::Timeout_scheduler::Timeout_scheduler(Platform_timer*, Genode::Rpc_entrypoint*): starting timeout scheduler
[init] child "timer" announces service "Timer"
start new pager object with EIP=0x101f7a0, ESP=0x401fefa0
start new pager object with EIP=0x102aee0, ESP=0x400fefa0
[init -> noux] virtual Genode::Dataspace_capability Noux::Tar_file_system::dataspace(const char*): copying /test-jlibc (74320 bytes) into new dataspace
[init -> noux] arg(0): "/test-jlibc"
start new pager object with EIP=0x575c8, ESP=0x6001000
start new pager object with EIP=0x1025fd0, ESP=0x401fefa0
[init -> noux -> /test-jlibc] Starting ldso ...
[init -> noux -> /test-jlibc] Starting application ... environ: 877e8
[init -> noux -> /test-jlibc] syscall STAT failed
[init -> noux -> /test-jlibc] stat syscall failed for path "/"
[init -> noux -> /test-jlibc] virtual int {anonymous}::Plugin::ioctl(Libc::File_descriptor*, int, char*): TIOCGETA - argp=0x10141b4
[init -> noux -> /test-jlibc] no plugin found for chdir("/")
[init -> noux] open pwd=/ path=/
[init -> noux] virtual Noux::Vfs_handle* Noux::Tar_file_system::open(Noux::Sysio*, const char*): open /
[init -> noux] no file system for "/"
[init -> noux -> /test-jlibc] syscall OPEN failed
[init -> noux -> /test-jlibc] plugin()->open("/") failed
[init -> noux -> /test-jlibc] no plugin found for fchdir(-1)
[init -> noux] child /test-jlibc exited with exit value 0
[init -> noux] init process exited
[init -> noux] -- exiting noux ---