From b67436f8411e8155c8b9a15f7d39751cd72248a1 Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Tue, 8 Oct 1996 16:19:45 +0000 Subject: Mon Oct 7 21:31:25 1996 Thomas Bushnell, n/BSG * exec.c (fake_seek): New function. (prepare): Initialize E->stream.__io_funcs.seek to fake_seek; this is called now that stdio doesn't assume it always knows the file position. --- exec/ChangeLog | 7 +++++++ exec/exec.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'exec') diff --git a/exec/ChangeLog b/exec/ChangeLog index 715b2677..5051a17c 100644 --- a/exec/ChangeLog +++ b/exec/ChangeLog @@ -1,3 +1,10 @@ +Mon Oct 7 21:31:25 1996 Thomas Bushnell, n/BSG + + * exec.c (fake_seek): New function. + (prepare): Initialize E->stream.__io_funcs.seek to fake_seek; this + is called now that stdio doesn't assume it always knows the file + position. + Thu Sep 12 16:30:12 1996 Thomas Bushnell, n/BSG * Makefile (HURDLIBS): New variable. diff --git a/exec/exec.c b/exec/exec.c index a9de454a..12dab482 100644 --- a/exec/exec.c +++ b/exec/exec.c @@ -523,6 +523,31 @@ close_exec_stream (void *cookie) return 0; } +/* stdio seek function. */ +static int +fake_seek (void *cookie, fpos_t *pos, int whence) +{ + struct execdata *e = cookie; + + /* Set __target to match the specifed seek location */ + switch (whence) + { + case SEEK_END: + e->stream.__target = e->file_size + *pos; + break; + + case SEEK_CUR: + e->stream.__target += *pos; + break; + + case SEEK_SET: + e->stream.__target = *pos; + break; + } + *pos = e->stream.__target; + return 0; +} + /* Prepare to check and load FILE. */ static void @@ -548,8 +573,7 @@ prepare (file_t file, struct execdata *e) e->stream.__mode.__read = 1; e->stream.__userbuf = 1; e->stream.__room_funcs.__input = input_room; - /* This never gets called, but fseek returns ESPIPE if it's null. */ - e->stream.__io_funcs.seek = __default_io_functions.seek; + e->stream.__io_funcs.seek = fake_seek; e->stream.__io_funcs.close = close_exec_stream; e->stream.__cookie = e; e->stream.__seen = 1; -- cgit v1.2.3