From ba593b457a5ab400654c6144d1b52e43784780b2 Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Thu, 27 Aug 2015 11:26:18 +0000 Subject: [PATCH] Avoid unstructured procfs on Solaris (Cherry-picked commit f9711f5 from 'gcc_boehmgc' branch.) * os_dep.c [PROC_VDB] (GC_dirty_init): Use /proc//pagedata instead of PIOCOPENPD; remove fd local variable; increase buf[] size. --- os_dep.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/os_dep.c b/os_dep.c index 9f44395f..838c9373 100644 --- a/os_dep.c +++ b/os_dep.c @@ -3511,8 +3511,7 @@ GC_INNER GC_bool GC_page_was_dirty(struct hblk *h) GC_INNER void GC_dirty_init(void) { - int fd; - char buf[30]; + char buf[40]; if (GC_bytes_allocd != 0 || GC_bytes_allocd_before_gc != 0) { memset(GC_written_pages, 0xff, sizeof(page_hash_table)); @@ -3521,14 +3520,12 @@ GC_INNER void GC_dirty_init(void) (unsigned long)(GC_bytes_allocd + GC_bytes_allocd_before_gc)); } - (void)snprintf(buf, sizeof(buf), "/proc/%ld", (long)getpid()); + (void)snprintf(buf, sizeof(buf), "/proc/%ld/pagedata", (long)getpid()); buf[sizeof(buf) - 1] = '\0'; - fd = open(buf, O_RDONLY); - if (fd < 0) { + GC_proc_fd = open(buf, O_RDONLY); + if (GC_proc_fd < 0) { ABORT("/proc open failed"); } - GC_proc_fd = syscall(SYS_ioctl, fd, PIOCOPENPD, 0); - close(fd); syscall(SYS_fcntl, GC_proc_fd, F_SETFD, FD_CLOEXEC); if (GC_proc_fd < 0) { WARN("/proc ioctl(PIOCOPENPD) failed", 0); -- 2.40.0