Implement current working directory for LiveProcesses
authorNathan Binkert <binkertn@umich.edu>
Thu, 16 Nov 2006 20:43:11 +0000 (12:43 -0800)
committerNathan Binkert <binkertn@umich.edu>
Thu, 16 Nov 2006 20:43:11 +0000 (12:43 -0800)
--HG--
extra : convert_revision : a2d3cf29ab65c61af27d82a8c421a41a19fd5aeb

21 files changed:
src/arch/alpha/linux/process.cc
src/arch/alpha/linux/process.hh
src/arch/alpha/process.cc
src/arch/alpha/process.hh
src/arch/alpha/tru64/process.cc
src/arch/alpha/tru64/process.hh
src/arch/mips/linux/process.cc
src/arch/mips/linux/process.hh
src/arch/mips/process.cc
src/arch/mips/process.hh
src/arch/sparc/linux/process.cc
src/arch/sparc/linux/process.hh
src/arch/sparc/process.cc
src/arch/sparc/process.hh
src/arch/sparc/solaris/process.cc
src/arch/sparc/solaris/process.hh
src/python/m5/objects/Process.py
src/sim/process.cc
src/sim/process.hh
src/sim/syscall_emul.cc
src/sim/syscall_emul.hh

index 56342dbc508517e3bde252f08ab6445bda695c10..f7d946e2e577ecbb7fd23e9281bcd4b46dc5b492 100644 (file)
@@ -576,6 +576,7 @@ AlphaLinuxProcess::AlphaLinuxProcess(const std::string &name,
                                      int stderr_fd,
                                      std::vector<std::string> &argv,
                                      std::vector<std::string> &envp,
+                                     const std::string &cwd,
                                      uint64_t _uid,
                                      uint64_t _euid,
                                      uint64_t _gid,
@@ -583,7 +584,7 @@ AlphaLinuxProcess::AlphaLinuxProcess(const std::string &name,
                                      uint64_t _pid,
                                      uint64_t _ppid)
     : AlphaLiveProcess(name, objFile, system, stdin_fd, stdout_fd,
-            stderr_fd, argv, envp, _uid, _euid, _gid, _egid, _pid, _ppid),
+           stderr_fd, argv, envp, cwd, _uid, _euid, _gid, _egid, _pid, _ppid),
      Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc))
 {
     //init_regs->intRegFile[0] = 0;
index b239048445099cd2cea756bbccc11e2757cff26c..2076f63393809e6ebee324011ba258912cd4cc1e 100644 (file)
@@ -46,6 +46,7 @@ class AlphaLinuxProcess : public AlphaLiveProcess
                       int stdin_fd, int stdout_fd, int stderr_fd,
                       std::vector<std::string> &argv,
                       std::vector<std::string> &envp,
+                      const std::string &cwd,
                       uint64_t _uid, uint64_t _euid,
                       uint64_t _gid, uint64_t _egid,
                       uint64_t _pid, uint64_t _ppid);
index 9e360e80f2ca535d6eed8c4718ab705b740b9872..85619e493b2472c7f4b8eeb9c911c3c6d7413c04 100644 (file)
@@ -43,10 +43,11 @@ using namespace std;
 AlphaLiveProcess::AlphaLiveProcess(const std::string &nm, ObjectFile *objFile,
         System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
         std::vector<std::string> &argv, std::vector<std::string> &envp,
+        const std::string &cwd,
         uint64_t _uid, uint64_t _euid, uint64_t _gid, uint64_t _egid,
         uint64_t _pid, uint64_t _ppid)
     : LiveProcess(nm, objFile, _system, stdin_fd, stdout_fd, stderr_fd,
-        argv, envp, _uid, _euid, _gid, _egid, _pid, _ppid)
+        argv, envp, cwd, _uid, _euid, _gid, _egid, _pid, _ppid)
 {
     brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
     brk_point = roundUp(brk_point, VMPageSize);
index c4aeb1885a0efd26af6b8eecd268bd8efd2278d3..8eede502aebb9175981a0da1c4f4b219dcd28b3b 100644 (file)
@@ -47,6 +47,7 @@ class AlphaLiveProcess : public LiveProcess
                 System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
                 std::vector<std::string> &argv,
                 std::vector<std::string> &envp,
+                const std::string &cwd,
                 uint64_t _uid, uint64_t _euid,
                 uint64_t _gid, uint64_t _egid,
                 uint64_t _pid, uint64_t _ppid);
