Ejemplo n.º 1
0
int
ka_open(void **misc)
{
    int rcode;
    struct kainfo *kp;


    kp = s_malloc(sizeof(*kp));
    
    /*
    ** Open the kernel memory device
    */
    if ((kp->kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL)) == NULL)
    {
	if (debug)
		perror("kvm_open");

	syslog(LOG_ERR, "kvm_open: %m");
	s_free(kp);
	return -1;
    }

    kp->nl[0].n_name = "_file";
    kp->nl[1].n_name = "_nfile";
#ifdef HPUX7
    kp->nl[2].n_name = "_tcb_cb";
#else
    kp->nl[2].n_name = "_tcb";
#endif
    kp->nl[3].n_name = NULL;
    
    /*
    ** Extract offsets to the needed variables in the kernel
    */
    if ((rcode = kvm_nlist(kp->kd, kp->nl)) != 0)
    {
	kp->nl[0].n_name = "file";
	kp->nl[1].n_name = "nfile";
#ifdef HPUX7
	kp->nl[2].n_name = "tcb_cb";
#else
	kp->nl[2].n_name = "tcb";
#endif
	
	if ((rcode = kvm_nlist(kp->kd, kp->nl)) != 0)
	{
	    if (debug)
		fprintf(stderr, "kvm_nlist: returned %d\n", rcode);

	    syslog(LOG_ERR, "kvm_nlist, rcode = %d: %m", rcode);
	    kvm_close(kp->kd);
	    s_free(kp);
	    return -1;
	}
    }

    *misc = (void *) kp;
    return 0;
}
Ejemplo n.º 2
0
void
load_symbols(kvm_t *kd)
{
	int rc, i, mib[2];
	size_t sz;

	rc = kvm_nlist(kd, &ksyms[0]);
	if (rc != 0) {
		for (i = 0; ksyms[i].n_name != NULL; i++)
			if (ksyms[i].n_value == 0)
				warnx("symbol %s: not found", ksyms[i].n_name);
		exit(1);
	}

	uvm_vnodeops =	(void*)ksyms[NL_UVM_VNODEOPS].n_value;
	uvm_deviceops =	(void*)ksyms[NL_UVM_DEVICEOPS].n_value;
	aobj_pager =	(void*)ksyms[NL_AOBJ_PAGER].n_value;
	ubc_pager =	(void*)ksyms[NL_UBC_PAGER].n_value;

	nchash_addr =	ksyms[NL_NCHASH].n_value;

	_KDEREF(kd, ksyms[NL_MAXSSIZ].n_value, &maxssiz,
		sizeof(maxssiz));
	_KDEREF(kd, ksyms[NL_NCHASHTBL].n_value, &nchashtbl_addr,
	       sizeof(nchashtbl_addr));
	_KDEREF(kd, ksyms[NL_KERNEL_MAP].n_value, &kernel_map_addr,
		sizeof(kernel_map_addr));

	/*
	 * Some of these may be missing from some platforms, for
	 * example sparc, sh3, and most powerpc platforms don't
	 * have a "phys_map", etc.
	 */
	(void)kvm_nlist(kd, &kmaps[0]);

#define get_map_address(m) do {\
	if (kmaps[__CONCAT(NL_,m)].n_value != 0) \
		_KDEREF(kd, kmaps[__CONCAT(NL_,m)].n_value, &m, sizeof(m)); \
	} while (0/*CONSTCOND*/)

	get_map_address(kmem_map);
	get_map_address(mb_map);
	get_map_address(phys_map);
	get_map_address(exec_map);
	get_map_address(pager_map);
	get_map_address(st_map);
	get_map_address(pt_map);
	get_map_address(lkm_map);
	get_map_address(buf_map);

	mib[0] = CTL_HW;
	mib[1] = HW_PAGESIZE;
	sz = sizeof(page_size);
	if (sysctl(&mib[0], 2, &page_size, &sz, NULL, 0) == -1)
		err(1, "sysctl: hw.pagesize");
}
Ejemplo n.º 3
0
int
_kvm_initvtop(kvm_t *kd)
{
	struct vmstate *vm;
	struct nlist nl[4];
	struct uvmexp uvmexp;

	vm = (struct vmstate *)_kvm_malloc(kd, sizeof(*vm));
	if (vm == 0)
		return (-1);
	kd->vmst = vm;

	nl[0].n_name = "Sysmap";
	nl[1].n_name = "Sysmapsize";
	nl[2].n_name = "uvmexp";
	nl[3].n_name = 0;

	if (kvm_nlist(kd, nl) != 0) {
		_kvm_err(kd, kd->program, "bad namelist");
		return (-1);
	}
	if (KREAD(kd, (u_long)nl[0].n_value, &vm->Sysmap)) {
		_kvm_err(kd, kd->program, "cannot read Sysmap");
		return (-1);
	}
	if (KREAD(kd, (u_long)nl[1].n_value, &vm->Sysmapsize)) {
		_kvm_err(kd, kd->program, "cannot read Sysmapsize");
		return (-1);
	}
	/*
	 * We are only interested in the first three fields of struct
	 * uvmexp, so do not try to read more than necessary (especially
	 * in case the layout changes).
	 */
	if (kvm_read(kd, (u_long)nl[2].n_value, &uvmexp,
	    3 * sizeof(int)) != 3 * sizeof(int)) {
		_kvm_err(kd, kd->program, "cannot read uvmexp");
		return (-1);
	}
	vm->pagesize = uvmexp.pagesize;
	vm->pagemask = uvmexp.pagemask;
	vm->pageshift = uvmexp.pageshift;

	/*
	 * Older kernels might not have this symbol; in which case
	 * we use the value of VM_MIN_KERNE_ADDRESS they must have.
	 */

	nl[0].n_name = "Sysmapbase";
	nl[1].n_name = 0;
	if (kvm_nlist(kd, nl) != 0 ||
	    KREAD(kd, (u_long)nl[0].n_value, &vm->Sysmapbase))
		vm->Sysmapbase = (vaddr_t)CKSSEG_BASE;

	return (0);
}
Ejemplo n.º 4
0
int k_open(void) {
	kinfo = xmalloc(sizeof(struct kainfo));

	kinfo->kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
	if (kinfo->kd == NULL) {
		free(kinfo);
		debug("kvm_open: %s", strerror(errno));
		return (-1);
	}

	kinfo->nl[N_TCB].n_name = "_tcb";

#ifdef MASQ_SUPPORT
	if (opt_enabled(MASQ))
		kinfo->nl[N_NATLIST].n_name = "_nat_instances";
	else
		kinfo->nl[N_NATLIST].n_name = NULL;
#endif

	kinfo->nl[N_TOTAL - 1].n_name = NULL;

	if (kvm_nlist(kinfo->kd, kinfo->nl) != 0) {
		kvm_close(kinfo->kd);
		free(kinfo);
		debug("kvm_nlist: %s", strerror(errno));
		return (-1);
	}

#ifdef MASQ_SUPPORT
	if (kinfo->nl[N_NATLIST].n_value == 0)
		disable_opt(MASQ);
#endif

	return (0);
}
Ejemplo n.º 5
0
void
mem_init(void)
{
    int pagesize;

    if (!(kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")))
    {
        perror("kvm_open");
        exit(1);
    }

    kvm_nlist(kd, nlst);

    if (!nlst[0].n_type)
    {
        perror("kvm_nlist");
        exit(1);
    }

    seteuid(getuid());
    setegid(getgid());

    if (geteuid() != getuid() || getegid() != getgid())
    {
        perror("sete?id");
        exit(1);
    }
}
Ejemplo n.º 6
0
void
cpu_init(void)
{

    kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open");

    if (kd == NULL) {
	fprintf(stderr, "can't open kernel virtual memory");
	exit(1);
    }

    kvm_nlist(kd, nlst);

    if (nlst[0].n_type == 0) {
	fprintf(stderr, "error extracting symbols");
	exit(1);
    }

    /* drop setgid & setuid (the latter should not be there really) */
    seteuid(getuid());
    setegid(getgid());

    if (geteuid() != getuid() || getegid() != getgid()) {
	fprintf(stderr, "unable to drop privileges");
	exit(1);
    }
}
Ejemplo n.º 7
0
Archivo: aux.c Proyecto: sergev/2.11BSD
int k_open()
{
  /*
  ** Open the kernel memory device
  */
  if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
    ERROR("main: kvm_open");

  /* Kludge - have to do it here or A/UX 3 will barf */
#define N_FILE 0  
#define N_TCB 1
#ifdef n_name
  strcpy(nl[N_FILE].n_name,"file");
  strcpy(nl[N_TCB].n_name,"tcb");
  strcpy(nl[2].n_name,"");
#else
  nl[N_FILE].n_name = "file";
  nl[N_TCB].n_name  = "tcb";
  nl[2].n_name = "";
#endif
  
  /*
  ** Extract offsets to the needed variables in the kernel
  */
  if (kvm_nlist(kd, nl) != 0)
    ERROR("main: kvm_nlist");

  return 0;
}
Ejemplo n.º 8
0
Archivo: vtw.c Proyecto: ryo/netbsd-src
static void *
lookup(const char *name)
{
	kvm_t *k;
	struct nlist nl[2];

	nl[0].n_name = name;
	nl[0].n_value = 0;
	nl[1].n_name = NULL;

	if ((k = get_kvmd()) == NULL) {
		if (Vflag)
			errx(EXIT_FAILURE, "kvm not available");
		return NULL;
	}
	switch (kvm_nlist(k, &nl[0])) {
	case -1:
		err(EXIT_FAILURE, "kvm_nlist");
		break;

	case 0:
		return (void *)nl[0].n_value;

	default:
		if (Vflag)
			errx(EXIT_FAILURE, "%s missing in symbol table", name);
		break;
	}

	return NULL;
}
Ejemplo n.º 9
0
static int
kvmd_init(void)
{
	char errbuf[_POSIX2_LINE_MAX];

	if (kvmd != NULL)
		return (0);

	kvmd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
	setgid(getgid());

	if (kvmd == NULL) {
		warnx("kvm not available: %s", errbuf);
		return (-1);
	}

	if (kvm_nlist(kvmd, nl) < 0) {
		if (nlistf)
			errx(1, "%s: kvm_nlist: %s", nlistf,
			     kvm_geterr(kvmd));
		else
			errx(1, "kvm_nlist: %s", kvm_geterr(kvmd));
	}

	if (nl[0].n_type == 0) {
		if (nlistf)
			errx(1, "%s: no namelist", nlistf);
		else
			errx(1, "no namelist");
	}

	return (0);
}
Ejemplo n.º 10
0
static void
fstat_kvm(int what, int arg)
{
	struct kinfo_proc *p, *plast;
	char buf[_POSIX2_LINE_MAX];
	int cnt;

	ALLOC_OFILES(256);	/* reserve space for file pointers */

	/*
	 * Discard setgid privileges if not the running kernel so that bad
	 * guys can't print interesting stuff from kernel memory.
	 */
	if (nlistf != NULL || memf != NULL)
		setgid(getgid());

	if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, buf)) == NULL)
		errx(1, "%s", buf);
	setgid(getgid());
