diff options
author | Jeremy Jones <jeremy@delphix.com> | 2013-08-21 15:45:46 -0800 |
---|---|---|
committer | Christopher Siden <chris.siden@delphix.com> | 2013-08-21 16:45:46 -0700 |
commit | 2a12f85ad140e332791b4bad1208a734c3f26bf3 (patch) | |
tree | f4360a28249f0409ce5037f493a18f60e6219ea2 /usr/src/lib/libproc/common/Pidle.c | |
parent | 840b2722e5294ae44aa3af6189002f521d7c50e0 (diff) | |
download | illumos-gate-2a12f85ad140e332791b4bad1208a734c3f26bf3.tar.gz |
3946 ::gcore
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src/lib/libproc/common/Pidle.c')
-rw-r--r-- | usr/src/lib/libproc/common/Pidle.c | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/usr/src/lib/libproc/common/Pidle.c b/usr/src/lib/libproc/common/Pidle.c index 938510abeb..3191f4fa7e 100644 --- a/usr/src/lib/libproc/common/Pidle.c +++ b/usr/src/lib/libproc/common/Pidle.c @@ -22,6 +22,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright (c) 2013 by Delphix. All rights reserved. + */ #include <stdlib.h> #include <libelf.h> @@ -34,8 +37,10 @@ #include "libproc.h" #include "Pcontrol.h" +/*ARGSUSED*/ static ssize_t -Pread_idle(struct ps_prochandle *P, void *buf, size_t n, uintptr_t addr) +Pread_idle(struct ps_prochandle *P, void *buf, size_t n, uintptr_t addr, + void *data) { size_t resid = n; @@ -65,15 +70,55 @@ Pread_idle(struct ps_prochandle *P, void *buf, size_t n, uintptr_t addr) /*ARGSUSED*/ static ssize_t -Pwrite_idle(struct ps_prochandle *P, const void *buf, size_t n, uintptr_t addr) +Pwrite_idle(struct ps_prochandle *P, const void *buf, size_t n, uintptr_t addr, + void *data) { errno = EIO; return (-1); } -static const ps_rwops_t P_idle_ops = { - Pread_idle, - Pwrite_idle +/*ARGSUSED*/ +static int +Ppriv_idle(struct ps_prochandle *P, prpriv_t **pprv, void *data) +{ + prpriv_t *pp; + + pp = proc_get_priv(P->pid); + if (pp == NULL) { + return (-1); + } + + *pprv = pp; + return (0); +} + +/* Default operations for the idl ops vector. */ +static void * +Pidle_voidp() +{ + errno = ENODATA; + return (NULL); +} + +static int +Pidle_int() +{ + errno = ENODATA; + return (-1); +} + +static const ps_ops_t P_idle_ops = { + .pop_pread = Pread_idle, + .pop_pwrite = Pwrite_idle, + .pop_cred = (pop_cred_t)Pidle_int, + .pop_priv = Ppriv_idle, + .pop_psinfo = (pop_psinfo_t)Pidle_voidp, + .pop_platform = (pop_platform_t)Pidle_voidp, + .pop_uname = (pop_uname_t)Pidle_int, + .pop_zonename = (pop_zonename_t)Pidle_voidp, +#if defined(__i386) || defined(__amd64) + .pop_ldt = (pop_ldt_t)Pidle_int +#endif }; static int @@ -143,7 +188,7 @@ Pgrab_file(const char *fname, int *perr) P->agentctlfd = -1; P->agentstatfd = -1; P->info_valid = -1; - P->ops = &P_idle_ops; + Pinit_ops(&P->ops, &P_idle_ops); Pinitsym(P); if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) { |