index 55b8ebf8bd295d278b0002f1791b28a648d3ec6d..a1f02b16c02f844f733e9a4651228fa8d7aca99d 100644 (file)
@@ -581,11 +581,12 @@ AlphaTru64Process::AlphaTru64Process(const std::string &name,
                                      int stderr_fd,
                                      std::vector<std::string> &argv,
                                      std::vector<std::string> &envp,
+                                     const std::string &cwd,
                                      uint64_t _uid, uint64_t _euid,
                                      uint64_t _gid, uint64_t _egid,
                                      uint64_t _pid, uint64_t _ppid)
     : AlphaLiveProcess(name, objFile, system, stdin_fd, stdout_fd,
-            stderr_fd, argv, envp, _uid, _euid, _gid, _egid, _pid, _ppid),
+            stderr_fd, argv, envp, cwd, _uid, _euid, _gid, _egid, _pid, _ppid),
       Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc)),
       Num_Mach_Syscall_Descs(sizeof(machSyscallDescs) / sizeof(SyscallDesc))
 {
index 23429dad3d7c403552e46397fdb09097090832cc..f5643c0b996d5ed992f5765a663aa295e0ac2a03 100644 (file)
@@ -45,6 +45,7 @@ class AlphaTru64Process : public AlphaLiveProcess
                       int stdin_fd, int stdout_fd, int stderr_fd,
                       std::vector<std::string> &argv,
                       std::vector<std::string> &envp,
+                      const std::string &cwd,
                       uint64_t _uid, uint64_t _euid,
                       uint64_t _gid, uint64_t _egid,
                       uint64_t _pid, uint64_t _ppid);
index d182cfa307722c3a2d5a9aed9492ea1177e8d22f..a847608d8d256a9e414fc74d835e4e8dc9377878 100644 (file)
@@ -411,6 +411,7 @@ MipsLinuxProcess::MipsLinuxProcess(const std::string &name,
                                      int stderr_fd,
                                      std::vector<std::string> &argv,
                                      std::vector<std::string> &envp,
+                                     const std::string &cwd,
                                      uint64_t _uid,
                                      uint64_t _euid,
                                      uint64_t _gid,
@@ -418,7 +419,7 @@ MipsLinuxProcess::MipsLinuxProcess(const std::string &name,
                                      uint64_t _pid,
                                      uint64_t _ppid)
     : MipsLiveProcess(name, objFile, system, stdin_fd, stdout_fd, stderr_fd,
-                      argv, envp, _uid, _euid, _gid, _egid, _pid, _ppid),
+                      argv, envp, cwd, _uid, _euid, _gid, _egid, _pid, _ppid),
      Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc))
 { }
 
index 06f86379c45f0faaa514668fdca630673c22be4e..398e1cfc266aa55b243f4f980aa66b11a8e32492 100644 (file)
@@ -43,6 +43,7 @@ class MipsLinuxProcess : public MipsLiveProcess
                       int stdin_fd, int stdout_fd, int stderr_fd,
                       std::vector<std::string> &argv,
                       std::vector<std::string> &envp,
+                      const std::string &cwd,
                       uint64_t _uid, uint64_t _euid,
                       uint64_t _gid, uint64_t _egid,
                       uint64_t _pid, uint64_t _ppid);
