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 _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;
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);
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);
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);
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))
{
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);
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 _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))
{ }
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);
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
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);
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))
{
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);
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
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);
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 _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))
{
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);
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')
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;
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)
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;
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;
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:
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;
Param<string> input;
Param<string> output;
VectorParam<string> env;
+ Param<string> cwd;
SimObjectParam<System *> system;
Param<uint64_t> uid;
Param<uint64_t> euid;
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"),
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);
}
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);
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;
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);
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;
}
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;
}
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;
}
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;
}
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
// 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)
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);
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);
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);
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);
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)