Print this page
3946 ::gcore
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
*** 20,29 ****
--- 20,32 ----
*/
/*
* 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>
#include <libgen.h>
#include <string.h>
*** 32,43 ****
#include <sys/sysmacros.h>
#include "libproc.h"
#include "Pcontrol.h"
static ssize_t
! Pread_idle(struct ps_prochandle *P, void *buf, size_t n, uintptr_t addr)
{
size_t resid = n;
while (resid > 0) {
map_info_t *mp;
--- 35,48 ----
#include <sys/sysmacros.h>
#include "libproc.h"
#include "Pcontrol.h"
+ /*ARGSUSED*/
static ssize_t
! Pread_idle(struct ps_prochandle *P, void *buf, size_t n, uintptr_t addr,
! void *data)
{
size_t resid = n;
while (resid > 0) {
map_info_t *mp;
*** 63,81 ****
return (n - resid);
}
/*ARGSUSED*/
static ssize_t
! Pwrite_idle(struct ps_prochandle *P, const void *buf, size_t n, uintptr_t addr)
{
errno = EIO;
return (-1);
}
! static const ps_rwops_t P_idle_ops = {
! Pread_idle,
! Pwrite_idle
};
static int
idle_add_mapping(struct ps_prochandle *P, GElf_Phdr *php, file_info_t *fp)
{
--- 68,126 ----
return (n - resid);
}
/*ARGSUSED*/
static ssize_t
! Pwrite_idle(struct ps_prochandle *P, const void *buf, size_t n, uintptr_t addr,
! void *data)
{
errno = EIO;
return (-1);
}
! /*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
idle_add_mapping(struct ps_prochandle *P, GElf_Phdr *php, file_info_t *fp)
{
*** 141,151 ****
P->ctlfd = -1;
P->statfd = -1;
P->agentctlfd = -1;
P->agentstatfd = -1;
P->info_valid = -1;
! P->ops = &P_idle_ops;
Pinitsym(P);
if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
*perr = G_ELF;
return (NULL);
--- 186,196 ----
P->ctlfd = -1;
P->statfd = -1;
P->agentctlfd = -1;
P->agentstatfd = -1;
P->info_valid = -1;
! Pinit_ops(&P->ops, &P_idle_ops);
Pinitsym(P);
if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
*perr = G_ELF;
return (NULL);