summaryrefslogtreecommitdiff
path: root/src/sim/process.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim/process.hh')
-rw-r--r--src/sim/process.hh41
1 files changed, 38 insertions, 3 deletions
diff --git a/src/sim/process.hh b/src/sim/process.hh
index a1ca84bf5..27c569602 100644
--- a/src/sim/process.hh
+++ b/src/sim/process.hh
@@ -91,8 +91,6 @@ class Process : public SimObject
inline void setpgid(uint64_t pgid) { _pgid = pgid; }
const char *progName() const { return executable.c_str(); }
- std::string fullPath(const std::string &filename);
- std::string getcwd() const { return cwd; }
/**
* Find an emulated device driver.
@@ -186,9 +184,46 @@ class Process : public SimObject
ObjectFile *objFile;
std::vector<std::string> argv;
std::vector<std::string> envp;
- std::string cwd;
std::string executable;
+ /**
+ * Return an absolute path given a relative path paired with the current
+ * working directory of the process running under simulation.
+ *
+ * @param path The relative path (generally a filename) that needs the
+ * current working directory prepended.
+ * @param host_fs A flag which determines whether to return a
+ * path for the host filesystem or the filesystem of the process running
+ * under simulation. Only matters if filesysem redirection is used to
+ * replace files (or directories) that would normally appear via the
+ * host filesystem.
+ * @return String containing an absolute path.
+ */
+ std::string absolutePath(const std::string &path, bool host_fs);
+
+ /**
+ * Redirect file path if it matches any keys initialized by system object.
+ * @param filename An input parameter containing either a relative path
+ * or an absolute path. If given a relative path, the path will be
+ * prepended to the current working directory of the simulation with
+ * respect to the host filesystem.
+ * @return String containing an absolute path.
+ */
+ std::string checkPathRedirect(const std::string &filename);
+
+ /**
+ * The cwd members are used to track changes to the current working
+ * directory for the purpose of executing system calls which depend on
+ * relative paths (i.e. open, chdir).
+ *
+ * The tgt member and host member may differ if the path for the current
+ * working directory is redirected to point to a different location
+ * (i.e. `cd /proc` should point to '$(gem5_repo)/m5out/fs/proc'
+ * instead of '/proc').
+ */
+ std::string tgtCwd;
+ std::string hostCwd;
+
// Id of the owner of the process
uint64_t _uid;
uint64_t _euid;