#ifdef notdef
	if (kvm_nlist(kd, nl) != 0)
		errx(1, "no namelist: %s", kvm_geterr(kd));
#endif
	if ((p = kvm_getprocs(kd, what, arg, &cnt)) == NULL)
		errx(1, "%s", kvm_geterr(kd));
	print_header();
	for (plast = &p[cnt]; p < plast; ++p) {
		if (p->ki_stat == SZOMB)
			continue;
		dofiles(p);
		if (mflg)
			dommap(p);
	}
}
Ejemplo n.º 11
0
static int conn_init(void) {
  char buf[_POSIX2_LINE_MAX];
  struct nlist nl[] = {
#define N_TCBTABLE 0
      {"_tcbtable"}, {""}};
  int status;

  kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, buf);
  if (kvmd == NULL) {
    ERROR("tcpconns plugin: kvm_openfiles failed: %s", buf);
    return (-1);
  }

  status = kvm_nlist(kvmd, nl);
  if (status < 0) {
    ERROR("tcpconns plugin: kvm_nlist failed with status %i.", status);
    return (-1);
  }

  if (nl[N_TCBTABLE].n_type == 0) {
    ERROR("tcpconns plugin: Error looking up kernel's namelist: "
          "N_TCBTABLE is invalid.");
    return (-1);
  }

  inpcbtable_off = (u_long)nl[N_TCBTABLE].n_value;
  inpcbtable_ptr = (struct inpcbtable *)nl[N_TCBTABLE].n_value;

  return (0);
} /* int conn_init */
Ejemplo n.º 12
0
static int
nlist_init(kvm_t *kd)
{

	if (kvm_swap_nl_cached)
		return (1);

	if (kvm_nlist(kd, kvm_swap_nl) < 0)
		return (0);

	/* Required entries */
	if (kvm_swap_nl[NL_SWTAILQ].n_value == 0) {
		_kvm_err(kd, kd->program, "unable to find swtailq");
		return (0);
	}
		
	if (kvm_swap_nl[NL_DMMAX].n_value == 0) {
		_kvm_err(kd, kd->program, "unable to find dmmax");
		return (0);
	}

	/* Get globals, type of swap */
	KGET(NL_DMMAX, &dmmax);

	kvm_swap_nl_cached = 1;
	return (1);
}
int
_kvm_initvtop(kvm_t *kd)
{
	struct vmstate *vm;
	struct stat st;
	struct nlist nl[2];

	vm = (struct vmstate *)_kvm_malloc(kd, sizeof(*vm));
	if (vm == 0)
		return (-1);

	kd->vmst = vm;

	if (fstat(kd->pmfd, &st) < 0)
		return (-1);

	/* Get end of kernel address */
	nl[0].n_name = "_end";
	nl[1].n_name = 0;
	if (kvm_nlist(kd, nl) != 0) {
		_kvm_err(kd, kd->program, "pmap_stod: no such symbol");
		return (-1);
	}
	vm->end = (u_long)nl[0].n_value;

	return (0);
}
Ejemplo n.º 14
0
static kvm_t *
kopen(char const *memf)
{
	kvm_t	*kvmd = NULL;
	char	 errbuf[_POSIX2_LINE_MAX];

	kvmd = kvm_openfiles(NULL, memf, NULL, O_RDONLY, errbuf);
	if (setgid(getgid()) != 0)
		err(1, "setgid");
	if (kvmd == NULL) {
		warnx("kvm_openfiles: %s", errbuf);
		return (NULL);
	}

	if (kvm_nlist(kvmd, nl) < 0) {
		warnx("kvm_nlist: %s", kvm_geterr(kvmd));
		goto fail;
	}

	if (nl[0].n_type == 0) {
		warnx("kvm_nlist: no namelist");
		goto fail;
	}

	return (kvmd);
fail:
	kvm_close(kvmd);

	return (NULL);
} /* kopen */
Ejemplo n.º 15
0
static void
dumpfile_init()

