diff --git a/LibOS/shim/src/fs/shim_namei.c b/LibOS/shim/src/fs/shim_namei.c index 8c4aac13..de9be8e0 100644 --- a/LibOS/shim/src/fs/shim_namei.c +++ b/LibOS/shim/src/fs/shim_namei.c @@ -385,10 +385,12 @@ int __path_lookupat (struct shim_dentry * start, const char * path, int flags, put_dentry(my_dent); my_dent = root; get_dentry(my_dent); - } else // Relative path, stay in this dir + } else { + // Relative path, stay in this dir put_dentry(my_dent); my_dent = start; get_dentry(my_dent); + } } } } diff --git a/LibOS/shim/test/regression/40_proc_path.py b/LibOS/shim/test/regression/40_proc_path.py new file mode 100644 index 00000000..aad3bfd0 --- /dev/null +++ b/LibOS/shim/test/regression/40_proc_path.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python2 + +import os, sys +from regression import Regression + +loader = sys.argv[1] + +# Running Bootstrap +regression = Regression(loader, "proc-path") + +regression.add_check(name="Base /proc path present", + check=lambda res: "proc path test success" in res[0].out) + +rv = regression.run_checks() +if rv: sys.exit(rv) diff --git a/LibOS/shim/test/regression/proc-path.c b/LibOS/shim/test/regression/proc-path.c new file mode 100644 index 00000000..c0daeea8 --- /dev/null +++ b/LibOS/shim/test/regression/proc-path.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +int main(int argc, char ** argv) +{ + struct stat root, proc_root; + + if (stat("/", &root) == -1) { + perror("stat"); + exit(1); + } + + if (stat("/proc/1/root", &proc_root) == -1) { + perror("stat"); + exit(1); + } + + if (root.st_dev == proc_root.st_dev && + root.st_ino == proc_root.st_ino) { + printf("proc path test success\n"); + } else { + printf("proc path test failure\n"); + } +} diff --git a/LibOS/shim/test/regression/proc-path.manifest.template b/LibOS/shim/test/regression/proc-path.manifest.template new file mode 100644 index 00000000..a7ff69a1 --- /dev/null +++ b/LibOS/shim/test/regression/proc-path.manifest.template @@ -0,0 +1,19 @@ +loader.preload = file:../../src/libsysdb.so +loader.env.LD_LIBRARY_PATH = /lib +loader.debug_type = none +loader.syscall_symbol = syscalldb + +fs.mount.lib.type = chroot +fs.mount.lib.path = /lib +fs.mount.lib.uri = file:../../../../Runtime + +fs.mount.bin.type = chroot +fs.mount.bin.path = /bin +fs.mount.bin.uri = file:/bin + +sys.brk.size = 32M +sys.stack.size = 4M + +# sgx-related +sgx.trusted_files.ld = file:../../../../Runtime/ld-linux-x86-64.so.2 +sgx.trusted_files.libc = file:../../../../Runtime/libc.so.6