index 4bc91ca24b068f793056554a8578ae080289666d..d1e6e27bf32fbe8d2c04d3790260f90da90a415a 100644 (file)
@@ -44,10 +44,11 @@ using namespace MipsISA;
 MipsLiveProcess::MipsLiveProcess(const std::string &nm, ObjectFile *objFile,
         System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
         std::vector<std::string> &argv, std::vector<std::string> &envp,
+        const std::string &cwd,
         uint64_t _uid, uint64_t _euid, uint64_t _gid, uint64_t _egid,
         uint64_t _pid, uint64_t _ppid)
     : LiveProcess(nm, objFile, _system, stdin_fd, stdout_fd, stderr_fd,
-        argv, envp, _uid, _euid, _gid, _egid, _pid, _ppid)
+        argv, envp, cwd, _uid, _euid, _gid, _egid, _pid, _ppid)
 {
     // Set up stack. On MIPS, stack starts at the top of kuseg
     // user address space. MIPS stack grows down from here
index fb004375d8a7b15acadb0a935fec3049b001f3ad..af85e8ee9e7a92b24c081c87d1fc853b42e51cda 100644 (file)
@@ -48,6 +48,7 @@ class MipsLiveProcess : public LiveProcess
                 System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
                 std::vector<std::string> &argv,
                 std::vector<std::string> &envp,
+                const std::string &cwd,
                 uint64_t _uid, uint64_t _euid,
                 uint64_t _gid, uint64_t _egid,
                 uint64_t _pid, uint64_t _ppid);
index 44c893f2b2d121e00070d109654eefba60751e2c..565975fe03239d92ad5255a195cdfc34f0db6c0b 100644 (file)
@@ -391,11 +391,12 @@ SparcLinuxProcess::SparcLinuxProcess(const std::string &name,
                                      int stderr_fd,
                                      std::vector<std::string> &argv,
                                      std::vector<std::string> &envp,
+                                     const std::string &cwd,
                                      uint64_t _uid, uint64_t _euid,
                                      uint64_t _gid, uint64_t _egid,
                                      uint64_t _pid, uint64_t _ppid)
     : SparcLiveProcess(name, objFile, system,
-            stdin_fd, stdout_fd, stderr_fd, argv, envp,
+            stdin_fd, stdout_fd, stderr_fd, argv, envp, cwd,
             _uid, _euid, _gid, _egid, _pid, _ppid),
      Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc))
 {
index c758d5433ea99c5bab19c7d8ac27079e369c09a4..e212de973ecd0c14c0f7702e50ddba2f79aab5d1 100644 (file)
@@ -49,6 +49,7 @@ class SparcLinuxProcess : public SparcLiveProcess
                       int stdin_fd, int stdout_fd, int stderr_fd,
                       std::vector<std::string> &argv,
                       std::vector<std::string> &envp,
+                      const std::string &cwd,
                       uint64_t _uid, uint64_t _euid,
                       uint64_t _gid, uint64_t _egid,
                       uint64_t _pid, uint64_t _ppid);
index 11a799ccbd4f8f980f26287cd0232e3cf408dc1b..3efe4fc0861c4308d1ef49a880c7f2c2642c8294 100644 (file)
@@ -47,10 +47,11 @@ using namespace SparcISA;
 SparcLiveProcess::SparcLiveProcess(const std::string &nm, ObjectFile *objFile,
         System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
         std::vector<std::string> &argv, std::vector<std::string> &envp,
+        const std::string &cwd,
         uint64_t _uid, uint64_t _euid, uint64_t _gid, uint64_t _egid,
         uint64_t _pid, uint64_t _ppid)
     : LiveProcess(nm, objFile, _system, stdin_fd, stdout_fd, stderr_fd,
-        argv, envp, _uid, _euid, _gid, _egid, _pid, _ppid)
+        argv, envp, cwd, _uid, _euid, _gid, _egid, _pid, _ppid)
 {
 
     // XXX all the below need to be updated for SPARC - Ali
index 2320810c7b6267d68e42c35a34db1d7ec6974354..1cf7ec2245755f2869b9296dac57052d106d0162 100644 (file)
@@ -64,6 +64,7 @@ class SparcLiveProcess : public LiveProcess
                 System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
                 std::vector<std::string> &argv,
                 std::vector<std::string> &envp,
+                const std::string &cwd,
                 uint64_t _uid, uint64_t _euid,
                 uint64_t _gid, uint64_t _egid,
                 uint64_t _pid, uint64_t _ppid);