{
	kvm_p = kvm_open(namelist, dumpfile, NULL, O_RDONLY, program_name);
	if (kvm_p == NULL) {
		/* kvm_open prints an error message */
		exit(1);
	}
	if (kvm_nlist(kvm_p, kvm_syms) != 0) {
		(void) fprintf(stderr, gettext(
			"Symbol lookup error in %s\n"), namelist);
		exit(1);
	}
	if (kvm_read(kvm_p, kvm_syms[0].n_value, (char *) &dump_bufaddr,
	    sizeof (dump_bufaddr)) != sizeof (dump_bufaddr) ||
	    kvm_read(kvm_p, kvm_syms[1].n_value, (char *) &tnf_bufsize,
	    sizeof (tnf_bufsize)) != sizeof (tnf_bufsize)) {
		(void) fprintf(stderr, gettext(
			"kvm_read error in %s\n"), dumpfile);
		exit(1);
	}
	if (dump_bufaddr == NULL || tnf_bufsize == 0) {
		(void) fprintf(stderr, gettext(
			"No trace data available in the kernel.\n"));
		exit(1);
	}
}
Ejemplo n.º 16
0
int
initvmstat(void)
{
	static char *intrnamebuf;
	char *cp;
	int i;

	if (intrnamebuf)
		free(intrnamebuf);
	if (intrname)
		free(intrname);
	if (intrloc)
		free(intrloc);

	if (namelist[0].n_type == 0) {
		if (kvm_nlist(kd, namelist) &&
		    namelist[X_ALLEVENTS].n_type == 0) {
			nlisterr(namelist);
			return(0);
		}
	}
	hertz = stathz ? stathz : hz;
	if (!drvinit(1))
		return(0);

	/* Old style interrupt counts - deprecated */
	nintr = (namelist[X_EINTRCNT].n_value -
		namelist[X_INTRCNT].n_value) / sizeof (long);
	if (nintr) {
		intrloc = calloc(nintr, sizeof (long));
		intrname = calloc(nintr, sizeof (long));
		intrnamebuf = malloc(namelist[X_EINTRNAMES].n_value -
				     namelist[X_INTRNAMES].n_value);
		if (intrnamebuf == NULL || intrname == 0 || intrloc == 0) {
			error("Out of memory\n");
			nintr = 0;
			return(0);
		}
		NREAD(X_INTRNAMES, intrnamebuf, NVAL(X_EINTRNAMES) -
		      NVAL(X_INTRNAMES));
		for (cp = intrnamebuf, i = 0; i < nintr; i++) {
			intrname[i] = cp;
			cp += strlen(cp) + 1;
		}
	}

	/* event counter interrupt counts */
	get_interrupt_events();

	nextintsrow = INTSROW + 1;
	allocinfo(&s);
	allocinfo(&s1);
	allocinfo(&s2);
	allocinfo(&z);

	getinfo(&s2);
	copyinfo(&s2, &s1);
	return(1);
}
Ejemplo n.º 17
0
static int
_kvm_cp_time_init(kvm_t *kd)
{

    if (kvm_nlist(kd, kvm_cp_time_nl) < 0)
        return (-1);
    kvm_cp_time_cached = 1;
    return (0);
}
Ejemplo n.º 18
0
void
_glibtop_init_netload_p (glibtop *server)
{
    if (kvm_nlist (server->machine->kd, nlst) < 0) {
        glibtop_warn_io_r (server, "kvm_nlist");
        return;
    }

    server->sysdeps.netload = _glibtop_sysdeps_netload;
}
Ejemplo n.º 19
0
Archivo: net.c Proyecto: Shmuma/z
static int get_ifdata(const char *device, struct ifnet *result)
{
	struct ifnet_head	head;
	struct ifnet 		*ifp;
	
	char 	ifname[IFNAMSIZ+1];
	kvm_t 	*kp;
	int	len = 0;
	int 	ret = SYSINFO_RET_FAIL;
	
	kp = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);

	if(kp)
	{
		if(kernel_symbols[IFNET_ID].n_type == N_UNDF)
		{
			if(kvm_nlist(kp, &kernel_symbols[0]) != 0)
			{
				kernel_symbols[IFNET_ID].n_type = N_UNDF;
			}
		}
		
		if(kernel_symbols[IFNET_ID].n_type != N_UNDF)
		{
			len = sizeof(struct ifnet_head);
			if(kvm_read(kp, kernel_symbols[IFNET_ID].n_value, &head, len) >= len)
			{
				len = sizeof(struct ifnet);
				for(ifp = head.tqh_first; ifp; ifp = result->if_list.tqe_next)
				{
					if(kvm_read(kp, (u_long) ifp, result, len) < len)
						break;
					
					memcpy(
						ifname, 
						result->if_xname, 
						MIN(sizeof(ifname)- 1, IFNAMSIZ)
					);
					ifname[IFNAMSIZ] = '\0';

					if(strcmp(device, ifname) == 0)
					{
						ret = SYSINFO_RET_OK;
						break;
					}
				}
			}
		}
		kvm_close(kp);
	}

   return ret;
}
Ejemplo n.º 20
0
void initCpuInfo(struct SensorModul *sm)
{
    /* Total CPU load */
    registerMonitor("cpu/user", "integer", printCPUUser, printCPUUserInfo, sm);
    registerMonitor("cpu/nice", "integer", printCPUNice, printCPUNiceInfo, sm);
    registerMonitor("cpu/sys", "integer", printCPUSys, printCPUSysInfo, sm);
    registerMonitor("cpu/idle", "integer", printCPUIdle, printCPUIdleInfo, sm);
    kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open");
    kvm_nlist(kd, my_nlist);
    cp_time_offset = my_nlist[0].n_value;

    updateCpuInfo();
}
Ejemplo n.º 21
0
void
_glibtop_init_shm_limits_p (glibtop *server)
{
#if GLIBTOP_SOLARIS_RELEASE < 51000

	kvm_t * const kd = server->machine->kd;

	if(kd && !kvm_nlist(kd, nlst))
		server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
	else
		server->sysdeps.shm_limits = 0;
#endif
}
Ejemplo n.º 22
0
void
ddb_capture(int argc, char *argv[])
{
	char *mflag, *nflag, errbuf[_POSIX2_LINE_MAX];
	kvm_t *kvm;
	int ch;

	mflag = NULL;
	nflag = NULL;
	kvm = NULL;
	while ((ch = getopt(argc, argv, "M:N:")) != -1) {
		switch (ch) {
		case 'M':
			mflag = optarg;
			break;

		case 'N':
			nflag = optarg;
			break;

		default:
			usage();
		}
	}
	argc -= optind;
	argv += optind;

	if (argc != 1)
		usage();

	if (mflag != NULL) {
		kvm = kvm_openfiles(nflag, mflag, NULL, O_RDONLY, errbuf);
		if (kvm == NULL)
			errx(-1, "ddb_capture: kvm_openfiles: %s", errbuf);
		if (kvm_nlist(kvm, namelist) != 0)
			errx(-1, "ddb_capture: kvm_nlist");
	} else if (nflag != NULL)
		usage();
	if (strcmp(argv[0], "print") == 0) {
		if (kvm != NULL)
			ddb_capture_print_kvm(kvm);
		else
			ddb_capture_print_sysctl();
	} else if (strcmp(argv[0], "status") == 0) {
		if (kvm != NULL)
			ddb_capture_status_kvm(kvm);
		else
			ddb_capture_status_sysctl();
	} else
		usage();
}
Ejemplo n.º 23
0
static int 
openkvm(void)
{
	if ((kvmfd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL)) == NULL)
		return FALSE;
	
	if (kvm_nlist(kvmfd, symbols) < 0)
		return FALSE;
	   
	if (kvm_read(kvmfd, (unsigned long) symbols[0].n_value, &ifnet_savedaddr, sizeof(unsigned long)) == -1)
		return FALSE;
		
	return TRUE;
}
Ejemplo n.º 24
0
Archivo: ppp.c Proyecto: GNOME/libgtop
void
_glibtop_init_ppp_p (glibtop *server)
{
#ifdef HAVE_I4B
#ifdef HAVE_I4B_ACCT
	server->sysdeps.ppp = _glibtop_sysdeps_ppp |
		_glibtop_sysdeps_ppp_acct;
#else
	server->sysdeps.ppp = _glibtop_sysdeps_ppp;
#endif
#endif /* HAVE_I4B */

	if (kvm_nlist (server->machine->kd, nlst) < 0)
		glibtop_error_io_r (server, "kvm_nlist");
}
Ejemplo n.º 25
0
int k_open()
{
  /*
  ** Open the kernel memory device
  */
  if (!(kd = kvm_open(path_unix, path_kmem, NULL, O_RDONLY, NULL)))
    ERROR("main: kvm_open");
  
  /*
  ** Extract offsets to the needed variables in the kernel
  */
  if (kvm_nlist(kd, nl) != 0)
    ERROR("main: kvm_nlist");

  return 0;
}
Ejemplo n.º 26
0
void
_glibtop_init_msg_limits_p (glibtop *server)
{
	if (kvm_nlist (server->machine->kd, nlst) < 0) {
		glibtop_warn_io_r (server, "kvm_nlist (msg_limits)");
		return;
	}

	if (kvm_read (server->machine->kd, nlst [0].n_value,
		      &_msginfo, sizeof (_msginfo)) != sizeof (_msginfo)) {
		glibtop_warn_io_r (server, "kvm_read (msginfo)");
		return;
	}

	server->sysdeps.msg_limits = _glibtop_sysdeps_msg_limits;
}
Ejemplo n.º 27
0
Archivo: tcp.c Proyecto: MarginC/kame
int
inittcp(void)
{

	if (namelist[0].n_type == 0) {
		if (kvm_nlist(kd, namelist)) {
			nlisterr(namelist);
			return(0);
		}
		if (namelist[0].n_type == 0) {
			error("No namelist");
			return(0);
		}
	}
	return 1;
}
Ejemplo n.º 28
0
Archivo: ip6.c Proyecto: MarginC/kame
int
initip6(void)
{
	int n;

	if (namelist[0].n_type == 0) {
		n = kvm_nlist(kd, namelist);
		if (n < 0) {
			nlisterr(namelist);
			return(0);
		} else if (n == sizeof(namelist) / sizeof(namelist[0]) - 1) {
			error("No namelist");
			return(0);
		}
	}
	return 1;
}
Ejemplo n.º 29
0
int k_open(void) {
	kinfo = xmalloc(sizeof(struct kainfo));

	kinfo->kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
	if (kinfo->kd == NULL) {
		free(kinfo);
		debug("kvm_open: %s", strerror(errno));
		return (-1);
	}

	kinfo->nl[N_TCB].n_name = "_tcbtable";

#ifdef WANT_IPV6
#if __NetBSD_Version__ >= 106250000	/* 1.6Y */
	kinfo->nl[N_TCB6].n_name = "_tcbtable";
#else
	kinfo->nl[N_TCB6].n_name = "_tcb6";
#endif
#else
	kinfo->nl[N_TCB6].n_name = "_oidentd_nonexistent";
#endif

#ifdef MASQ_SUPPORT
	if (opt_enabled(MASQ))
		kinfo->nl[N_NATLIST].n_name = "_nat_instances";
	else
		kinfo->nl[N_NATLIST].n_name = "NULL";
#endif

	kinfo->nl[N_TOTAL - 1].n_name = NULL;

	if (kvm_nlist(kinfo->kd, kinfo->nl) == -1) {
		kvm_close(kinfo->kd);
		free(kinfo);
		debug("kvm_nlist: %s", strerror(errno));
		return (-1);
	}

#ifdef MASQ_SUPPORT
	if (kinfo->nl[N_NATLIST].n_value == 0)
		disable_opt(MASQ);
#endif

	return (0);
}
Ejemplo n.º 30
0
static int openbsd_init ()
{
    struct nlist nlst [] = {
        { "_hz" },
        { 0 }
    };
    kvm_nlist(openbsd_kvm,nlst);
    if (nlst[0].n_type == 0) {
        and_printf(0,"KVM: nlist failed. Aborting.\n");
        abort();
    }
    if (kvm_read(openbsd_kvm,nlst[0].n_value,(char*)(&openbsd_hz),
                 sizeof(openbsd_hz)) != sizeof(openbsd_hz)) {
        and_printf(0,"KVM: hz symbol empty. Aborting.\n");
        abort();
    }
    return 1;
}