From b637237cba240f810b0292cae9fd7baa37d6088b Mon Sep 17 00:00:00 2001 From: David Malone Date: Tue, 23 Mar 2004 12:29:17 +0000 Subject: [PATCH] Use pread to implement pread, rather than taking a detour throug stdio. PR: 52190 Submitted by: Dan Nelson --- usr.bin/truss/syscalls.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c index 8638ec92f752..6f35f998566c 100644 --- a/usr.bin/truss/syscalls.c +++ b/usr.bin/truss/syscalls.c @@ -169,23 +169,9 @@ get_syscall(const char *name) { static int get_struct(int procfd, void *offset, void *buf, int len) { - char *pos; - FILE *p; - int c, fd; - if ((fd = dup(procfd)) == -1) - err(1, "dup"); - if ((p = fdopen(fd, "r")) == NULL) - err(1, "fdopen"); - if (fseeko(p, (uintptr_t)offset, SEEK_SET) == 0) { - for (pos = (char *)buf; len--; pos++) { - if ((c = fgetc(p)) == EOF) - return (-1); - *pos = c; - } - } else - bzero(buf, len); - fclose(p); + if (pread(procfd, buf, len, (uintptr_t)offset) != len) + return -1; return 0; }