summaryrefslogtreecommitdiffstats
path: root/usr.bin/truss
diff options
context:
space:
mode:
authordwmalone <dwmalone@FreeBSD.org>2004-03-23 12:29:17 +0000
committerdwmalone <dwmalone@FreeBSD.org>2004-03-23 12:29:17 +0000
commit7a220808b385b0705af10fbe0e346aa70f0e72ce (patch)
treec3b7f22fc61be34489b4f335c537107094762b56 /usr.bin/truss
parent422a2ca6b489b0e27c89e494979edb49bd275c0d (diff)
downloadFreeBSD-src-7a220808b385b0705af10fbe0e346aa70f0e72ce.zip
FreeBSD-src-7a220808b385b0705af10fbe0e346aa70f0e72ce.tar.gz
Use pread to implement pread, rather than taking a detour throug stdio.
PR: 52190 Submitted by: Dan Nelson <dnelson@allantgroup.com>
Diffstat (limited to 'usr.bin/truss')
-rw-r--r--usr.bin/truss/syscalls.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c
index 8638ec9..6f35f99 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;
}
OpenPOWER on IntegriCloud