summaryrefslogtreecommitdiffstats
path: root/sys/fs/procfs/procfs_map.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2003-09-29 20:53:19 +0000
committerrwatson <rwatson@FreeBSD.org>2003-09-29 20:53:19 +0000
commitff22b8b38f4e9c039cf374545491e7c83f719ca6 (patch)
tree3ec7addbf0f85c515af7f7f07cd07130d818002a /sys/fs/procfs/procfs_map.c
parent0e5948bb6b0fbb263d335c9fa1c7301047de8217 (diff)
downloadFreeBSD-src-ff22b8b38f4e9c039cf374545491e7c83f719ca6.zip
FreeBSD-src-ff22b8b38f4e9c039cf374545491e7c83f719ca6.tar.gz
Add a new column to the procfs map to hold the name of the mapped
file for vnode mappings. Note that this uses vn_fullpath() and may be somewhat unreliable, although not too unreliable for shared libraries. For non-vnode mappings, just print "-" for the field. Obtained from: TrustedBSD Projects Sponsored by: DARPA, AFRL, Network Associates Laboratories
Diffstat (limited to 'sys/fs/procfs/procfs_map.c')
-rw-r--r--sys/fs/procfs/procfs_map.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/fs/procfs/procfs_map.c b/sys/fs/procfs/procfs_map.c
index 3808145..478bcba 100644
--- a/sys/fs/procfs/procfs_map.c
+++ b/sys/fs/procfs/procfs_map.c
@@ -42,9 +42,12 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
+#include <sys/filedesc.h>
+#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/uio.h>
+#include <sys/vnode.h>
#include <fs/pseudofs/pseudofs.h>
#include <fs/procfs/procfs.h>
@@ -77,6 +80,7 @@ procfs_doprocmap(PFS_FILL_ARGS)
pmap_t pmap = vmspace_pmap(p->p_vmspace);
vm_map_entry_t entry;
char mebuffer[MEBUFFERSIZE];
+ char *fullpath, *freepath;
GIANT_REQUIRED;
@@ -124,6 +128,8 @@ procfs_doprocmap(PFS_FILL_ARGS)
for (lobj = tobj = obj; tobj; tobj = tobj->backing_object)
lobj = tobj;
+ freepath = NULL;
+ fullpath = "-";
if (lobj) {
switch(lobj->type) {
default:
@@ -132,6 +138,11 @@ procfs_doprocmap(PFS_FILL_ARGS)
break;
case OBJT_VNODE:
type = "vnode";
+ vn_fullpath(td,
+ (struct vnode *)lobj->handle,
+ &fullpath,
+ &freepath);
+ printf("string: %s\n", fullpath);
break;
case OBJT_SWAP:
type = "swap";
@@ -156,7 +167,7 @@ procfs_doprocmap(PFS_FILL_ARGS)
* start, end, resident, private resident, cow, access, type.
*/
snprintf(mebuffer, sizeof mebuffer,
- "0x%lx 0x%lx %d %d %p %s%s%s %d %d 0x%x %s %s %s\n",
+ "0x%lx 0x%lx %d %d %p %s%s%s %d %d 0x%x %s %s %s %s\n",
(u_long)entry->start, (u_long)entry->end,
resident, privateresident, obj,
(entry->protection & VM_PROT_READ)?"r":"-",
@@ -165,7 +176,10 @@ procfs_doprocmap(PFS_FILL_ARGS)
ref_count, shadow_count, flags,
(entry->eflags & MAP_ENTRY_COW)?"COW":"NCOW",
(entry->eflags & MAP_ENTRY_NEEDS_COPY)?"NC":"NNC",
- type);
+ type, fullpath);
+
+ if (freepath != NULL)
+ free(freepath, M_TEMP);
len = strlen(mebuffer);
if (len > uio->uio_resid) {
OpenPOWER on IntegriCloud