index ff466c8e61700e2ff09f72e3be6430408a4e8adb..f9876bf00d265b06bee8bae3676dcc84b432f08b 100644 (file)
@@ -329,6 +329,7 @@ SparcSolarisProcess::SparcSolarisProcess(const std::string &name,
                                      int stderr_fd,
                                      std::vector<std::string> &argv,
                                      std::vector<std::string> &envp,
+                                     const std::string &cwd,
                                      uint64_t _uid,
                                      uint64_t _euid,
                                      uint64_t _gid,
@@ -336,7 +337,7 @@ SparcSolarisProcess::SparcSolarisProcess(const std::string &name,
                                      uint64_t _pid,
                                      uint64_t _ppid)
     : SparcLiveProcess(name, objFile, system,
-            stdin_fd, stdout_fd, stderr_fd, argv, envp,
+            stdin_fd, stdout_fd, stderr_fd, argv, envp, cwd,
             _uid, _euid, _gid, _egid, _pid, _ppid),
      Num_Syscall_Descs(sizeof(syscallDescs) / sizeof(SyscallDesc))
 {
index 2cf329211c8472dfcedc06ce64b63aaa6b0a9dfc..f65a60656617aa703fc6de9f04502441327b391a 100644 (file)
@@ -48,6 +48,7 @@ class SparcSolarisProcess : public SparcLiveProcess
                       int stdin_fd, int stdout_fd, int stderr_fd,
                       std::vector<std::string> &argv,
                       std::vector<std::string> &envp,
+                      const std::string &cwd,
                       uint64_t _uid, uint64_t _euid,
                       uint64_t _gid, uint64_t _egid,
                       uint64_t _pid, uint64_t _ppid);
index 771ad4101c3fc8602f0c96688555ff94165da636..79268e6f48470eeb771f0c16015ccfd949eb6e12 100644 (file)
@@ -12,6 +12,7 @@ class LiveProcess(Process):
     executable = Param.String('', "executable (overrides cmd[0] if set)")
     cmd = VectorParam.String("command line (executable plus arguments)")
     env = VectorParam.String('', "environment settings")
+    cwd = Param.String('', "current working directory")
     input = Param.String('cin', "filename for stdin")
     uid = Param.Int(100, 'user id')
     euid = Param.Int(100, 'effective user id')
index f3e289d41595874e78315b3311b6e457c704cd0c..b43fa7d00fc44b7a230d1eaba7cf9be48b5d3352 100644 (file)
@@ -314,11 +314,12 @@ LiveProcess::LiveProcess(const string &nm, ObjectFile *_objFile,
                          System *_system,
                          int stdin_fd, int stdout_fd, int stderr_fd,
                          vector<string> &_argv, vector<string> &_envp,
+                         const string &_cwd,
                          uint64_t _uid, uint64_t _euid,
                          uint64_t _gid, uint64_t _egid,
                          uint64_t _pid, uint64_t _ppid)
     : Process(nm, _system, stdin_fd, stdout_fd, stderr_fd),
-      objFile(_objFile), argv(_argv), envp(_envp)
+      objFile(_objFile), argv(_argv), envp(_envp), cwd(_cwd)
 {
     __uid = _uid;
     __euid = _euid;
@@ -427,6 +428,7 @@ LiveProcess::create(const std::string &nm, System *system, int stdin_fd,
                     int stdout_fd, int stderr_fd, std::string executable,
                     std::vector<std::string> &argv,
                     std::vector<std::string> &envp,
+                    const std::string &cwd,
                     uint64_t _uid, uint64_t _euid,
                     uint64_t _gid, uint64_t _egid,
                     uint64_t _pid, uint64_t _ppid)
@@ -445,14 +447,14 @@ LiveProcess::create(const std::string &nm, System *system, int stdin_fd,
       case ObjectFile::Tru64:
         process = new AlphaTru64Process(nm, objFile, system,
                                         stdin_fd, stdout_fd, stderr_fd,
-                                        argv, envp,
+                                        argv, envp, cwd,
                                         _uid, _euid, _gid, _egid, _pid, _ppid);
         break;
 
       case ObjectFile::Linux:
         process = new AlphaLinuxProcess(nm, objFile, system,
                                         stdin_fd, stdout_fd, stderr_fd,
-                                        argv, envp,
+                                        argv, envp, cwd,
                                         _uid, _euid, _gid, _egid, _pid, _ppid);
         break;
 
@@ -466,7 +468,7 @@ LiveProcess::create(const std::string &nm, System *system, int stdin_fd,
       case ObjectFile::Linux:
         process = new SparcLinuxProcess(nm, objFile, system,
                                         stdin_fd, stdout_fd, stderr_fd,
-                                        argv, envp,
+                                        argv, envp, cwd,
                                         _uid, _euid, _gid, _egid, _pid, _ppid);
         break;
 
@@ -474,7 +476,7 @@ LiveProcess::create(const std::string &nm, System *system, int stdin_fd,
       case ObjectFile::Solaris:
         process = new SparcSolarisProcess(nm, objFile, system,
                                         stdin_fd, stdout_fd, stderr_fd,
-                                        argv, envp,
+                                        argv, envp, cwd,
                                         _uid, _euid, _gid, _egid, _pid, _ppid);
         break;
       default:
@@ -487,7 +489,7 @@ LiveProcess::create(const std::string &nm, System *system, int stdin_fd,
       case ObjectFile::Linux:
         process = new MipsLinuxProcess(nm, objFile, system,
                                         stdin_fd, stdout_fd, stderr_fd,
-                                        argv, envp,
+                                        argv, envp, cwd,
                                         _uid, _euid, _gid, _egid, _pid, _ppid);
         break;
 
@@ -512,6 +514,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(LiveProcess)
     Param<string> input;
     Param<string> output;
     VectorParam<string> env;
+    Param<string> cwd;
     SimObjectParam<System *> system;
     Param<uint64_t> uid;
     Param<uint64_t> euid;
@@ -530,6 +533,7 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(LiveProcess)
     INIT_PARAM(input, "filename for stdin (dflt: use sim stdin)"),
     INIT_PARAM(output, "filename for stdout/stderr (dflt: use sim stdout)"),
     INIT_PARAM(env, "environment settings"),
+    INIT_PARAM(cwd, "current working directory"),
     INIT_PARAM(system, "system"),
     INIT_PARAM(uid, "user id"),
     INIT_PARAM(euid, "effective user id"),
@@ -566,7 +570,7 @@ CREATE_SIM_OBJECT(LiveProcess)
     return LiveProcess::create(getInstanceName(), system,
                                stdin_fd, stdout_fd, stderr_fd,
                                (string)executable == "" ? cmd[0] : executable,
-                               cmd, env,
+                               cmd, env, cwd,
                                uid, euid, gid, egid, pid, ppid);
 }
 
index 5c37f725e3ae6d6fbadeb030dc96cde943171f7f..616c02c00920d70fc5c1f6fa658e6d403142231d 100644 (file)
@@ -177,11 +177,13 @@ class LiveProcess : public Process
     ObjectFile *objFile;
     std::vector<std::string> argv;
     std::vector<std::string> envp;
+    std::string cwd;
 
     LiveProcess(const std::string &nm, ObjectFile *objFile,
                 System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
                 std::vector<std::string> &argv,
                 std::vector<std::string> &envp,
+                const std::string &cwd,
                 uint64_t _uid, uint64_t _euid,
                 uint64_t _gid, uint64_t _egid,
                 uint64_t _pid, uint64_t _ppid);
@@ -207,6 +209,20 @@ class LiveProcess : public Process
     inline uint64_t pid() {return __pid;}
     inline uint64_t ppid() {return __ppid;}
 
+    std::string
+    fullPath(const std::string &filename)
+    {
+        if (filename[0] == '/' || cwd.empty())
+            return filename;
+
+        std::string full = cwd;
+
+        if (cwd[cwd.size() - 1] != '/')
+            full += '/';
+
+        return full + filename;
+    }
+
     virtual void syscall(int64_t callnum, ThreadContext *tc);
 
     virtual SyscallDesc* getDesc(int callnum) = 0;
@@ -220,6 +236,7 @@ class LiveProcess : public Process
                                std::string executable,
                                std::vector<std::string> &argv,
                                std::vector<std::string> &envp,
+                               const std::string &cwd,
                                uint64_t _uid, uint64_t _euid,
                                uint64_t _gid, uint64_t _egid,
                                uint64_t _pid, uint64_t _ppid);
index 9028d590bd0964312319c326f447c080c7399ddb..ab44c0a35f8efb998e5a17fa0fba423fd1afc69b 100644 (file)
@@ -214,6 +214,9 @@ unlinkFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
     if (!tc->getMemPort()->tryReadString(path, tc->getSyscallArg(0)))
         return (TheISA::IntReg)-EFAULT;
 
+    // Adjust path for current working directory
+    path = p->fullPath(path);
+
     int result = unlink(path.c_str());
     return (result == -1) ? -errno : result;
 }
@@ -231,6 +234,10 @@ renameFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
     if (!tc->getMemPort()->tryReadString(new_name, tc->getSyscallArg(1)))
         return -EFAULT;
 
+    // Adjust path for current working directory
+    old_name = p->fullPath(old_name);
+    new_name = p->fullPath(new_name);
+
     int64_t result = rename(old_name.c_str(), new_name.c_str());
     return (result == -1) ? -errno : result;
 }
@@ -245,6 +252,9 @@ truncateFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
 
     off_t length = tc->getSyscallArg(1);
 
+    // Adjust path for current working directory
+    path = p->fullPath(path);
+
     int result = truncate(path.c_str(), length);
     return (result == -1) ? -errno : result;
 }
@@ -277,6 +287,9 @@ chownFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
     uint32_t group = tc->getSyscallArg(2);
     gid_t hostGroup = group;
 
+    // Adjust path for current working directory
+    path = p->fullPath(path);
+
     int result = chown(path.c_str(), hostOwner, hostGroup);
     return (result == -1) ? -errno : result;
 }
