Import the article about how to migrate from ScratchBox2.
Print syscall names as strings instead of numbers, à la strace.

Before:

  sysenter start: 157, 0x16, 0x2, 0x7fff2700cb10, 0xffffffffffffffff, 0x0, 0x8) = 0xffffffffffffffda [0x7fff2700caf8]
  sysenter start: 59, 0x18448f0, 0x1842510, 0x7fff2700ccf0, 0x7fff2700c910, 0x1, 0x0) = 0xffffffffffffffda [0x7fff2700cae8]

Now:

  sysenter start: prctl(0x16, 0x2, 0x7fffcdc5c560, 0x4125c1, 0x0, 0x8) = 0xffffffffffffffda [0x7fffcdc5c508, 0]
  sysenter start: execve(0x6af900, 0x6ad520, 0x7fffcdc5c750, 0x7fffcdc5c3a0, 0x0, 0x0) = 0xffffffffffffffda [0x7fffcdc5c578, 0]
Emulate tracees' heap (brk) with a regular memory mapping (mmap, mremap).

With some versions of the Linux kernel and some versions of the GNU ELF
interpreter (ld.so), the heap can't grow at all because the kernel has put
a memory mapping right after the heap.  This issue can be reproduced when
using a Ubuntu 12.04 x86_64 rootfs on RHEL 5 x86_64.
Remove the stack limit constraint, its side effect is not needed anymore.

The heap emulation fixes this problem definitively.
Fix translate_path(): return -EBADF if the file descriptor is not valid.

Before:

    $ proot ./ltp-full-20130503/testcases/kernel/syscalls/fchdir/fchdir02
    fchdir02    1  TFAIL  :  call failed unexpectedly: TEST_ERRNO=EPERM(1): Operation not permitted

Now:

    $ proot ./ltp-full-20130503/testcases/kernel/syscalls/fchdir/fchdir02
    fchdir02    1  TPASS  :  failed as expected with EBADF
Fix translate_path(): return correct errno when dir_fd points to an unreachable path.

Before:

    $ proot ./ltp-full-20130503/testcases/kernel/syscalls/linkat/linkat01
    [...]
    linkat01   16  TFAIL  :  linkat failed unexpectedly; expected 2 - No such file or directory: TEST_ERRNO=ENOTDIR(20): Not a directory
    linkat01   17  TFAIL  :  linkat failed unexpectedly; expected 2 - No such file or directory: TEST_ERRNO=ENOTDIR(20): Not a directory
    [...]

Now:

    $ proot ./ltp-full-20130503/testcases/kernel/syscalls/linkat/linkat01
    [...]
    linkat01   16  TPASS  :  linkat failed as expected: TEST_ERRNO=ENOENT(2): No such file or directory
    linkat01   17  TPASS  :  linkat failed as expected: TEST_ERRNO=ENOENT(2): No such file or directory
    [...]
Fix the sysenter handling of socket syscalls: return correct errno.

Before:

    $ proot -w ./ltp-full-20130503/ ./runltp -f syscalls
    [...]
    accept01    4  TFAIL  :  invalid salen ; returned -1 (expected -1), errno 5 (expected 22)
    [...]
    getpeername01    5  TFAIL  :  invalid aligned salen ; returned -1 (expected -1), errno 5 (expected 14)
    getpeername01    6  TFAIL  :  invalid unaligned salen ; returned -1 (expected -1), errno 5 (expected 14)
    [...]
    getsockname01    4  TFAIL  :  invalid aligned salen ; returned -1 (expected -1), errno 5 (expected 14)
    getsockname01    5  TFAIL  :  invalid unaligned salen ; returned -1 (expected -1), errno 5 (expected 14)
    [...]

Now:

    $ proot -w ./ltp-full-20130503/ ./runltp -f syscalls
    [...]
    accept01    4  TPASS  :  invalid salen successful
    [...]
    getpeername01    5  TPASS  :  invalid aligned salen successful
    getpeername01    6  TPASS  :  invalid unaligned salen successful
    [...]
    getsockname01    4  TPASS  :  invalid aligned salen successful
    getsockname01    5  TPASS  :  invalid unaligned salen successful
    [...]
Fix expand_interp(): don't overwrite argv[0] when it's the NULL terminator.

Before:

    $ proot -R rootfs -w ltp-full-20130503/testcases/bin ./execve04 -F ./test3
    proot: ./tracee/array.c:415: push_array: Assertion `local_count < array->length + 1' failed.

Now:

    $ proot -R rootfs -w ltp-full-20130503/testcases/bin ./execve04 -F ./test3
    Hello World
    execve04    1  TFAIL  :  execve succeeded, expected failure

At least, it doesn't abort anymore...
Introduce read_path(), a new helper for read_string(PATH_MAX).
Introduce substitute_path_prefix(), extracted from substitute_binding().
Fix the sysexit handling of rename[at] when used to move [a prefix of] cwd.

Before:

    $ proot ./ltp-full-20130503/testcases/kernel/syscalls/inotify/inotify02
    inotify02    8  TBROK  :  unlink(test_file2) failed: errno=ENOENT(2): No such file or directory
    inotify02    9  TBROK  :  Remaining cases broken
    inotify02    0  TWARN  :  tst_rmdir: rmobj(/tmp/inoHPzj80) failed: lstat(/tmp/inoHPzj80) failed; errno=2: No such file or directory

Now:

    $ proot ./ltp-full-20130503/testcases/kernel/syscalls/inotify/inotify02
    inotify02    1  TPASS  :  get event: wd=1 mask=40000004 cookie=0 len=0 name=""
    inotify02    2  TPASS  :  get event: wd=1 mask=100 cookie=0 len=16 name="test_file1"
    inotify02    3  TPASS  :  get event: wd=1 mask=20 cookie=0 len=16 name="test_file1"
    inotify02    4  TPASS  :  get event: wd=1 mask=8 cookie=0 len=16 name="test_file1"
    inotify02    5  TPASS  :  get event: wd=1 mask=40 cookie=11309409 len=16 name="test_file1"
    inotify02    6  TPASS  :  get event: wd=1 mask=80 cookie=11309409 len=16 name="test_file2"
    inotify02    7  TPASS  :  get event: wd=1 mask=800 cookie=0 len=0 name=""
    inotify02    8  TPASS  :  get event: wd=1 mask=200 cookie=0 len=16 name="test_file2"
    inotify02    9  TPASS  :  get event: wd=1 mask=800 cookie=0 len=0 name=""
Fix off-by-one in read/write_data() when there are no "trailing" bytes.

PEEKDATA might fail due to an illegal access.  It seems I was
(un)lucky so far: this could happen only on a page boundary.