diff options
author | Edward Pilatowicz <Edward.Pilatowicz@Sun.COM> | 2008-09-23 22:32:10 -0700 |
---|---|---|
committer | Edward Pilatowicz <Edward.Pilatowicz@Sun.COM> | 2008-09-23 22:32:10 -0700 |
commit | 186f7fbf5e07d046b50e4e15c32b21f109b76c80 (patch) | |
tree | 7bb0d0b3f1656c4959df4535c7adc296422b5863 /usr/src/lib/libproc/common/Pidle.c | |
parent | feccaf6df4d61f3e7e0723a768ce407f9eb6a1dd (diff) | |
download | illumos-gate-186f7fbf5e07d046b50e4e15c32b21f109b76c80.tar.gz |
PSARC/2008/490 pmadvise/pldd unresolved link map flag
6599704 libproc should look inside zones for objects
--HG--
rename : usr/src/lib/libproc/common/Pbrand.c => usr/src/lib/libproc/common/Pzone.c
Diffstat (limited to 'usr/src/lib/libproc/common/Pidle.c')
-rw-r--r-- | usr/src/lib/libproc/common/Pidle.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/usr/src/lib/libproc/common/Pidle.c b/usr/src/lib/libproc/common/Pidle.c index 4e23112152..5562385ef5 100644 --- a/usr/src/lib/libproc/common/Pidle.c +++ b/usr/src/lib/libproc/common/Pidle.c @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdlib.h> #include <libelf.h> #include <libgen.h> @@ -34,6 +31,7 @@ #include <errno.h> #include <sys/sysmacros.h> +#include "libproc.h" #include "Pcontrol.h" static ssize_t @@ -111,6 +109,7 @@ struct ps_prochandle * Pgrab_file(const char *fname, int *perr) { struct ps_prochandle *P = NULL; + char buf[PATH_MAX]; GElf_Ehdr ehdr; Elf *elf = NULL; size_t phnum; @@ -183,10 +182,16 @@ Pgrab_file(const char *fname, int *perr) fp->file_fd = fd; fp->file_lo->rl_lmident = LM_ID_BASE; - fp->file_lname = strdup(fp->file_pname); + if ((fp->file_lname = strdup(fp->file_pname)) == NULL) { + *perr = G_STRANGE; + goto err; + } fp->file_lbase = basename(fp->file_lname); - P->execname = strdup(fp->file_pname); + if ((P->execname = strdup(fp->file_pname)) == NULL) { + *perr = G_STRANGE; + goto err; + } P->num_files++; list_link(fp, &P->file_head); @@ -236,6 +241,7 @@ Pgrab_file(const char *fname, int *perr) P->status.pr_sid = (pid_t)-1; P->status.pr_taskid = (taskid_t)-1; P->status.pr_projid = (projid_t)-1; + P->status.pr_zoneid = (zoneid_t)-1; switch (ehdr.e_ident[EI_CLASS]) { case ELFCLASS32: P->status.pr_dmodel = PR_MODEL_ILP32; @@ -249,6 +255,18 @@ Pgrab_file(const char *fname, int *perr) } /* + * Pfindobj() checks what zone a process is associated with, so + * we call it after initializing pr_zoneid to -1. This ensures + * we don't get associated with any zone on the system. + */ + if (Pfindobj(P, fp->file_lname, buf, sizeof (buf)) != NULL) { + free(P->execname); + P->execname = strdup(buf); + if ((fp->file_rname = strdup(buf)) != NULL) + fp->file_rbase = basename(fp->file_rname); + } + + /* * The file and map lists are complete, and will never need to be * adjusted. */ |