aboutsummaryrefslogtreecommitdiff
path: root/sim/common/syscall.c
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@axis.com>2004-12-13 00:38:38 +0000
committerHans-Peter Nilsson <hp@axis.com>2004-12-13 00:38:38 +0000
commit0d3cd463e38ed3e3f7ae27ca38c00170150a275f (patch)
treeb914bea3898f12983af0fc8a627d7f03d601cc79 /sim/common/syscall.c
parentc4b36ce9fe15924cebd13edf3867f19eded2fa89 (diff)
downloadfsf-binutils-gdb-0d3cd463e38ed3e3f7ae27ca38c00170150a275f.zip
fsf-binutils-gdb-0d3cd463e38ed3e3f7ae27ca38c00170150a275f.tar.gz
fsf-binutils-gdb-0d3cd463e38ed3e3f7ae27ca38c00170150a275f.tar.bz2
* syscall.c (cb_syscall) <case CB_SYS_lstat>: New case.
* callback.c (os_lstat): New function.
Diffstat (limited to 'sim/common/syscall.c')
-rw-r--r--sim/common/syscall.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/sim/common/syscall.c b/sim/common/syscall.c
index 76b32ba..07521c9 100644
--- a/sim/common/syscall.c
+++ b/sim/common/syscall.c
@@ -471,6 +471,50 @@ cb_syscall (cb, sc)
}
break;
+ case CB_SYS_lstat :
+ {
+ char *path, *buf;
+ int buflen;
+ struct stat statbuf;
+ TADDR addr = sc->arg2;
+
+ errcode = get_path (cb, sc, sc->arg1, &path);
+ if (errcode != 0)
+ {
+ result = -1;
+ goto FinishSyscall;
+ }
+ result = (*cb->lstat) (cb, path, &statbuf);
+ free (path);
+ if (result < 0)
+ goto ErrorFinish;
+
+ buflen = cb_host_to_target_stat (cb, NULL, NULL);
+ buf = xmalloc (buflen);
+ if (cb_host_to_target_stat (cb, &statbuf, buf) != buflen)
+ {
+ /* The translation failed. This is due to an internal
+ host program error, not the target's fault.
+ Unfortunately, it's hard to test this case, so there's no
+ test-case for this execution path. */
+ free (buf);
+ errcode = ENOSYS;
+ result = -1;
+ goto FinishSyscall;
+ }
+
+ if ((*sc->write_mem) (cb, sc, addr, buf, buflen) != buflen)
+ {
+ free (buf);
+ errcode = EINVAL;
+ result = -1;
+ goto FinishSyscall;
+ }
+
+ free (buf);
+ }
+ break;
+
case CB_SYS_time :
{
/* FIXME: May wish to change CB_SYS_time to something else.