git: ed96fd7fc652 - main - kldxref: Simplify elf_read_raw_data
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 22 Dec 2023 15:50:11 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=ed96fd7fc652d77ae5e34727e54610e87854defc
commit ed96fd7fc652d77ae5e34727e54610e87854defc
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-12-22 15:49:03 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-12-22 15:49:03 +0000
kldxref: Simplify elf_read_raw_data
Use pread as a valid offset is always passed now. Originally the DSO
code read the .hash section in two separate requests and relied on the
implicit offset for the second read, but now the hash table is fetched
in a single call.
Reviewed by: imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D43125
---
usr.sbin/kldxref/elf.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/usr.sbin/kldxref/elf.c b/usr.sbin/kldxref/elf.c
index f8a6510ed352..cc9bf9e6cb38 100644
--- a/usr.sbin/kldxref/elf.c
+++ b/usr.sbin/kldxref/elf.c
@@ -170,11 +170,7 @@ elf_read_raw_data(struct elf_file *efile, off_t offset, void *dst, size_t len)
{
ssize_t nread;
- if (offset != (off_t)-1) {
- if (lseek(efile->ef_fd, offset, SEEK_SET) == -1)
- return (EIO);
- }
- nread = read(efile->ef_fd, dst, len);
+ nread = pread(efile->ef_fd, dst, len, offset);
if (nread == -1)
return (errno);
if (nread != len)