panic("getdirent not implemented on cygwin!");
#else
int index = 0;
- int fd = process->sim_fd(process->getSyscallArg(tc, index));
+ int fd = process->getSimFD(process->getSyscallArg(tc, index));
Addr tgt_buf = process->getSyscallArg(tc, index);
int tgt_nbytes = process->getSyscallArg(tc, index);
Addr tgt_basep = process->getSyscallArg(tc, index);
int num_processes = 0;
template<class IntType>
+
AuxVector<IntType>::AuxVector(IntType type, IntType val)
{
a_type = TheISA::htog(type);
// Search through the input options and set fd if match is found;
// otherwise, open an input file and seek to location.
- FDEntry *fde_stdin = get_fd_entry(STDIN_FILENO);
+ FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
if ((it = imap.find(params->input)) != imap.end())
sim_fd = it->second;
else
// Search through the output/error options and set fd if match is found;
// otherwise, open an output file and seek to location.
- FDEntry *fde_stdout = get_fd_entry(STDOUT_FILENO);
+ FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
if ((it = oemap.find(params->output)) != oemap.end())
sim_fd = it->second;
else
fde_stdout->set(sim_fd, params->output, O_WRONLY | O_CREAT | O_TRUNC,
0664, false);
- FDEntry *fde_stderr = get_fd_entry(STDERR_FILENO);
+ FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
if (params->output == params->errout)
// Reuse the same file descriptor if these match.
sim_fd = fde_stdout->fd;
}
void
-Process::inheritFdArray(Process *p)
+Process::inheritFDArray(Process *p)
{
fd_array = p->fd_array;
}
DrainState
Process::drain()
{
- find_file_offsets();
+ findFileOffsets();
return DrainState::Drained;
}
int
-Process::alloc_fd(int sim_fd, const string& filename, int flags, int mode,
- bool pipe)
+Process::allocFD(int sim_fd, const string& filename, int flags, int mode,
+ bool pipe)
{
if (sim_fd == -1)
return -1;
for (int free_fd = 0; free_fd < fd_array->size(); free_fd++) {
- FDEntry *fde = get_fd_entry(free_fd);
+ FDEntry *fde = getFDEntry(free_fd);
if (fde->isFree()) {
fde->set(sim_fd, filename, flags, mode, pipe);
return free_fd;
}
void
-Process::reset_fd_entry(int tgt_fd)
+Process::resetFDEntry(int tgt_fd)
{
- FDEntry *fde = get_fd_entry(tgt_fd);
+ FDEntry *fde = getFDEntry(tgt_fd);
assert(fde->fd > -1);
fde->reset();
}
int
-Process::sim_fd(int tgt_fd)
+Process::getSimFD(int tgt_fd)
{
- FDEntry *entry = get_fd_entry(tgt_fd);
+ FDEntry *entry = getFDEntry(tgt_fd);
return entry ? entry->fd : -1;
}
FDEntry *
-Process::get_fd_entry(int tgt_fd)
+Process::getFDEntry(int tgt_fd)
{
assert(0 <= tgt_fd && tgt_fd < fd_array->size());
return &(*fd_array)[tgt_fd];
}
int
-Process::tgt_fd(int sim_fd)
+Process::getTgtFD(int sim_fd)
{
for (int index = 0; index < fd_array->size(); index++)
if ((*fd_array)[index].fd == sim_fd)
}
void
-Process::fix_file_offsets()
+Process::fixFileOffsets()
{
auto seek = [] (FDEntry *fde)
{
// Search through the input options and set fd if match is found;
// otherwise, open an input file and seek to location.
- FDEntry *fde_stdin = get_fd_entry(STDIN_FILENO);
+ FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
if ((it = imap.find(fde_stdin->filename)) != imap.end()) {
fde_stdin->fd = it->second;
} else {
// Search through the output/error options and set fd if match is found;
// otherwise, open an output file and seek to location.
- FDEntry *fde_stdout = get_fd_entry(STDOUT_FILENO);
+ FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) {
fde_stdout->fd = it->second;
} else {
seek(fde_stdout);
}
- FDEntry *fde_stderr = get_fd_entry(STDERR_FILENO);
+ FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
if (fde_stdout->filename == fde_stderr->filename) {
// Reuse the same file descriptor if these match.
fde_stderr->fd = fde_stdout->fd;
}
for (int tgt_fd = 3; tgt_fd < fd_array->size(); tgt_fd++) {
- FDEntry *fde = get_fd_entry(tgt_fd);
+ FDEntry *fde = getFDEntry(tgt_fd);
if (fde->fd == -1)
continue;
fde->fd = fds[0];
- FDEntry *fde_write = get_fd_entry(fde->readPipeSource);
- assert(fde_write->filename == "PIPE-WRITE");
+ FDEntry *fde_write = getFDEntry(fde->readPipeSource);
+ assert(
+ fde_write->filename == "PIPE-WRITE");
fde_write->fd = fds[1];
} else {
fde->fd = openFile(fde->filename.c_str(), fde->flags, fde->mode);
}
void
-Process::find_file_offsets()
+Process::findFileOffsets()
{
for (auto& fde : *fd_array) {
if (fde.fd != -1)
void
Process::setReadPipeSource(int read_pipe_fd, int source_fd)
{
- FDEntry *fde = get_fd_entry(read_pipe_fd);
+ FDEntry *fde = getFDEntry(read_pipe_fd);
assert(source_fd >= -1);
fde->readPipeSource = source_fd;
}
UNSERIALIZE_SCALAR(nxm_end);
pTable->unserialize(cp);
for (int x = 0; x < fd_array->size(); x++) {
- FDEntry *fde = get_fd_entry(x);
+ FDEntry *fde = getFDEntry(x);
fde->unserializeSection(cp, csprintf("FDEntry%d", x));
}
- fix_file_offsets();
+ fixFileOffsets();
UNSERIALIZE_OPT_SCALAR(M5_pid);
// The above returns a bool so that you could do something if you don't
// find the param in the checkpoint if you wanted to, like set a default
public:
// inherit file descriptor map from another process (necessary for clone)
- void inheritFdArray(Process *p);
+ void inheritFDArray(Process *p);
// override of virtual SimObject method: register statistics
virtual void regStats();
virtual const char *progName() const { return "<unknown>"; }
// generate new target fd for sim_fd
- int alloc_fd(int sim_fd, const std::string& filename, int flags, int mode,
- bool pipe);
+ int allocFD(int sim_fd, const std::string& filename, int flags, int mode,
+ bool pipe);
// disassociate target fd with simulator fd and cleanup subsidiary fields
- void reset_fd_entry(int tgt_fd);
+ void resetFDEntry(int tgt_fd);
// look up simulator fd for given target fd
- int sim_fd(int tgt_fd);
+ int getSimFD(int tgt_fd);
// look up fd entry for a given target fd
- FDEntry *get_fd_entry(int tgt_fd);
+ FDEntry *getFDEntry(int tgt_fd);
// look up target fd for given host fd
// Assumes a 1:1 mapping between target file descriptor and host file
// descriptor. Given the current API, this must be true given that it's
// not possible to map multiple target file descriptors to the same host
// file descriptor
- int tgt_fd(int sim_fd);
+ int getTgtFD(int sim_fd);
// fix all offsets for currently open files and save them
- void fix_file_offsets();
+ void fixFileOffsets();
// find all offsets for currently open files and save them
- void find_file_offsets();
+ void findFileOffsets();
// set the source of this read pipe for a checkpoint resume
void setReadPipeSource(int read_pipe_fd, int source_fd);
int index = 0;
int tgt_fd = p->getSyscallArg(tc, index);
- int sim_fd = p->sim_fd(tgt_fd);
+ int sim_fd = p->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
if (sim_fd > 2)
status = close(sim_fd);
if (status >= 0)
- p->reset_fd_entry(tgt_fd);
+ p->resetFDEntry(tgt_fd);
return status;
}
int nbytes = p->getSyscallArg(tc, index);
BufferArg bufArg(bufPtr, nbytes);
- int sim_fd = p->sim_fd(tgt_fd);
+ int sim_fd = p->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
int nbytes = p->getSyscallArg(tc, index);
BufferArg bufArg(bufPtr, nbytes);
- int sim_fd = p->sim_fd(tgt_fd);
+ int sim_fd = p->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
uint64_t offs = p->getSyscallArg(tc, index);
int whence = p->getSyscallArg(tc, index);
- int sim_fd = p->sim_fd(tgt_fd);
+ int sim_fd = p->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
Addr result_ptr = p->getSyscallArg(tc, index);
int whence = p->getSyscallArg(tc, index);
- int sim_fd = p->sim_fd(tgt_fd);
+ int sim_fd = p->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
int tgt_fd = process->getSyscallArg(tc, index);
off_t length = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
int tgt_fd = process->getSyscallArg(tc, index);
int64_t length = process->getSyscallArg(tc, index, 64);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
int index = 0;
int tgt_fd = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
int index = 0;
int tgt_fd = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
- FDEntry *fde = process->get_fd_entry(tgt_fd);
+ FDEntry *fde = process->getFDEntry(tgt_fd);
int result = dup(sim_fd);
return (result == -1) ? -errno :
- process->alloc_fd(result, fde->filename, fde->flags, fde->mode, false);
+ process->allocFD(result, fde->filename, fde->flags, fde->mode, false);
}
int index = 0;
int tgt_fd = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
int index = 0;
int tgt_fd = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
return pipe_retval;
}
- sim_fds[0] = process->alloc_fd(fds[0], "PIPE-READ", O_WRONLY, -1, true);
- sim_fds[1] = process->alloc_fd(fds[1], "PIPE-WRITE", O_RDONLY, -1, true);
+ sim_fds[0] = process->allocFD(fds[0], "PIPE-READ", O_WRONLY, -1, true);
+ sim_fds[1] = process->allocFD(fds[1], "PIPE-WRITE", O_RDONLY, -1, true);
process->setReadPipeSource(sim_fds[0], sim_fds[1]);
// Alpha Linux convention for pipe() is that fd[0] is returned as
DPRINTF(SyscallVerbose, "ioctl(%d, 0x%x, ...)\n", tgt_fd, req);
- FDEntry *fde = process->get_fd_entry(tgt_fd);
+ FDEntry *fde = process->getFDEntry(tgt_fd);
if (fde == NULL) {
// doesn't map to any simulator fd: not a valid target fd
if (fd == -1)
return -local_errno;
- return process->alloc_fd(fd, path.c_str(), hostFlags, mode, false);
+ return process->allocFD(fd, path.c_str(), hostFlags, mode, false);
}
/// Target open() handler.
int tgt_fd = process->getSyscallArg(tc, index);
uint32_t mode = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
int tgt_fd = process->getSyscallArg(tc, index);
Addr bufPtr = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
DPRINTF(SyscallVerbose, "fstat(%d, ...)\n", tgt_fd);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
int tgt_fd = process->getSyscallArg(tc, index);
Addr bufPtr = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
int index = 0;
int tgt_fd = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
warn("mmap length argument %#x is unreasonably large.\n", length);
if (!(flags & OS::TGT_MAP_ANONYMOUS)) {
- FDEntry *fde = p->get_fd_entry(tgt_fd);
+ FDEntry *fde = p->getFDEntry(tgt_fd);
if (!fde || fde->fd < 0) {
warn("mmap failing: target fd %d is not valid\n", tgt_fd);
return -EBADF;