Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Jun 2012 15:30:15 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r237792 - stable/9/lib/libprocstat
Message-ID:  <201206291530.q5TFUFNh053812@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Jun 29 15:30:14 2012
New Revision: 237792
URL: http://svn.freebsd.org/changeset/base/237792

Log:
  MFC 236717:
  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.

Modified:
  stable/9/lib/libprocstat/libprocstat.c
Directory Properties:
  stable/9/lib/libprocstat/   (props changed)

Modified: stable/9/lib/libprocstat/libprocstat.c
==============================================================================
--- stable/9/lib/libprocstat/libprocstat.c	Fri Jun 29 15:27:17 2012	(r237791)
+++ stable/9/lib/libprocstat/libprocstat.c	Fri Jun 29 15:30:14 2012	(r237792)
@@ -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?201206291530.q5TFUFNh053812>