Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Oct 2017 12:04:07 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r324952 - head/libexec/rtld-elf
Message-ID:  <201710241204.v9OC48oO031364@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Tue Oct 24 12:04:07 2017
New Revision: 324952
URL: https://svnweb.freebsd.org/changeset/base/324952

Log:
  Replace lseek(2)/read(2) pair with pread(2), removing yet another syscall
  from the binary startup code.
  
  MFC after:	2 weeks
  Sponsored by:	DARPA, AFRL

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Tue Oct 24 11:24:54 2017	(r324951)
+++ head/libexec/rtld-elf/rtld.c	Tue Oct 24 12:04:07 2017	(r324952)
@@ -1824,10 +1824,9 @@ cleanup1:
 		if (dl > hint_stat.st_size)
 			goto cleanup1;
 		p = xmalloc(hdr.dirlistlen + 1);
-
-		if (lseek(fd, hdr.strtab + hdr.dirlist, SEEK_SET) == -1 ||
-		    read(fd, p, hdr.dirlistlen + 1) !=
-		    (ssize_t)hdr.dirlistlen + 1 || p[hdr.dirlistlen] != '\0') {
+		if (pread(fd, p, hdr.dirlistlen + 1,
+		    hdr.strtab + hdr.dirlist) != (ssize_t)hdr.dirlistlen + 1 ||
+		    p[hdr.dirlistlen] != '\0') {
 			free(p);
 			goto cleanup1;
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710241204.v9OC48oO031364>