summaryrefslogtreecommitdiff
path: root/sim/ppc/emul_netbsd.c
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@geoffk.org>2001-01-15 23:24:30 +0000
committerGeoffrey Keating <geoffk@geoffk.org>2001-01-15 23:24:30 +0000
commit428e1889bc97f711eacc344ee3e17a8bfc05176d (patch)
treeda206de34d0b12a1bd7568fc91e6036337f13ffc /sim/ppc/emul_netbsd.c
parent098f2ec3f5e6d9283bfc59639182083701943804 (diff)
downloadbinutils-gdb-428e1889bc97f711eacc344ee3e17a8bfc05176d.tar.gz
* emul_netbsd.c (do_open): Translate the flag parameter to the
open syscall to the numbers supported by the host.
Diffstat (limited to 'sim/ppc/emul_netbsd.c')
-rw-r--r--sim/ppc/emul_netbsd.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/sim/ppc/emul_netbsd.c b/sim/ppc/emul_netbsd.c
index e2064a45afb..777c364ac32 100644
--- a/sim/ppc/emul_netbsd.c
+++ b/sim/ppc/emul_netbsd.c
@@ -386,6 +386,7 @@ do_open(os_emul_data *emul,
char *path = emul_read_string(path_buf, path_addr, PATH_MAX, processor, cia);
int flags = (int)cpu_registers(processor)->gpr[arg0+1];
int mode = (int)cpu_registers(processor)->gpr[arg0+2];
+ int hostflags;
int status;
if (WITH_TRACE && ppc_trace[trace_os_emul])
@@ -393,8 +394,25 @@ do_open(os_emul_data *emul,
SYS(open);
+ /* Do some translation on 'flags' to match it to the host's version. */
+ /* These flag values were taken from the NetBSD 1.4 header files. */
+ if ((flags & 3) == 0)
+ hostflags = O_RDONLY;
+ else if ((flags & 3) == 1)
+ hostflags = O_WRONLY;
+ else
+ hostflags = O_RDWR;
+ if (flags & 0x00000008)
+ hostflags |= O_APPEND;
+ if (flags & 0x00000200)
+ hostflags |= O_CREAT;
+ if (flags & 0x00000400)
+ hostflags |= O_TRUNC;
+ if (flags & 0x00000800)
+ hostflags |= O_EXCL;
+
/* Can't combine these statements, cuz open sets errno. */
- status = open(path, flags, mode);
+ status = open(path, hostflags, mode);
emul_write_status(processor, status, errno);
}