Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Jun 2012 15:54:53 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r236717 - head/lib/libprocstat
Message-ID:  <201206071554.q57Fsr9S097274@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Thu Jun  7 15:54:52 2012
New Revision: 236717
URL: http://svn.freebsd.org/changeset/base/236717

Log:
  Teach procstat_get_shm_info_kvm() how to fetch the pathname of a SHM file
  descriptor from a core and set it in fts->fs_path.
  
  MFC after:	1 week

Modified:
  head/lib/libprocstat/libprocstat.c

Modified: head/lib/libprocstat/libprocstat.c
==============================================================================
--- head/lib/libprocstat/libprocstat.c	Thu Jun  7 14:38:43 2012	(r236716)
+++ head/lib/libprocstat/libprocstat.c	Thu Jun  7 15:54:52 2012	(r236717)
@@ -881,6 +881,8 @@ procstat_get_shm_info_kvm(kvm_t *kd, str
 {
 	struct shmfd shmfd;
 	void *shmfdp;
+	char *path;
+	int i;
 
 	assert(kd);
 	assert(shm);
@@ -896,6 +898,21 @@ procstat_get_shm_info_kvm(kvm_t *kd, str
 	}
 	shm->mode = S_IFREG | shmfd.shm_mode;
 	shm->size = shmfd.shm_size;
+	if (fst->fs_path == NULL && shmfd.shm_path != NULL) {
+		path = malloc(MAXPATHLEN);
+		for (i = 0; i < MAXPATHLEN - 1; i++) {
+			if (!kvm_read_all(kd, (unsigned long)shmfd.shm_path + i,
+			    path + i, 1))
+				break;
+			if (path[i] == '\0')
+				break;
+		}
+		path[i] = '\0';
+		if (i == 0)
+			free(path);
+		else
+			fst->fs_path = path;
+	}
 	return (0);
 
 fail:



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