index e79712a197b7a00176e97fce754dfd3c23c5c6df..07689ef06bf62066ec08a07af01459569325df9d 100644 (file)
@@ -500,6 +500,9 @@ openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     hostFlags |= O_BINARY;
 #endif
 
+    // Adjust path for current working directory
+    path = process->fullPath(path);
+
     DPRINTF(SyscallVerbose, "opening file %s\n", path.c_str());
 
     // open the file
@@ -526,6 +529,9 @@ chmodFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     // XXX translate mode flags via OS::something???
     hostMode = mode;
 
+    // Adjust path for current working directory
+    path = process->fullPath(path);
+
     // do the chmod
     int result = chmod(path.c_str(), hostMode);
     if (result < 0)
@@ -573,6 +579,9 @@ statFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (!tc->getMemPort()->tryReadString(path, tc->getSyscallArg(0)))
     return -EFAULT;
 
+    // Adjust path for current working directory
+    path = process->fullPath(path);
+
     struct stat hostBuf;
     int result = stat(path.c_str(), &hostBuf);
 
@@ -626,6 +635,9 @@ lstatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (!tc->getMemPort()->tryReadString(path, tc->getSyscallArg(0)))
       return -EFAULT;
 
+    // Adjust path for current working directory
+    path = process->fullPath(path);
+
     struct stat hostBuf;
     int result = lstat(path.c_str(), &hostBuf);
 
@@ -648,6 +660,9 @@ lstat64Func(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (!tc->getMemPort()->tryReadString(path, tc->getSyscallArg(0)))
       return -EFAULT;
 
+    // Adjust path for current working directory
+    path = process->fullPath(path);
+
 #if NO_STAT64
     struct stat hostBuf;
     int result = lstat(path.c_str(), &hostBuf);
@@ -701,6 +716,9 @@ statfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
     if (!tc->getMemPort()->tryReadString(path, tc->getSyscallArg(0)))
       return -EFAULT;
 
+    // Adjust path for current working directory
+    path = process->fullPath(path);
+
     struct statfs hostBuf;
     int result = statfs(path.c_str(), &hostBuf);
 
@@ -896,6 +914,10 @@ utimesFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
         hostTimeval[i].tv_sec = gtoh((*tp)[i].tv_sec);
         hostTimeval[i].tv_usec = gtoh((*tp)[i].tv_usec);
     }
+
+    // Adjust path for current working directory
+    path = process->fullPath(path);
+
     int result = utimes(path.c_str(), hostTimeval);
 
     if (result < 0)