# Node ID aac11600a695edc902f6279a698bbaea607dfc74 # Parent 573b8c64224fd01c7ae6112e16dde1a499af434f diff --git a/src/kern/tru64/tru64.hh b/src/kern/tru64/tru64.hh --- a/src/kern/tru64/tru64.hh +++ b/src/kern/tru64/tru64.hh @@ -438,7 +438,7 @@ 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); diff --git a/src/sim/process.hh b/src/sim/process.hh --- a/src/sim/process.hh +++ b/src/sim/process.hh @@ -153,7 +153,7 @@ 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(); @@ -172,30 +172,30 @@ virtual const char *progName() const { return ""; } // 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); diff --git a/src/sim/process.cc b/src/sim/process.cc --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -153,7 +153,7 @@ // 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 @@ -162,7 +162,7 @@ // 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 @@ -170,7 +170,7 @@ 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; @@ -199,7 +199,7 @@ } void -Process::inheritFdArray(Process *p) +Process::inheritFDArray(Process *p) { fd_array = p->fd_array; } @@ -233,19 +233,19 @@ 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; @@ -256,30 +256,30 @@ } 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) @@ -321,7 +321,7 @@ } void -Process::fix_file_offsets() +Process::fixFileOffsets() { auto seek = [] (FDEntry *fde) { @@ -333,7 +333,7 @@ // 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 { @@ -343,7 +343,7 @@ // 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 { @@ -351,7 +351,7 @@ 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; @@ -377,7 +377,7 @@ fde.fd = fds[0]; - FDEntry *fde_write = get_fd_entry(fde.readPipeSource); + FDEntry *fde_write = getFDEntry(fde.readPipeSource); assert(fde_write->filename == "PIPE-WRITE"); fde_write->fd = fds[1]; } else { @@ -388,7 +388,7 @@ } void -Process::find_file_offsets() +Process::findFileOffsets() { for (auto& fde : *fd_array) { if (fde.fd != -1) @@ -399,7 +399,7 @@ 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; } @@ -438,10 +438,10 @@ 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 diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -558,7 +558,7 @@ 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 @@ -650,7 +650,7 @@ 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. @@ -812,7 +812,7 @@ 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; @@ -1006,7 +1006,7 @@ 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; @@ -1102,7 +1102,7 @@ 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; @@ -1158,7 +1158,7 @@ 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; @@ -1183,7 +1183,7 @@ 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; @@ -1237,7 +1237,7 @@ 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; diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc --- a/src/sim/syscall_emul.cc +++ b/src/sim/syscall_emul.cc @@ -212,7 +212,7 @@ 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; @@ -220,7 +220,7 @@ if (sim_fd > 2) status = close(sim_fd); if (status >= 0) - p->reset_fd_entry(tgt_fd); + p->resetFDEntry(tgt_fd); return status; } @@ -234,7 +234,7 @@ 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; @@ -255,7 +255,7 @@ 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; @@ -277,7 +277,7 @@ 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; @@ -297,7 +297,7 @@ 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; @@ -501,7 +501,7 @@ 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; @@ -540,7 +540,7 @@ 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; @@ -591,7 +591,7 @@ 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; @@ -612,15 +612,15 @@ 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); } @@ -631,7 +631,7 @@ 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; @@ -675,7 +675,7 @@ 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; @@ -712,8 +712,8 @@ 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