syscall_emul: Added getdents and getdents64 syscalls
Review Request #3583 - Created July 23, 2016 and updated
| Information | |
|---|---|
| Nicolas Derumigny | |
| gem5 | |
| Reviewers | |
| Default | |
syscall_emul: Added getdents and getdents64 syscalls
Works with readdir() wrapper, tested with CERE codelets (https://github.com/benchmark-subsetting/cere).
Thanks for the patch, Nicolas. It looks like it doesn't apply cleanly, though. Could you repost by using "hg postreview -o"? Also, be sure to use the gem5 development repo as the base for your changeset, not gem5-stable.
Summary: |
|
||||||
|---|---|---|---|---|---|---|---|
Description: |
|
Based on recent experiences, please make sure it compiles on OSX
-
src/sim/syscall_emul.hh (Diff revision 2) -
whitespace here and a few other places
is your editor setup correctly?
LGTM. Two questions about testing, though.
1) Did you test the 32-bit versions?
2) Can you add tests for these? It seems like you have some small bits of code. If they only take a few seconds to run in gem5, you should make a new regression test.Thanks!
Hi Nicolas, thanks for the contribution. Couple of things before you commit this.
-
src/sim/syscall_emul.hh (Diff revision 4) -
alignment should be under the 'S' in "SyscallDesc"
-
src/sim/syscall_emul.hh (Diff revision 4) -
alignment
-
src/sim/syscall_emul.cc (Diff revision 4) -
Please rename fd to sim_fd. It gets confusing over time if the distinction isn't explicit especially in more complicated functions. I've seen at least one bug that was caused by this type of naming.
-
src/sim/syscall_emul.cc (Diff revision 4) -
This should not be an assert here. I think the correct thing to do here is instead "if(fd < 0) {return -EBADF;}".
The point is that the application is free to pass in bad file descriptors to the kernel. The kernel's job is to reject the file descriptor and return an errno to the application. It's not the kernel's job to kill the process for passing in a bad file descriptor.
-
src/sim/syscall_emul.cc (Diff revision 4) -
Local variables are supposed to be lower case and seperated by underscores (instead of camel case).
http://www.m5sim.org/Coding_Style
-
src/sim/syscall_emul.cc (Diff revision 4) -
variable name
-
src/sim/syscall_emul.cc (Diff revision 4) -
save errno to a local variable after the system call
-
src/sim/syscall_emul.cc (Diff revision 4) -
space between if keyword and paren
-
src/sim/syscall_emul.cc (Diff revision 4) -
add a conditional return here if the sim_fd is bad
-
src/sim/syscall_emul.cc (Diff revision 4) -
rename fd to sim_fd
-
src/sim/syscall_emul.cc (Diff revision 4) -
name
-
src/sim/syscall_emul.cc (Diff revision 4) -
name
-
src/sim/syscall_emul.cc (Diff revision 4) -
You should save the errno value into a local variable immediately after a real system call if you have intervening code between the system call and the code.
Otherwise, the errno value might get clobbered before you return it.
-
src/sim/syscall_emul.cc (Diff revision 4) -
space
Ship It!
-
src/arch/x86/linux/process.cc (Diff revision 5) -
What is the reasoning behind this change?
The system calls are defined by what the Linux kernel has set for them; we can't arbitrarily decide to alter the call to a different variant.
-
src/sim/syscall_emul.hh (Diff revision 5) -
remove whitespace on lines 305, 307, 311, and 313
-
src/sim/syscall_emul.cc (Diff revision 5) -
space around '='
-
src/sim/syscall_emul.cc (Diff revision 5) -
space around '='
