2005-01-05 22:34:37 +00:00
|
|
|
/*-
|
2008-11-05 15:08:09 +00:00
|
|
|
* Copyright (c) 2000 Dag-Erling Coïdan Smørgrav
|
2000-09-07 16:44:26 +00:00
|
|
|
* Copyright (c) 1999 Pierre Beyssac
|
2000-04-20 03:54:27 +00:00
|
|
|
* Copyright (c) 1993 Jan-Simon Pendry
|
|
|
|
* Copyright (c) 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Jan-Simon Pendry.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* @(#)procfs_status.c 8.4 (Berkeley) 6/15/94
|
|
|
|
*/
|
|
|
|
|
2008-08-25 04:55:29 +00:00
|
|
|
#include "opt_compat.h"
|
|
|
|
|
2003-06-10 21:29:12 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2000-04-20 03:54:27 +00:00
|
|
|
#include <sys/param.h>
|
2001-09-25 13:24:24 +00:00
|
|
|
#include <sys/queue.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
#include <sys/blist.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/conf.h>
|
2001-09-25 13:24:24 +00:00
|
|
|
#include <sys/exec.h>
|
2008-03-31 12:01:21 +00:00
|
|
|
#include <sys/fcntl.h>
|
2003-09-09 08:19:06 +00:00
|
|
|
#include <sys/filedesc.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/jail.h>
|
2000-09-09 11:44:58 +00:00
|
|
|
#include <sys/kernel.h>
|
2001-09-25 13:24:24 +00:00
|
|
|
#include <sys/linker.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/lock.h>
|
2001-03-12 03:16:56 +00:00
|
|
|
#include <sys/malloc.h>
|
2001-06-10 23:23:59 +00:00
|
|
|
#include <sys/mount.h>
|
2007-03-30 17:56:44 +00:00
|
|
|
#include <sys/msg.h>
|
2001-05-19 01:28:09 +00:00
|
|
|
#include <sys/mutex.h>
|
2001-10-21 15:56:46 +00:00
|
|
|
#include <sys/namei.h>
|
2000-09-09 11:44:58 +00:00
|
|
|
#include <sys/proc.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
#include <sys/resourcevar.h>
|
2000-12-13 20:22:24 +00:00
|
|
|
#include <sys/sbuf.h>
|
2007-03-30 17:56:44 +00:00
|
|
|
#include <sys/sem.h>
|
2003-12-07 17:38:20 +00:00
|
|
|
#include <sys/smp.h>
|
2001-09-25 13:24:24 +00:00
|
|
|
#include <sys/socket.h>
|
2001-05-19 05:54:26 +00:00
|
|
|
#include <sys/sysctl.h>
|
2001-09-25 13:24:24 +00:00
|
|
|
#include <sys/systm.h>
|
2006-06-27 20:11:58 +00:00
|
|
|
#include <sys/time.h>
|
2000-09-09 11:44:58 +00:00
|
|
|
#include <sys/tty.h>
|
2001-09-25 13:24:24 +00:00
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/vmmeter.h>
|
2000-09-09 11:44:58 +00:00
|
|
|
#include <sys/vnode.h>
|
2009-03-26 17:14:22 +00:00
|
|
|
#include <sys/bus.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
|
2001-09-25 13:24:24 +00:00
|
|
|
#include <net/if.h>
|
2008-12-02 21:37:28 +00:00
|
|
|
#include <net/vnet.h>
|
2001-09-25 13:24:24 +00:00
|
|
|
|
2000-04-20 03:54:27 +00:00
|
|
|
#include <vm/vm.h>
|
2008-12-12 12:12:36 +00:00
|
|
|
#include <vm/vm_extern.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
#include <vm/pmap.h>
|
2000-10-25 22:12:59 +00:00
|
|
|
#include <vm/vm_map.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
#include <vm/vm_param.h>
|
2000-05-24 07:37:02 +00:00
|
|
|
#include <vm/vm_object.h>
|
2000-04-20 03:54:27 +00:00
|
|
|
#include <vm/swap_pager.h>
|
2000-12-09 13:25:54 +00:00
|
|
|
|
2000-10-25 22:38:23 +00:00
|
|
|
#include <machine/clock.h>
|
2001-06-11 21:55:40 +00:00
|
|
|
|
2009-03-26 17:14:22 +00:00
|
|
|
#include <geom/geom.h>
|
|
|
|
#include <geom/geom_int.h>
|
|
|
|
|
2004-08-16 08:19:18 +00:00
|
|
|
#if defined(__i386__) || defined(__amd64__)
|
2000-04-20 03:54:27 +00:00
|
|
|
#include <machine/cputypes.h>
|
2000-10-25 22:38:23 +00:00
|
|
|
#include <machine/md_var.h>
|
2004-08-16 08:19:18 +00:00
|
|
|
#endif /* __i386__ || __amd64__ */
|
2000-04-20 03:54:27 +00:00
|
|
|
|
2005-01-14 04:44:56 +00:00
|
|
|
#ifdef COMPAT_LINUX32 /* XXX */
|
2004-08-16 08:19:18 +00:00
|
|
|
#include <machine/../linux32/linux.h>
|
2005-01-14 04:44:56 +00:00
|
|
|
#else
|
|
|
|
#include <machine/../linux/linux.h>
|
2004-08-16 08:19:18 +00:00
|
|
|
#endif
|
2001-10-19 01:45:03 +00:00
|
|
|
#include <compat/linux/linux_ioctl.h>
|
2000-12-13 20:22:24 +00:00
|
|
|
#include <compat/linux/linux_mib.h>
|
2001-10-21 15:56:46 +00:00
|
|
|
#include <compat/linux/linux_util.h>
|
2001-06-10 23:23:59 +00:00
|
|
|
#include <fs/pseudofs/pseudofs.h>
|
2001-10-01 04:31:05 +00:00
|
|
|
#include <fs/procfs/procfs.h>
|
2000-09-09 11:44:58 +00:00
|
|
|
|
2000-10-25 22:12:59 +00:00
|
|
|
/*
|
|
|
|
* Various conversion macros
|
|
|
|
*/
|
2001-05-09 11:41:54 +00:00
|
|
|
#define T2J(x) (((x) * 100UL) / (stathz ? stathz : hz)) /* ticks to jiffies */
|
2000-10-25 22:12:59 +00:00
|
|
|
#define T2S(x) ((x) / (stathz ? stathz : hz)) /* ticks to seconds */
|
|
|
|
#define B2K(x) ((x) >> 10) /* bytes to kbytes */
|
2000-12-09 13:25:54 +00:00
|
|
|
#define B2P(x) ((x) >> PAGE_SHIFT) /* bytes to pages */
|
2000-10-25 22:12:59 +00:00
|
|
|
#define P2B(x) ((x) << PAGE_SHIFT) /* pages to bytes */
|
|
|
|
#define P2K(x) ((x) << (PAGE_SHIFT - 10)) /* pages to kbytes */
|
2001-03-12 03:16:56 +00:00
|
|
|
|
2006-06-27 20:11:58 +00:00
|
|
|
/**
|
|
|
|
* @brief Mapping of ki_stat in struct kinfo_proc to the linux state
|
|
|
|
*
|
|
|
|
* The linux procfs state field displays one of the characters RSDZTW to
|
|
|
|
* denote running, sleeping in an interruptible wait, waiting in an
|
2007-10-12 06:03:46 +00:00
|
|
|
* uninterruptible disk sleep, a zombie process, process is being traced
|
2006-06-27 20:11:58 +00:00
|
|
|
* or stopped, or process is paging respectively.
|
|
|
|
*
|
|
|
|
* Our struct kinfo_proc contains the variable ki_stat which contains a
|
|
|
|
* value out of SIDL, SRUN, SSLEEP, SSTOP, SZOMB, SWAIT and SLOCK.
|
|
|
|
*
|
|
|
|
* This character array is used with ki_stati-1 as an index and tries to
|
|
|
|
* map our states to suitable linux states.
|
|
|
|
*/
|
2007-01-20 11:07:41 +00:00
|
|
|
static char linux_state[] = "RRSTZDD";
|
2006-06-27 20:11:58 +00:00
|
|
|
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/meminfo
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
static int
|
|
|
|
linprocfs_domeminfo(PFS_FILL_ARGS)
|
2000-04-20 03:54:27 +00:00
|
|
|
{
|
|
|
|
unsigned long memtotal; /* total memory in bytes */
|
|
|
|
unsigned long memused; /* used memory in bytes */
|
|
|
|
unsigned long memfree; /* free memory in bytes */
|
|
|
|
unsigned long memshared; /* shared memory ??? */
|
|
|
|
unsigned long buffers, cached; /* buffer / cache memory ??? */
|
2003-04-16 19:46:26 +00:00
|
|
|
unsigned long long swaptotal; /* total swap space in bytes */
|
|
|
|
unsigned long long swapused; /* used swap space in bytes */
|
|
|
|
unsigned long long swapfree; /* free swap space in bytes */
|
2000-05-24 07:37:02 +00:00
|
|
|
vm_object_t object;
|
2003-07-18 10:26:09 +00:00
|
|
|
int i, j;
|
2000-04-20 03:54:27 +00:00
|
|
|
|
|
|
|
memtotal = physmem * PAGE_SIZE;
|
|
|
|
/*
|
|
|
|
* The correct thing here would be:
|
|
|
|
*
|
2007-05-31 22:52:15 +00:00
|
|
|
memfree = cnt.v_free_count * PAGE_SIZE;
|
2000-04-20 03:54:27 +00:00
|
|
|
memused = memtotal - memfree;
|
|
|
|
*
|
|
|
|
* but it might mislead linux binaries into thinking there
|
|
|
|
* is very little memory left, so we cheat and tell them that
|
|
|
|
* all memory that isn't wired down is free.
|
|
|
|
*/
|
2007-05-31 22:52:15 +00:00
|
|
|
memused = cnt.v_wire_count * PAGE_SIZE;
|
2000-04-20 03:54:27 +00:00
|
|
|
memfree = memtotal - memused;
|
2003-07-18 10:26:09 +00:00
|
|
|
swap_pager_status(&i, &j);
|
2005-12-11 21:37:42 +00:00
|
|
|
swaptotal = (unsigned long long)i * PAGE_SIZE;
|
|
|
|
swapused = (unsigned long long)j * PAGE_SIZE;
|
2003-07-18 10:26:09 +00:00
|
|
|
swapfree = swaptotal - swapused;
|
2000-05-24 07:37:02 +00:00
|
|
|
memshared = 0;
|
2004-01-02 19:29:31 +00:00
|
|
|
mtx_lock(&vm_object_list_mtx);
|
2001-01-23 22:13:07 +00:00
|
|
|
TAILQ_FOREACH(object, &vm_object_list, object_list)
|
2000-05-24 07:37:02 +00:00
|
|
|
if (object->shadow_count > 1)
|
|
|
|
memshared += object->resident_page_count;
|
2004-01-02 19:29:31 +00:00
|
|
|
mtx_unlock(&vm_object_list_mtx);
|
2000-05-24 07:37:02 +00:00
|
|
|
memshared *= PAGE_SIZE;
|
2000-04-20 03:54:27 +00:00
|
|
|
/*
|
|
|
|
* We'd love to be able to write:
|
|
|
|
*
|
|
|
|
buffers = bufspace;
|
|
|
|
*
|
|
|
|
* but bufspace is internal to vfs_bio.c and we don't feel
|
|
|
|
* like unstaticizing it just for linprocfs's sake.
|
|
|
|
*/
|
|
|
|
buffers = 0;
|
2007-05-31 22:52:15 +00:00
|
|
|
cached = cnt.v_cache_count * PAGE_SIZE;
|
2000-04-20 03:54:27 +00:00
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb,
|
2001-06-11 00:17:59 +00:00
|
|
|
" total: used: free: shared: buffers: cached:\n"
|
2000-12-09 13:25:54 +00:00
|
|
|
"Mem: %lu %lu %lu %lu %lu %lu\n"
|
2001-05-19 05:54:26 +00:00
|
|
|
"Swap: %llu %llu %llu\n"
|
2000-12-09 13:25:54 +00:00
|
|
|
"MemTotal: %9lu kB\n"
|
|
|
|
"MemFree: %9lu kB\n"
|
|
|
|
"MemShared:%9lu kB\n"
|
|
|
|
"Buffers: %9lu kB\n"
|
|
|
|
"Cached: %9lu kB\n"
|
2001-05-19 05:54:26 +00:00
|
|
|
"SwapTotal:%9llu kB\n"
|
|
|
|
"SwapFree: %9llu kB\n",
|
2000-12-09 13:25:54 +00:00
|
|
|
memtotal, memused, memfree, memshared, buffers, cached,
|
|
|
|
swaptotal, swapused, swapfree,
|
|
|
|
B2K(memtotal), B2K(memfree),
|
|
|
|
B2K(memshared), B2K(buffers), B2K(cached),
|
|
|
|
B2K(swaptotal), B2K(swapfree));
|
2000-04-20 03:54:27 +00:00
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
return (0);
|
2000-04-20 03:54:27 +00:00
|
|
|
}
|
|
|
|
|
2004-08-16 08:19:18 +00:00
|
|
|
#if defined(__i386__) || defined(__amd64__)
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
2004-08-16 08:19:18 +00:00
|
|
|
* Filler function for proc/cpuinfo (i386 & amd64 version)
|
2001-06-11 21:55:40 +00:00
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
static int
|
|
|
|
linprocfs_docpuinfo(PFS_FILL_ARGS)
|
2000-04-20 03:54:27 +00:00
|
|
|
{
|
2006-06-12 18:14:49 +00:00
|
|
|
int hw_model[2];
|
|
|
|
char model[128];
|
|
|
|
size_t size;
|
2003-12-07 17:38:20 +00:00
|
|
|
int class, fqmhz, fqkhz;
|
2003-08-04 10:55:22 +00:00
|
|
|
int i;
|
|
|
|
|
2000-12-09 13:25:54 +00:00
|
|
|
/*
|
2001-06-11 00:17:59 +00:00
|
|
|
* We default the flags to include all non-conflicting flags,
|
|
|
|
* and the Intel versions of conflicting flags.
|
2000-12-09 13:25:54 +00:00
|
|
|
*/
|
2001-06-11 00:17:59 +00:00
|
|
|
static char *flags[] = {
|
|
|
|
"fpu", "vme", "de", "pse", "tsc",
|
|
|
|
"msr", "pae", "mce", "cx8", "apic",
|
|
|
|
"sep", "sep", "mtrr", "pge", "mca",
|
|
|
|
"cmov", "pat", "pse36", "pn", "b19",
|
|
|
|
"b20", "b21", "mmxext", "mmx", "fxsr",
|
2008-09-26 15:29:18 +00:00
|
|
|
"xmm", "sse2", "b27", "b28", "b29",
|
2000-10-25 22:38:23 +00:00
|
|
|
"3dnowext", "3dnow"
|
|
|
|
};
|
2000-04-20 03:54:27 +00:00
|
|
|
|
|
|
|
switch (cpu_class) {
|
2004-08-16 08:19:18 +00:00
|
|
|
#ifdef __i386__
|
2000-04-20 03:54:27 +00:00
|
|
|
case CPUCLASS_286:
|
2000-10-25 22:38:23 +00:00
|
|
|
class = 2;
|
2000-04-20 03:54:27 +00:00
|
|
|
break;
|
|
|
|
case CPUCLASS_386:
|
2000-10-25 22:38:23 +00:00
|
|
|
class = 3;
|
2000-04-20 03:54:27 +00:00
|
|
|
break;
|
|
|
|
case CPUCLASS_486:
|
2000-10-25 22:38:23 +00:00
|
|
|
class = 4;
|
2000-04-20 03:54:27 +00:00
|
|
|
break;
|
|
|
|
case CPUCLASS_586:
|
2000-10-25 22:38:23 +00:00
|
|
|
class = 5;
|
2000-04-20 03:54:27 +00:00
|
|
|
break;
|
|
|
|
case CPUCLASS_686:
|
2000-10-25 22:38:23 +00:00
|
|
|
class = 6;
|
2000-04-20 03:54:27 +00:00
|
|
|
break;
|
|
|
|
default:
|
2001-06-11 00:17:59 +00:00
|
|
|
class = 0;
|
2000-04-20 03:54:27 +00:00
|
|
|
break;
|
2006-06-02 13:01:25 +00:00
|
|
|
#else /* __amd64__ */
|
2004-08-16 08:19:18 +00:00
|
|
|
default:
|
2006-06-02 13:01:25 +00:00
|
|
|
class = 15;
|
2004-08-16 08:19:18 +00:00
|
|
|
break;
|
|
|
|
#endif
|
2000-04-20 03:54:27 +00:00
|
|
|
}
|
|
|
|
|
2006-06-12 18:14:49 +00:00
|
|
|
hw_model[0] = CTL_HW;
|
|
|
|
hw_model[1] = HW_MODEL;
|
|
|
|
model[0] = '\0';
|
|
|
|
size = sizeof(model);
|
|
|
|
if (kernel_sysctl(td, hw_model, 2, &model, &size, 0, 0, 0, 0) != 0)
|
|
|
|
strcpy(model, "unknown");
|
2003-12-07 17:38:20 +00:00
|
|
|
for (i = 0; i < mp_ncpus; ++i) {
|
2003-08-04 10:55:22 +00:00
|
|
|
sbuf_printf(sb,
|
|
|
|
"processor\t: %d\n"
|
|
|
|
"vendor_id\t: %.20s\n"
|
|
|
|
"cpu family\t: %d\n"
|
|
|
|
"model\t\t: %d\n"
|
2006-06-12 18:14:49 +00:00
|
|
|
"model name\t: %s\n"
|
2003-08-04 10:55:22 +00:00
|
|
|
"stepping\t: %d\n",
|
2006-06-12 18:14:49 +00:00
|
|
|
i, cpu_vendor, class, cpu, model, cpu_id & 0xf);
|
|
|
|
/* XXX per-cpu vendor / class / model / id? */
|
2003-08-04 10:55:22 +00:00
|
|
|
}
|
2000-10-25 22:38:23 +00:00
|
|
|
|
2008-12-08 13:15:31 +00:00
|
|
|
sbuf_cat(sb, "flags\t\t:");
|
2000-04-20 03:54:27 +00:00
|
|
|
|
2009-01-22 17:06:33 +00:00
|
|
|
#ifdef __i386__
|
|
|
|
switch (cpu_vendor_id) {
|
|
|
|
case CPU_VENDOR_AMD:
|
|
|
|
if (class < 6)
|
|
|
|
flags[16] = "fcmov";
|
|
|
|
break;
|
|
|
|
case CPU_VENDOR_CYRIX:
|
2000-10-25 22:38:23 +00:00
|
|
|
flags[24] = "cxmmx";
|
2009-01-22 17:06:33 +00:00
|
|
|
break;
|
2001-06-11 00:17:59 +00:00
|
|
|
}
|
2009-01-22 17:06:33 +00:00
|
|
|
#endif
|
2003-08-18 13:30:15 +00:00
|
|
|
|
2001-06-11 00:17:59 +00:00
|
|
|
for (i = 0; i < 32; i++)
|
2000-10-25 22:38:23 +00:00
|
|
|
if (cpu_feature & (1 << i))
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb, " %s", flags[i]);
|
|
|
|
sbuf_cat(sb, "\n");
|
2001-06-11 00:17:59 +00:00
|
|
|
if (class >= 5) {
|
2000-12-09 13:25:54 +00:00
|
|
|
fqmhz = (tsc_freq + 4999) / 1000000;
|
|
|
|
fqkhz = ((tsc_freq + 4999) / 10000) % 100;
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb,
|
2000-12-09 13:25:54 +00:00
|
|
|
"cpu MHz\t\t: %d.%02d\n"
|
|
|
|
"bogomips\t: %d.%02d\n",
|
|
|
|
fqmhz, fqkhz, fqmhz, fqkhz);
|
2001-06-11 00:17:59 +00:00
|
|
|
}
|
2000-12-13 20:22:24 +00:00
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
return (0);
|
2000-09-09 11:44:58 +00:00
|
|
|
}
|
2004-08-16 08:19:18 +00:00
|
|
|
#endif /* __i386__ || __amd64__ */
|
2000-09-09 11:44:58 +00:00
|
|
|
|
2001-10-21 15:56:46 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/mtab
|
|
|
|
*
|
|
|
|
* This file doesn't exist in Linux' procfs, but is included here so
|
|
|
|
* users can symlink /compat/linux/etc/mtab to /proc/mtab
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_domtab(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
struct nameidata nd;
|
|
|
|
struct mount *mp;
|
2002-02-26 23:38:34 +00:00
|
|
|
const char *lep;
|
|
|
|
char *dlep, *flep, *mntto, *mntfrom, *fstype;
|
2001-10-21 15:56:46 +00:00
|
|
|
size_t lep_len;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
/* resolve symlinks etc. in the emulation tree prefix */
|
2007-04-22 08:41:52 +00:00
|
|
|
NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, linux_emul_path, td);
|
2001-10-21 15:56:46 +00:00
|
|
|
flep = NULL;
|
2007-04-22 08:41:52 +00:00
|
|
|
error = namei(&nd);
|
2008-11-04 18:53:33 +00:00
|
|
|
lep = linux_emul_path;
|
|
|
|
if (error == 0) {
|
2009-02-13 15:32:03 +00:00
|
|
|
if (vn_fullpath(td, nd.ni_vp, &dlep, &flep) == 0)
|
2008-11-04 18:53:33 +00:00
|
|
|
lep = dlep;
|
|
|
|
vrele(nd.ni_vp);
|
|
|
|
VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
|
|
|
|
}
|
2001-10-21 15:56:46 +00:00
|
|
|
lep_len = strlen(lep);
|
2003-08-18 13:30:15 +00:00
|
|
|
|
2001-10-21 15:56:46 +00:00
|
|
|
mtx_lock(&mountlist_mtx);
|
|
|
|
error = 0;
|
|
|
|
TAILQ_FOREACH(mp, &mountlist, mnt_list) {
|
|
|
|
/* determine device name */
|
|
|
|
mntfrom = mp->mnt_stat.f_mntfromname;
|
2003-08-18 13:30:15 +00:00
|
|
|
|
2001-10-21 15:56:46 +00:00
|
|
|
/* determine mount point */
|
|
|
|
mntto = mp->mnt_stat.f_mntonname;
|
|
|
|
if (strncmp(mntto, lep, lep_len) == 0 &&
|
|
|
|
mntto[lep_len] == '/')
|
|
|
|
mntto += lep_len;
|
|
|
|
|
|
|
|
/* determine fs type */
|
|
|
|
fstype = mp->mnt_stat.f_fstypename;
|
|
|
|
if (strcmp(fstype, pn->pn_info->pi_name) == 0)
|
|
|
|
mntfrom = fstype = "proc";
|
|
|
|
else if (strcmp(fstype, "procfs") == 0)
|
|
|
|
continue;
|
2003-08-18 13:30:15 +00:00
|
|
|
|
2006-05-05 16:10:45 +00:00
|
|
|
if (strcmp(fstype, "linsysfs") == 0) {
|
|
|
|
sbuf_printf(sb, "/sys %s sysfs %s", mntto,
|
|
|
|
mp->mnt_stat.f_flags & MNT_RDONLY ? "ro" : "rw");
|
|
|
|
} else {
|
2009-03-26 17:14:22 +00:00
|
|
|
/* For Linux msdosfs is called vfat */
|
|
|
|
if (strcmp(fstype, "msdosfs") == 0)
|
|
|
|
fstype = "vfat";
|
2006-05-05 16:10:45 +00:00
|
|
|
sbuf_printf(sb, "%s %s %s %s", mntfrom, mntto, fstype,
|
|
|
|
mp->mnt_stat.f_flags & MNT_RDONLY ? "ro" : "rw");
|
|
|
|
}
|
2001-10-21 15:56:46 +00:00
|
|
|
#define ADD_OPTION(opt, name) \
|
|
|
|
if (mp->mnt_stat.f_flags & (opt)) sbuf_printf(sb, "," name);
|
|
|
|
ADD_OPTION(MNT_SYNCHRONOUS, "sync");
|
|
|
|
ADD_OPTION(MNT_NOEXEC, "noexec");
|
|
|
|
ADD_OPTION(MNT_NOSUID, "nosuid");
|
|
|
|
ADD_OPTION(MNT_UNION, "union");
|
|
|
|
ADD_OPTION(MNT_ASYNC, "async");
|
|
|
|
ADD_OPTION(MNT_SUIDDIR, "suiddir");
|
|
|
|
ADD_OPTION(MNT_NOSYMFOLLOW, "nosymfollow");
|
|
|
|
ADD_OPTION(MNT_NOATIME, "noatime");
|
|
|
|
#undef ADD_OPTION
|
|
|
|
/* a real Linux mtab will also show NFS options */
|
|
|
|
sbuf_printf(sb, " 0 0\n");
|
|
|
|
}
|
|
|
|
mtx_unlock(&mountlist_mtx);
|
|
|
|
if (flep != NULL)
|
|
|
|
free(flep, M_TEMP);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2009-03-26 17:14:22 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/partitions
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_dopartitions(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
struct g_class *cp;
|
|
|
|
struct g_geom *gp;
|
|
|
|
struct g_provider *pp;
|
|
|
|
struct nameidata nd;
|
|
|
|
const char *lep;
|
|
|
|
char *dlep, *flep;
|
|
|
|
size_t lep_len;
|
|
|
|
int error;
|
|
|
|
int major, minor;
|
|
|
|
|
|
|
|
/* resolve symlinks etc. in the emulation tree prefix */
|
|
|
|
NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, linux_emul_path, td);
|
|
|
|
flep = NULL;
|
|
|
|
error = namei(&nd);
|
|
|
|
lep = linux_emul_path;
|
|
|
|
if (error == 0) {
|
|
|
|
if (vn_fullpath(td, nd.ni_vp, &dlep, &flep) == 0)
|
|
|
|
lep = dlep;
|
|
|
|
vrele(nd.ni_vp);
|
|
|
|
VFS_UNLOCK_GIANT(NDHASGIANT(&nd));
|
|
|
|
}
|
|
|
|
lep_len = strlen(lep);
|
|
|
|
|
|
|
|
g_topology_lock();
|
|
|
|
error = 0;
|
|
|
|
sbuf_printf(sb, "major minor #blocks name rio rmerge rsect "
|
|
|
|
"ruse wio wmerge wsect wuse running use aveq\n");
|
|
|
|
|
|
|
|
LIST_FOREACH(cp, &g_classes, class) {
|
|
|
|
if (strcmp(cp->name, "DISK") == 0 ||
|
|
|
|
strcmp(cp->name, "PART") == 0)
|
|
|
|
LIST_FOREACH(gp, &cp->geom, geom) {
|
|
|
|
LIST_FOREACH(pp, &gp->provider, provider) {
|
|
|
|
if (linux_driver_get_major_minor(
|
|
|
|
pp->name, &major, &minor) != 0) {
|
|
|
|
major = 0;
|
|
|
|
minor = 0;
|
|
|
|
}
|
|
|
|
sbuf_printf(sb, "%d %d %lld %s "
|
|
|
|
"%d %d %d %d %d "
|
|
|
|
"%d %d %d %d %d %d\n",
|
|
|
|
major, minor,
|
|
|
|
(long long)pp->mediasize, pp->name,
|
|
|
|
0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_topology_unlock();
|
|
|
|
|
|
|
|
if (flep != NULL)
|
|
|
|
free(flep, M_TEMP);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/stat
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
static int
|
|
|
|
linprocfs_dostat(PFS_FILL_ARGS)
|
2000-09-09 11:44:58 +00:00
|
|
|
{
|
2007-11-29 06:34:30 +00:00
|
|
|
struct pcpu *pcpu;
|
|
|
|
long cp_time[CPUSTATES];
|
|
|
|
long *cp;
|
2003-12-07 17:38:20 +00:00
|
|
|
int i;
|
|
|
|
|
2007-11-29 06:34:30 +00:00
|
|
|
read_cpu_time(cp_time);
|
2003-09-22 15:52:32 +00:00
|
|
|
sbuf_printf(sb, "cpu %ld %ld %ld %ld\n",
|
|
|
|
T2J(cp_time[CP_USER]),
|
|
|
|
T2J(cp_time[CP_NICE]),
|
|
|
|
T2J(cp_time[CP_SYS] /*+ cp_time[CP_INTR]*/),
|
|
|
|
T2J(cp_time[CP_IDLE]));
|
2007-11-29 06:34:30 +00:00
|
|
|
for (i = 0; i <= mp_maxid; ++i) {
|
|
|
|
if (CPU_ABSENT(i))
|
|
|
|
continue;
|
|
|
|
pcpu = pcpu_find(i);
|
|
|
|
cp = pcpu->pc_cp_time;
|
2005-03-06 22:28:14 +00:00
|
|
|
sbuf_printf(sb, "cpu%d %ld %ld %ld %ld\n", i,
|
2007-11-29 06:34:30 +00:00
|
|
|
T2J(cp[CP_USER]),
|
|
|
|
T2J(cp[CP_NICE]),
|
|
|
|
T2J(cp[CP_SYS] /*+ cp[CP_INTR]*/),
|
|
|
|
T2J(cp[CP_IDLE]));
|
|
|
|
}
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb,
|
2000-12-09 13:25:54 +00:00
|
|
|
"disk 0 0 0 0\n"
|
|
|
|
"page %u %u\n"
|
|
|
|
"swap %u %u\n"
|
|
|
|
"intr %u\n"
|
|
|
|
"ctxt %u\n"
|
2001-10-29 02:17:41 +00:00
|
|
|
"btime %lld\n",
|
2007-05-31 22:52:15 +00:00
|
|
|
cnt.v_vnodepgsin,
|
|
|
|
cnt.v_vnodepgsout,
|
|
|
|
cnt.v_swappgsin,
|
|
|
|
cnt.v_swappgsout,
|
|
|
|
cnt.v_intr,
|
|
|
|
cnt.v_swtch,
|
2003-04-16 19:46:26 +00:00
|
|
|
(long long)boottime.tv_sec);
|
2001-06-10 23:23:59 +00:00
|
|
|
return (0);
|
2000-09-09 11:44:58 +00:00
|
|
|
}
|
|
|
|
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/uptime
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
static int
|
|
|
|
linprocfs_douptime(PFS_FILL_ARGS)
|
2000-09-09 11:44:58 +00:00
|
|
|
{
|
2007-11-29 06:34:30 +00:00
|
|
|
long cp_time[CPUSTATES];
|
2000-09-09 11:44:58 +00:00
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
getmicrouptime(&tv);
|
2007-11-29 06:34:30 +00:00
|
|
|
read_cpu_time(cp_time);
|
2001-10-29 02:17:41 +00:00
|
|
|
sbuf_printf(sb, "%lld.%02ld %ld.%02ld\n",
|
2003-04-16 19:46:26 +00:00
|
|
|
(long long)tv.tv_sec, tv.tv_usec / 10000,
|
2000-12-09 13:25:54 +00:00
|
|
|
T2S(cp_time[CP_IDLE]), T2J(cp_time[CP_IDLE]) % 100);
|
2001-06-10 23:23:59 +00:00
|
|
|
return (0);
|
2000-09-09 11:44:58 +00:00
|
|
|
}
|
|
|
|
|
2007-03-02 01:10:26 +00:00
|
|
|
/*
|
|
|
|
* Get OS build date
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
linprocfs_osbuild(struct thread *td, struct sbuf *sb)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
char osbuild[256];
|
|
|
|
char *cp1, *cp2;
|
|
|
|
|
|
|
|
strncpy(osbuild, version, 256);
|
|
|
|
osbuild[255] = '\0';
|
|
|
|
cp1 = strstr(osbuild, "\n");
|
|
|
|
cp2 = strstr(osbuild, ":");
|
|
|
|
if (cp1 && cp2) {
|
|
|
|
*cp1 = *cp2 = '\0';
|
|
|
|
cp1 = strstr(osbuild, "#");
|
|
|
|
} else
|
|
|
|
cp1 = NULL;
|
|
|
|
if (cp1)
|
|
|
|
sbuf_printf(sb, "%s%s", cp1, cp2 + 1);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
sbuf_cat(sb, "#4 Sun Dec 18 04:30:00 CET 1977");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get OS builder
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
linprocfs_osbuilder(struct thread *td, struct sbuf *sb)
|
|
|
|
{
|
2007-04-15 17:02:03 +00:00
|
|
|
#if 0
|
2007-03-02 01:10:26 +00:00
|
|
|
char builder[256];
|
|
|
|
char *cp;
|
|
|
|
|
|
|
|
cp = strstr(version, "\n ");
|
|
|
|
if (cp) {
|
|
|
|
strncpy(builder, cp + 5, 256);
|
|
|
|
builder[255] = '\0';
|
|
|
|
cp = strstr(builder, ":");
|
|
|
|
if (cp)
|
|
|
|
*cp = '\0';
|
|
|
|
}
|
|
|
|
if (cp)
|
|
|
|
sbuf_cat(sb, builder);
|
|
|
|
else
|
2007-04-15 17:02:03 +00:00
|
|
|
#endif
|
2007-03-02 01:10:26 +00:00
|
|
|
sbuf_cat(sb, "des@freebsd.org");
|
|
|
|
}
|
|
|
|
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/version
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
static int
|
|
|
|
linprocfs_doversion(PFS_FILL_ARGS)
|
2000-09-09 11:44:58 +00:00
|
|
|
{
|
o Introduce pr_mtx into struct prison, providing protection for the
mutable contents of struct prison (hostname, securelevel, refcount,
pr_linux, ...)
o Generally introduce mtx_lock()/mtx_unlock() calls throughout kern/
so as to enforce these protections, in particular, in kern_mib.c
protection sysctl access to the hostname and securelevel, as well as
kern_prot.c access to the securelevel for access control purposes.
o Rewrite linux emulator abstractions for accessing per-jail linux
mib entries (osname, osrelease, osversion) so that they don't return
a pointer to the text in the struct linux_prison, rather, a copy
to an array passed into the calls. Likewise, update linprocfs to
use these primitives.
o Update in_pcb.c to always use prison_getip() rather than directly
accessing struct prison.
Reviewed by: jhb
2001-12-03 16:12:27 +00:00
|
|
|
char osname[LINUX_MAX_UTSNAME];
|
|
|
|
char osrelease[LINUX_MAX_UTSNAME];
|
|
|
|
|
2003-03-13 22:45:43 +00:00
|
|
|
linux_get_osname(td, osname);
|
|
|
|
linux_get_osrelease(td, osrelease);
|
2007-03-02 01:10:26 +00:00
|
|
|
sbuf_printf(sb, "%s version %s (", osname, osrelease);
|
|
|
|
linprocfs_osbuilder(td, sb);
|
|
|
|
sbuf_cat(sb, ") (gcc version " __VERSION__ ") ");
|
|
|
|
linprocfs_osbuild(td, sb);
|
|
|
|
sbuf_cat(sb, "\n");
|
o Introduce pr_mtx into struct prison, providing protection for the
mutable contents of struct prison (hostname, securelevel, refcount,
pr_linux, ...)
o Generally introduce mtx_lock()/mtx_unlock() calls throughout kern/
so as to enforce these protections, in particular, in kern_mib.c
protection sysctl access to the hostname and securelevel, as well as
kern_prot.c access to the securelevel for access control purposes.
o Rewrite linux emulator abstractions for accessing per-jail linux
mib entries (osname, osrelease, osversion) so that they don't return
a pointer to the text in the struct linux_prison, rather, a copy
to an array passed into the calls. Likewise, update linprocfs to
use these primitives.
o Update in_pcb.c to always use prison_getip() rather than directly
accessing struct prison.
Reviewed by: jhb
2001-12-03 16:12:27 +00:00
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
return (0);
|
2000-04-20 03:54:27 +00:00
|
|
|
}
|
2000-09-09 11:44:58 +00:00
|
|
|
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/loadavg
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
static int
|
|
|
|
linprocfs_doloadavg(PFS_FILL_ARGS)
|
2001-05-19 05:54:26 +00:00
|
|
|
{
|
2007-04-15 17:02:03 +00:00
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb,
|
2001-05-19 05:54:26 +00:00
|
|
|
"%d.%02d %d.%02d %d.%02d %d/%d %d\n",
|
|
|
|
(int)(averunnable.ldavg[0] / averunnable.fscale),
|
|
|
|
(int)(averunnable.ldavg[0] * 100 / averunnable.fscale % 100),
|
|
|
|
(int)(averunnable.ldavg[1] / averunnable.fscale),
|
|
|
|
(int)(averunnable.ldavg[1] * 100 / averunnable.fscale % 100),
|
|
|
|
(int)(averunnable.ldavg[2] / averunnable.fscale),
|
|
|
|
(int)(averunnable.ldavg[2] * 100 / averunnable.fscale % 100),
|
|
|
|
1, /* number of running tasks */
|
|
|
|
nprocs, /* number of tasks */
|
2001-06-11 23:00:35 +00:00
|
|
|
lastpid /* the last pid */
|
2001-05-19 05:54:26 +00:00
|
|
|
);
|
2001-06-10 23:23:59 +00:00
|
|
|
return (0);
|
2001-05-19 05:54:26 +00:00
|
|
|
}
|
|
|
|
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/pid/stat
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
static int
|
|
|
|
linprocfs_doprocstat(PFS_FILL_ARGS)
|
2000-10-25 22:12:59 +00:00
|
|
|
{
|
2000-12-13 20:22:24 +00:00
|
|
|
struct kinfo_proc kp;
|
2007-01-20 11:07:41 +00:00
|
|
|
char state;
|
|
|
|
static int ratelimit = 0;
|
2000-12-13 20:22:24 +00:00
|
|
|
|
2002-04-09 20:10:46 +00:00
|
|
|
PROC_LOCK(p);
|
2000-12-13 20:22:24 +00:00
|
|
|
fill_kinfo_proc(p, &kp);
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb, "%d", p->p_pid);
|
|
|
|
#define PS_ADD(name, fmt, arg) sbuf_printf(sb, " " fmt, arg)
|
2000-10-25 22:12:59 +00:00
|
|
|
PS_ADD("comm", "(%s)", p->p_comm);
|
2007-01-20 11:07:41 +00:00
|
|
|
if (kp.ki_stat > sizeof(linux_state)) {
|
|
|
|
state = 'R';
|
|
|
|
|
2007-01-20 11:31:14 +00:00
|
|
|
if (ratelimit == 0) {
|
2007-01-21 13:18:52 +00:00
|
|
|
printf("linprocfs: don't know how to handle unknown FreeBSD state %d/%zd, mapping to R\n",
|
|
|
|
kp.ki_stat, sizeof(linux_state));
|
2007-01-20 11:31:14 +00:00
|
|
|
++ratelimit;
|
|
|
|
}
|
2007-01-20 11:07:41 +00:00
|
|
|
} else
|
|
|
|
state = linux_state[kp.ki_stat - 1];
|
|
|
|
PS_ADD("state", "%c", state);
|
2001-03-07 03:21:26 +00:00
|
|
|
PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0);
|
2000-10-25 22:12:59 +00:00
|
|
|
PS_ADD("pgrp", "%d", p->p_pgid);
|
|
|
|
PS_ADD("session", "%d", p->p_session->s_sid);
|
2002-02-23 11:12:57 +00:00
|
|
|
PROC_UNLOCK(p);
|
2000-10-25 22:12:59 +00:00
|
|
|
PS_ADD("tty", "%d", 0); /* XXX */
|
2006-06-27 20:11:58 +00:00
|
|
|
PS_ADD("tpgid", "%d", kp.ki_tpgid);
|
2000-10-25 22:12:59 +00:00
|
|
|
PS_ADD("flags", "%u", 0); /* XXX */
|
2006-06-27 20:11:58 +00:00
|
|
|
PS_ADD("minflt", "%lu", kp.ki_rusage.ru_minflt);
|
|
|
|
PS_ADD("cminflt", "%lu", kp.ki_rusage_ch.ru_minflt);
|
|
|
|
PS_ADD("majflt", "%lu", kp.ki_rusage.ru_majflt);
|
|
|
|
PS_ADD("cmajflt", "%lu", kp.ki_rusage_ch.ru_majflt);
|
|
|
|
PS_ADD("utime", "%ld", T2J(tvtohz(&kp.ki_rusage.ru_utime)));
|
|
|
|
PS_ADD("stime", "%ld", T2J(tvtohz(&kp.ki_rusage.ru_stime)));
|
|
|
|
PS_ADD("cutime", "%ld", T2J(tvtohz(&kp.ki_rusage_ch.ru_utime)));
|
|
|
|
PS_ADD("cstime", "%ld", T2J(tvtohz(&kp.ki_rusage_ch.ru_stime)));
|
|
|
|
PS_ADD("priority", "%d", kp.ki_pri.pri_user);
|
|
|
|
PS_ADD("nice", "%d", kp.ki_nice); /* 19 (nicest) to -19 */
|
|
|
|
PS_ADD("0", "%d", 0); /* removed field */
|
|
|
|
PS_ADD("itrealvalue", "%d", 0); /* XXX */
|
|
|
|
/* XXX: starttime is not right, it is the _same_ for _every_ process.
|
|
|
|
It should be the number of jiffies between system boot and process
|
|
|
|
start. */
|
|
|
|
PS_ADD("starttime", "%lu", T2J(tvtohz(&kp.ki_start)));
|
|
|
|
PS_ADD("vsize", "%ju", P2K((uintmax_t)kp.ki_size));
|
|
|
|
PS_ADD("rss", "%ju", (uintmax_t)kp.ki_rssize);
|
|
|
|
PS_ADD("rlim", "%lu", kp.ki_rusage.ru_maxrss);
|
2000-12-13 20:22:24 +00:00
|
|
|
PS_ADD("startcode", "%u", (unsigned)0);
|
2000-10-25 22:12:59 +00:00
|
|
|
PS_ADD("endcode", "%u", 0); /* XXX */
|
|
|
|
PS_ADD("startstack", "%u", 0); /* XXX */
|
2006-06-27 20:11:58 +00:00
|
|
|
PS_ADD("kstkesp", "%u", 0); /* XXX */
|
|
|
|
PS_ADD("kstkeip", "%u", 0); /* XXX */
|
|
|
|
PS_ADD("signal", "%u", 0); /* XXX */
|
|
|
|
PS_ADD("blocked", "%u", 0); /* XXX */
|
|
|
|
PS_ADD("sigignore", "%u", 0); /* XXX */
|
|
|
|
PS_ADD("sigcatch", "%u", 0); /* XXX */
|
2000-10-25 22:12:59 +00:00
|
|
|
PS_ADD("wchan", "%u", 0); /* XXX */
|
2006-06-27 20:11:58 +00:00
|
|
|
PS_ADD("nswap", "%lu", kp.ki_rusage.ru_nswap);
|
|
|
|
PS_ADD("cnswap", "%lu", kp.ki_rusage_ch.ru_nswap);
|
2000-12-09 13:25:54 +00:00
|
|
|
PS_ADD("exitsignal", "%d", 0); /* XXX */
|
2006-06-27 20:11:58 +00:00
|
|
|
PS_ADD("processor", "%u", kp.ki_lastcpu);
|
|
|
|
PS_ADD("rt_priority", "%u", 0); /* XXX */ /* >= 2.5.19 */
|
|
|
|
PS_ADD("policy", "%u", kp.ki_pri.pri_class); /* >= 2.5.19 */
|
2000-10-25 22:12:59 +00:00
|
|
|
#undef PS_ADD
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_putc(sb, '\n');
|
2003-08-18 13:30:15 +00:00
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
return (0);
|
2000-10-25 22:12:59 +00:00
|
|
|
}
|
|
|
|
|
2003-09-09 08:19:06 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/pid/statm
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_doprocstatm(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
struct kinfo_proc kp;
|
|
|
|
segsz_t lsize;
|
2003-09-22 16:05:11 +00:00
|
|
|
|
2003-09-09 08:19:06 +00:00
|
|
|
PROC_LOCK(p);
|
|
|
|
fill_kinfo_proc(p, &kp);
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See comments in linprocfs_doprocstatus() regarding the
|
|
|
|
* computation of lsize.
|
|
|
|
*/
|
|
|
|
/* size resident share trs drs lrs dt */
|
|
|
|
sbuf_printf(sb, "%ju ", B2P((uintmax_t)kp.ki_size));
|
|
|
|
sbuf_printf(sb, "%ju ", (uintmax_t)kp.ki_rssize);
|
|
|
|
sbuf_printf(sb, "%ju ", (uintmax_t)0); /* XXX */
|
|
|
|
sbuf_printf(sb, "%ju ", (uintmax_t)kp.ki_tsize);
|
|
|
|
sbuf_printf(sb, "%ju ", (uintmax_t)(kp.ki_dsize + kp.ki_ssize));
|
|
|
|
lsize = B2P(kp.ki_size) - kp.ki_dsize -
|
|
|
|
kp.ki_ssize - kp.ki_tsize - 1;
|
|
|
|
sbuf_printf(sb, "%ju ", (uintmax_t)lsize);
|
|
|
|
sbuf_printf(sb, "%ju\n", (uintmax_t)0); /* XXX */
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/pid/status
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
static int
|
|
|
|
linprocfs_doprocstatus(PFS_FILL_ARGS)
|
2000-10-25 22:12:59 +00:00
|
|
|
{
|
2000-12-13 20:22:24 +00:00
|
|
|
struct kinfo_proc kp;
|
2000-10-25 22:12:59 +00:00
|
|
|
char *state;
|
2000-12-09 13:25:54 +00:00
|
|
|
segsz_t lsize;
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
struct thread *td2;
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
struct sigacts *ps;
|
2001-03-12 03:16:56 +00:00
|
|
|
int i;
|
2000-10-25 22:12:59 +00:00
|
|
|
|
2003-04-17 21:58:45 +00:00
|
|
|
PROC_LOCK(p);
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
td2 = FIRST_THREAD_IN_PROC(p); /* XXXKSE pretend only one thread */
|
|
|
|
|
|
|
|
if (P_SHOULDSTOP(p)) {
|
|
|
|
state = "T (stopped)";
|
|
|
|
} else {
|
Commit 14/14 of sched_lock decomposition.
- Use thread_lock() rather than sched_lock for per-thread scheduling
sychronization.
- Use the per-process spinlock rather than the sched_lock for per-process
scheduling synchronization.
Tested by: kris, current@
Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc.
Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)
2007-06-05 00:00:57 +00:00
|
|
|
PROC_SLOCK(p);
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
switch(p->p_state) {
|
|
|
|
case PRS_NEW:
|
|
|
|
state = "I (idle)";
|
|
|
|
break;
|
|
|
|
case PRS_NORMAL:
|
|
|
|
if (p->p_flag & P_WEXIT) {
|
|
|
|
state = "X (exiting)";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch(td2->td_state) {
|
2002-09-11 08:13:56 +00:00
|
|
|
case TDS_INHIBITED:
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
state = "S (sleeping)";
|
|
|
|
break;
|
|
|
|
case TDS_RUNQ:
|
|
|
|
case TDS_RUNNING:
|
|
|
|
state = "R (running)";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
state = "? (unknown)";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PRS_ZOMBIE:
|
|
|
|
state = "Z (zombie)";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
state = "? (unknown)";
|
|
|
|
break;
|
|
|
|
}
|
Commit 14/14 of sched_lock decomposition.
- Use thread_lock() rather than sched_lock for per-thread scheduling
sychronization.
- Use the per-process spinlock rather than the sched_lock for per-process
scheduling synchronization.
Tested by: kris, current@
Tested on: i386, amd64, ULE, 4BSD, libthr, libkse, PREEMPTION, etc.
Discussed with: kris, attilio, kmacy, jhb, julian, bde (small parts each)
2007-06-05 00:00:57 +00:00
|
|
|
PROC_SUNLOCK(p);
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
}
|
2000-10-25 22:12:59 +00:00
|
|
|
|
2000-12-13 20:22:24 +00:00
|
|
|
fill_kinfo_proc(p, &kp);
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb, "Name:\t%s\n", p->p_comm); /* XXX escape */
|
2001-06-11 00:17:59 +00:00
|
|
|
sbuf_printf(sb, "State:\t%s\n", state);
|
2000-10-25 22:12:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Credentials
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb, "Pid:\t%d\n", p->p_pid);
|
|
|
|
sbuf_printf(sb, "PPid:\t%d\n", p->p_pptr ?
|
2001-03-07 03:21:26 +00:00
|
|
|
p->p_pptr->p_pid : 0);
|
2001-06-11 00:17:59 +00:00
|
|
|
sbuf_printf(sb, "Uid:\t%d %d %d %d\n", p->p_ucred->cr_ruid,
|
|
|
|
p->p_ucred->cr_uid,
|
|
|
|
p->p_ucred->cr_svuid,
|
|
|
|
/* FreeBSD doesn't have fsuid */
|
|
|
|
p->p_ucred->cr_uid);
|
|
|
|
sbuf_printf(sb, "Gid:\t%d %d %d %d\n", p->p_ucred->cr_rgid,
|
|
|
|
p->p_ucred->cr_gid,
|
|
|
|
p->p_ucred->cr_svgid,
|
|
|
|
/* FreeBSD doesn't have fsgid */
|
|
|
|
p->p_ucred->cr_gid);
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_cat(sb, "Groups:\t");
|
2000-10-25 22:12:59 +00:00
|
|
|
for (i = 0; i < p->p_ucred->cr_ngroups; i++)
|
2001-06-11 00:17:59 +00:00
|
|
|
sbuf_printf(sb, "%d ", p->p_ucred->cr_groups[i]);
|
2001-01-23 22:13:07 +00:00
|
|
|
PROC_UNLOCK(p);
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_putc(sb, '\n');
|
2003-08-18 13:30:15 +00:00
|
|
|
|
2000-10-25 22:12:59 +00:00
|
|
|
/*
|
|
|
|
* Memory
|
2000-12-09 13:25:54 +00:00
|
|
|
*
|
|
|
|
* While our approximation of VmLib may not be accurate (I
|
|
|
|
* don't know of a simple way to verify it, and I'm not sure
|
|
|
|
* it has much meaning anyway), I believe it's good enough.
|
|
|
|
*
|
|
|
|
* The same code that could (I think) accurately compute VmLib
|
|
|
|
* could also compute VmLck, but I don't really care enough to
|
|
|
|
* implement it. Submissions are welcome.
|
2000-10-25 22:12:59 +00:00
|
|
|
*/
|
2003-04-16 19:46:26 +00:00
|
|
|
sbuf_printf(sb, "VmSize:\t%8ju kB\n", B2K((uintmax_t)kp.ki_size));
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb, "VmLck:\t%8u kB\n", P2K(0)); /* XXX */
|
2003-04-16 19:46:26 +00:00
|
|
|
sbuf_printf(sb, "VmRss:\t%8ju kB\n", P2K((uintmax_t)kp.ki_rssize));
|
|
|
|
sbuf_printf(sb, "VmData:\t%8ju kB\n", P2K((uintmax_t)kp.ki_dsize));
|
|
|
|
sbuf_printf(sb, "VmStk:\t%8ju kB\n", P2K((uintmax_t)kp.ki_ssize));
|
|
|
|
sbuf_printf(sb, "VmExe:\t%8ju kB\n", P2K((uintmax_t)kp.ki_tsize));
|
2000-12-13 20:22:24 +00:00
|
|
|
lsize = B2P(kp.ki_size) - kp.ki_dsize -
|
|
|
|
kp.ki_ssize - kp.ki_tsize - 1;
|
2003-04-16 19:46:26 +00:00
|
|
|
sbuf_printf(sb, "VmLib:\t%8ju kB\n", P2K((uintmax_t)lsize));
|
2000-10-25 22:12:59 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Signal masks
|
|
|
|
*
|
|
|
|
* We support up to 128 signals, while Linux supports 32,
|
|
|
|
* but we only define 32 (the same 32 as Linux, to boot), so
|
|
|
|
* just show the lower 32 bits of each mask. XXX hack.
|
|
|
|
*
|
|
|
|
* NB: on certain platforms (Sparc at least) Linux actually
|
|
|
|
* supports 64 signals, but this code is a long way from
|
|
|
|
* running on anything but i386, so ignore that for now.
|
|
|
|
*/
|
2001-01-23 22:13:07 +00:00
|
|
|
PROC_LOCK(p);
|
2002-10-01 17:15:53 +00:00
|
|
|
sbuf_printf(sb, "SigPnd:\t%08x\n", p->p_siglist.__bits[0]);
|
2000-12-09 13:25:54 +00:00
|
|
|
/*
|
|
|
|
* I can't seem to find out where the signal mask is in
|
|
|
|
* relation to struct proc, so SigBlk is left unimplemented.
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb, "SigBlk:\t%08x\n", 0); /* XXX */
|
- Merge struct procsig with struct sigacts.
- Move struct sigacts out of the u-area and malloc() it using the
M_SUBPROC malloc bucket.
- Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(),
sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared().
- Remove the p_sigignore, p_sigacts, and p_sigcatch macros.
- Add a mutex to struct sigacts that protects all the members of the struct.
- Add sigacts locking.
- Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now
that sigacts is locked.
- Several in-kernel functions such as psignal(), tdsignal(), trapsignal(),
and thread_stopped() are now MP safe.
Reviewed by: arch@
Approved by: re (rwatson)
2003-05-13 20:36:02 +00:00
|
|
|
ps = p->p_sigacts;
|
|
|
|
mtx_lock(&ps->ps_mtx);
|
|
|
|
sbuf_printf(sb, "SigIgn:\t%08x\n", ps->ps_sigignore.__bits[0]);
|
|
|
|
sbuf_printf(sb, "SigCgt:\t%08x\n", ps->ps_sigcatch.__bits[0]);
|
|
|
|
mtx_unlock(&ps->ps_mtx);
|
2001-01-23 22:13:07 +00:00
|
|
|
PROC_UNLOCK(p);
|
2003-08-18 13:30:15 +00:00
|
|
|
|
2000-10-25 22:12:59 +00:00
|
|
|
/*
|
|
|
|
* Linux also prints the capability masks, but we don't have
|
|
|
|
* capabilities yet, and when we do get them they're likely to
|
|
|
|
* be meaningless to Linux programs, so we lie. XXX
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb, "CapInh:\t%016x\n", 0);
|
|
|
|
sbuf_printf(sb, "CapPrm:\t%016x\n", 0);
|
|
|
|
sbuf_printf(sb, "CapEff:\t%016x\n", 0);
|
2003-08-18 13:30:15 +00:00
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
return (0);
|
2001-03-12 03:16:56 +00:00
|
|
|
}
|
|
|
|
|
2003-09-09 08:19:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Filler function for proc/pid/cwd
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_doproccwd(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
char *fullpath = "unknown";
|
|
|
|
char *freepath = NULL;
|
|
|
|
|
|
|
|
vn_fullpath(td, p->p_fd->fd_cdir, &fullpath, &freepath);
|
|
|
|
sbuf_printf(sb, "%s", fullpath);
|
|
|
|
if (freepath)
|
|
|
|
free(freepath, M_TEMP);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Filler function for proc/pid/root
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_doprocroot(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
struct vnode *rvp;
|
|
|
|
char *fullpath = "unknown";
|
|
|
|
char *freepath = NULL;
|
|
|
|
|
|
|
|
rvp = jailed(p->p_ucred) ? p->p_fd->fd_jdir : p->p_fd->fd_rdir;
|
|
|
|
vn_fullpath(td, rvp, &fullpath, &freepath);
|
|
|
|
sbuf_printf(sb, "%s", fullpath);
|
|
|
|
if (freepath)
|
|
|
|
free(freepath, M_TEMP);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/pid/cmdline
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_doproccmdline(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
struct ps_strings pstr;
|
2004-12-01 21:33:02 +00:00
|
|
|
char **ps_argvstr;
|
2001-06-11 21:55:40 +00:00
|
|
|
int error, i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we are using the ps/cmdline caching, use that. Otherwise
|
|
|
|
* revert back to the old way which only implements full cmdline
|
|
|
|
* for the currept process and just p->p_comm for all other
|
|
|
|
* processes.
|
|
|
|
* Note that if the argv is no longer available, we deliberately
|
|
|
|
* don't fall back on p->p_comm or return an error: the authentic
|
|
|
|
* Linux behaviour is to return zero-length in this case.
|
|
|
|
*/
|
|
|
|
|
2002-04-13 23:09:41 +00:00
|
|
|
PROC_LOCK(p);
|
2004-04-01 00:04:23 +00:00
|
|
|
if (p->p_args && p_cansee(td, p) == 0) {
|
2002-04-13 23:09:41 +00:00
|
|
|
sbuf_bcpy(sb, p->p_args->ar_args, p->p_args->ar_length);
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
} else if (p != td->td_proc) {
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
sbuf_printf(sb, "%.*s", MAXCOMLEN, p->p_comm);
|
|
|
|
} else {
|
|
|
|
PROC_UNLOCK(p);
|
2002-09-21 22:07:17 +00:00
|
|
|
error = copyin((void *)p->p_sysent->sv_psstrings, &pstr,
|
|
|
|
sizeof(pstr));
|
2002-04-13 23:09:41 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
2004-12-01 21:33:02 +00:00
|
|
|
if (pstr.ps_nargvstr > ARG_MAX)
|
|
|
|
return (E2BIG);
|
|
|
|
ps_argvstr = malloc(pstr.ps_nargvstr * sizeof(char *),
|
|
|
|
M_TEMP, M_WAITOK);
|
|
|
|
error = copyin((void *)pstr.ps_argvstr, ps_argvstr,
|
|
|
|
pstr.ps_nargvstr * sizeof(char *));
|
|
|
|
if (error) {
|
|
|
|
free(ps_argvstr, M_TEMP);
|
|
|
|
return (error);
|
|
|
|
}
|
2002-04-13 23:09:41 +00:00
|
|
|
for (i = 0; i < pstr.ps_nargvstr; i++) {
|
2004-12-01 21:33:02 +00:00
|
|
|
sbuf_copyin(sb, ps_argvstr[i], 0);
|
2002-04-13 23:09:41 +00:00
|
|
|
sbuf_printf(sb, "%c", '\0');
|
2001-06-11 21:55:40 +00:00
|
|
|
}
|
2004-12-01 21:33:02 +00:00
|
|
|
free(ps_argvstr, M_TEMP);
|
2001-06-11 21:55:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2003-06-10 21:29:12 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/pid/environ
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_doprocenviron(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
|
2007-04-15 17:02:03 +00:00
|
|
|
sbuf_printf(sb, "doprocenviron\n%c", '\0');
|
2003-06-10 21:29:12 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Filler function for proc/pid/maps
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_doprocmaps(PFS_FILL_ARGS)
|
|
|
|
{
|
2008-12-12 12:12:36 +00:00
|
|
|
struct vmspace *vm;
|
|
|
|
vm_map_t map;
|
2008-12-08 12:34:52 +00:00
|
|
|
vm_map_entry_t entry, tmp_entry;
|
2003-10-20 04:10:20 +00:00
|
|
|
vm_object_t obj, tobj, lobj;
|
2008-12-08 12:34:52 +00:00
|
|
|
vm_offset_t e_start, e_end;
|
2003-10-20 04:10:20 +00:00
|
|
|
vm_ooffset_t off = 0;
|
2008-12-08 12:34:52 +00:00
|
|
|
vm_prot_t e_prot;
|
|
|
|
unsigned int last_timestamp;
|
2003-10-20 04:10:20 +00:00
|
|
|
char *name = "", *freename = NULL;
|
|
|
|
ino_t ino;
|
|
|
|
int ref_count, shadow_count, flags;
|
|
|
|
int error;
|
2004-11-10 07:25:37 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
struct vattr vat;
|
2006-08-08 12:29:26 +00:00
|
|
|
int locked;
|
2007-04-15 17:02:03 +00:00
|
|
|
|
2003-10-19 14:13:51 +00:00
|
|
|
PROC_LOCK(p);
|
|
|
|
error = p_candebug(td, p);
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2007-04-15 17:02:03 +00:00
|
|
|
|
2003-10-19 14:13:51 +00:00
|
|
|
if (uio->uio_rw != UIO_READ)
|
|
|
|
return (EOPNOTSUPP);
|
2007-04-15 17:02:03 +00:00
|
|
|
|
2003-10-19 14:13:51 +00:00
|
|
|
error = 0;
|
2008-12-12 12:12:36 +00:00
|
|
|
vm = vmspace_acquire_ref(p);
|
|
|
|
if (vm == NULL)
|
|
|
|
return (ESRCH);
|
|
|
|
map = &vm->vm_map;
|
2007-05-01 03:09:57 +00:00
|
|
|
vm_map_lock_read(map);
|
2008-10-04 14:08:16 +00:00
|
|
|
for (entry = map->header.next; entry != &map->header;
|
2003-10-19 14:13:51 +00:00
|
|
|
entry = entry->next) {
|
2003-10-20 04:10:20 +00:00
|
|
|
name = "";
|
|
|
|
freename = NULL;
|
2003-10-19 14:13:51 +00:00
|
|
|
if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
|
|
|
|
continue;
|
2008-12-08 12:34:52 +00:00
|
|
|
e_prot = entry->protection;
|
|
|
|
e_start = entry->start;
|
|
|
|
e_end = entry->end;
|
2003-10-19 14:13:51 +00:00
|
|
|
obj = entry->object.vm_object;
|
2007-05-01 03:09:57 +00:00
|
|
|
for (lobj = tobj = obj; tobj; tobj = tobj->backing_object) {
|
|
|
|
VM_OBJECT_LOCK(tobj);
|
|
|
|
if (lobj != obj)
|
|
|
|
VM_OBJECT_UNLOCK(lobj);
|
2003-10-19 14:13:51 +00:00
|
|
|
lobj = tobj;
|
2007-05-01 03:09:57 +00:00
|
|
|
}
|
2008-12-08 12:34:52 +00:00
|
|
|
last_timestamp = map->timestamp;
|
|
|
|
vm_map_unlock_read(map);
|
2003-10-19 14:13:51 +00:00
|
|
|
ino = 0;
|
|
|
|
if (lobj) {
|
|
|
|
off = IDX_TO_OFF(lobj->size);
|
2006-08-08 12:29:26 +00:00
|
|
|
if (lobj->type == OBJT_VNODE) {
|
|
|
|
vp = lobj->handle;
|
|
|
|
if (vp)
|
|
|
|
vref(vp);
|
2003-10-19 14:13:51 +00:00
|
|
|
}
|
2006-08-08 12:29:26 +00:00
|
|
|
else
|
|
|
|
vp = NULL;
|
2007-05-01 03:09:57 +00:00
|
|
|
if (lobj != obj)
|
|
|
|
VM_OBJECT_UNLOCK(lobj);
|
2003-10-19 14:13:51 +00:00
|
|
|
flags = obj->flags;
|
|
|
|
ref_count = obj->ref_count;
|
|
|
|
shadow_count = obj->shadow_count;
|
2007-05-01 03:09:57 +00:00
|
|
|
VM_OBJECT_UNLOCK(obj);
|
2006-08-08 12:29:26 +00:00
|
|
|
if (vp) {
|
|
|
|
vn_fullpath(td, vp, &name, &freename);
|
|
|
|
locked = VFS_LOCK_GIANT(vp->v_mount);
|
2008-01-10 01:10:58 +00:00
|
|
|
vn_lock(vp, LK_SHARED | LK_RETRY);
|
2008-08-28 15:23:18 +00:00
|
|
|
VOP_GETATTR(vp, &vat, td->td_ucred);
|
2006-08-08 12:29:26 +00:00
|
|
|
ino = vat.va_fileid;
|
|
|
|
vput(vp);
|
|
|
|
VFS_UNLOCK_GIANT(locked);
|
|
|
|
}
|
2003-10-19 14:13:51 +00:00
|
|
|
} else {
|
|
|
|
flags = 0;
|
|
|
|
ref_count = 0;
|
|
|
|
shadow_count = 0;
|
|
|
|
}
|
2007-04-15 17:02:03 +00:00
|
|
|
|
2003-10-19 14:13:51 +00:00
|
|
|
/*
|
2007-04-15 17:02:03 +00:00
|
|
|
* format:
|
2003-10-19 14:13:51 +00:00
|
|
|
* start, end, access, offset, major, minor, inode, name.
|
|
|
|
*/
|
2008-10-04 14:08:16 +00:00
|
|
|
error = sbuf_printf(sb,
|
2003-10-19 14:13:51 +00:00
|
|
|
"%08lx-%08lx %s%s%s%s %08lx %02x:%02x %lu%s%s\n",
|
2008-12-08 12:34:52 +00:00
|
|
|
(u_long)e_start, (u_long)e_end,
|
|
|
|
(e_prot & VM_PROT_READ)?"r":"-",
|
|
|
|
(e_prot & VM_PROT_WRITE)?"w":"-",
|
|
|
|
(e_prot & VM_PROT_EXECUTE)?"x":"-",
|
2003-10-19 14:13:51 +00:00
|
|
|
"p",
|
2003-10-20 04:10:20 +00:00
|
|
|
(u_long)off,
|
2003-10-19 14:13:51 +00:00
|
|
|
0,
|
|
|
|
0,
|
2003-10-20 04:10:20 +00:00
|
|
|
(u_long)ino,
|
2003-10-19 14:13:51 +00:00
|
|
|
*name ? " " : "",
|
|
|
|
name
|
|
|
|
);
|
|
|
|
if (freename)
|
|
|
|
free(freename, M_TEMP);
|
2008-12-10 16:11:09 +00:00
|
|
|
vm_map_lock_read(map);
|
2008-10-04 14:08:16 +00:00
|
|
|
if (error == -1) {
|
|
|
|
error = 0;
|
2003-10-19 14:13:51 +00:00
|
|
|
break;
|
2007-05-01 03:09:57 +00:00
|
|
|
}
|
2008-12-29 12:45:11 +00:00
|
|
|
if (last_timestamp != map->timestamp) {
|
2008-12-08 12:34:52 +00:00
|
|
|
/*
|
|
|
|
* Look again for the entry because the map was
|
|
|
|
* modified while it was unlocked. Specifically,
|
|
|
|
* the entry may have been clipped, merged, or deleted.
|
|
|
|
*/
|
|
|
|
vm_map_lookup_entry(map, e_end - 1, &tmp_entry);
|
|
|
|
entry = tmp_entry;
|
|
|
|
}
|
2003-10-19 14:13:51 +00:00
|
|
|
}
|
2007-05-01 03:09:57 +00:00
|
|
|
vm_map_unlock_read(map);
|
2008-12-12 12:12:36 +00:00
|
|
|
vmspace_free(vm);
|
2007-04-15 17:02:03 +00:00
|
|
|
|
2003-10-19 14:13:51 +00:00
|
|
|
return (error);
|
2007-04-15 17:02:03 +00:00
|
|
|
}
|
|
|
|
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/net/dev
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
static int
|
|
|
|
linprocfs_donetdev(PFS_FILL_ARGS)
|
2001-03-12 03:16:56 +00:00
|
|
|
{
|
2001-10-19 01:45:03 +00:00
|
|
|
char ifname[16]; /* XXX LINUX_IFNAMSIZ */
|
2001-03-12 03:16:56 +00:00
|
|
|
struct ifnet *ifp;
|
|
|
|
|
2001-10-19 01:45:03 +00:00
|
|
|
sbuf_printf(sb, "%6s|%58s|%s\n%6s|%58s|%58s\n",
|
2001-09-25 13:24:24 +00:00
|
|
|
"Inter-", " Receive", " Transmit", " face",
|
2001-10-19 01:45:03 +00:00
|
|
|
"bytes packets errs drop fifo frame compressed",
|
2001-09-25 13:24:24 +00:00
|
|
|
"bytes packets errs drop fifo frame compressed");
|
2001-03-12 03:16:56 +00:00
|
|
|
|
2009-08-28 22:51:07 +00:00
|
|
|
CURVNET_SET(TD_TO_VNET(curthread));
|
2002-12-22 05:35:03 +00:00
|
|
|
IFNET_RLOCK();
|
Commit step 1 of the vimage project, (network stack)
virtualization work done by Marko Zec (zec@).
This is the first in a series of commits over the course
of the next few weeks.
Mark all uses of global variables to be virtualized
with a V_ prefix.
Use macros to map them back to their global names for
now, so this is a NOP change only.
We hope to have caught at least 85-90% of what is needed
so we do not invalidate a lot of outstanding patches again.
Obtained from: //depot/projects/vimage-commit2/...
Reviewed by: brooks, des, ed, mav, julian,
jamie, kris, rwatson, zec, ...
(various people I forgot, different versions)
md5 (with a bit of help)
Sponsored by: NLnet Foundation, The FreeBSD Foundation
X-MFC after: never
V_Commit_Message_Reviewed_By: more people than the patch
2008-08-17 23:27:27 +00:00
|
|
|
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
|
2001-10-19 01:45:03 +00:00
|
|
|
linux_ifname(ifp, ifname, sizeof ifname);
|
|
|
|
sbuf_printf(sb, "%6.6s:", ifname);
|
2001-09-25 13:24:24 +00:00
|
|
|
sbuf_printf(sb, "%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu ",
|
|
|
|
0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL);
|
|
|
|
sbuf_printf(sb, "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
|
|
|
|
0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL);
|
2001-03-12 03:16:56 +00:00
|
|
|
}
|
2002-12-22 05:35:03 +00:00
|
|
|
IFNET_RUNLOCK();
|
2009-08-28 22:51:07 +00:00
|
|
|
CURVNET_RESTORE();
|
2003-08-18 13:30:15 +00:00
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
return (0);
|
2001-03-12 03:16:56 +00:00
|
|
|
}
|
|
|
|
|
2007-03-02 01:10:26 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/sys/kernel/osrelease
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_doosrelease(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
char osrelease[LINUX_MAX_UTSNAME];
|
|
|
|
|
|
|
|
linux_get_osrelease(td, osrelease);
|
|
|
|
sbuf_printf(sb, "%s\n", osrelease);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Filler function for proc/sys/kernel/ostype
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_doostype(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
char osname[LINUX_MAX_UTSNAME];
|
|
|
|
|
|
|
|
linux_get_osname(td, osname);
|
|
|
|
sbuf_printf(sb, "%s\n", osname);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Filler function for proc/sys/kernel/version
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_doosbuild(PFS_FILL_ARGS)
|
|
|
|
{
|
2007-04-15 17:02:03 +00:00
|
|
|
|
2007-03-02 01:10:26 +00:00
|
|
|
linprocfs_osbuild(td, sb);
|
|
|
|
sbuf_cat(sb, "\n");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2006-11-27 21:10:55 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/sys/kernel/msgmni
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_domsgmni(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
|
2007-03-30 17:56:44 +00:00
|
|
|
sbuf_printf(sb, "%d\n", msginfo.msgmni);
|
2006-11-27 21:10:55 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2006-10-08 16:55:27 +00:00
|
|
|
/*
|
2006-10-11 20:32:46 +00:00
|
|
|
* Filler function for proc/sys/kernel/pid_max
|
2006-10-08 16:55:27 +00:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_dopid_max(PFS_FILL_ARGS)
|
|
|
|
{
|
2006-10-29 09:50:55 +00:00
|
|
|
|
2006-10-08 16:55:27 +00:00
|
|
|
sbuf_printf(sb, "%i\n", PID_MAX);
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2006-11-27 21:10:55 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/sys/kernel/sem
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_dosem(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
|
2007-03-30 17:56:44 +00:00
|
|
|
sbuf_printf(sb, "%d %d %d %d\n", seminfo.semmsl, seminfo.semmns,
|
|
|
|
seminfo.semopm, seminfo.semmni);
|
2006-11-27 21:10:55 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2006-05-05 16:10:45 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/scsi/device_info
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_doscsidevinfo(PFS_FILL_ARGS)
|
|
|
|
{
|
2007-04-15 17:02:03 +00:00
|
|
|
|
2006-05-05 16:10:45 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Filler function for proc/scsi/scsi
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_doscsiscsi(PFS_FILL_ARGS)
|
|
|
|
{
|
2007-04-15 17:02:03 +00:00
|
|
|
|
2006-05-05 16:10:45 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-10-26 15:30:44 +00:00
|
|
|
extern struct cdevsw *cdevsw[];
|
|
|
|
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/devices
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
static int
|
|
|
|
linprocfs_dodevices(PFS_FILL_ARGS)
|
2001-03-12 03:16:56 +00:00
|
|
|
{
|
2006-05-05 16:10:45 +00:00
|
|
|
char *char_devices;
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb, "Character devices:\n");
|
2001-03-12 03:16:56 +00:00
|
|
|
|
2006-05-05 16:10:45 +00:00
|
|
|
char_devices = linux_get_char_devices();
|
|
|
|
sbuf_printf(sb, "%s", char_devices);
|
|
|
|
linux_free_get_char_devices(char_devices);
|
2001-03-12 03:16:56 +00:00
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb, "\nBlock devices:\n");
|
2003-08-18 13:30:15 +00:00
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
return (0);
|
2001-03-12 03:16:56 +00:00
|
|
|
}
|
|
|
|
|
2001-06-11 21:55:40 +00:00
|
|
|
/*
|
|
|
|
* Filler function for proc/cmdline
|
|
|
|
*/
|
2001-06-10 23:23:59 +00:00
|
|
|
static int
|
|
|
|
linprocfs_docmdline(PFS_FILL_ARGS)
|
2001-03-12 03:16:56 +00:00
|
|
|
{
|
2007-04-15 17:02:03 +00:00
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
sbuf_printf(sb, "BOOT_IMAGE=%s", kernelname);
|
|
|
|
sbuf_printf(sb, " ro root=302\n");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2001-09-25 13:24:24 +00:00
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
* Filler function for proc/modules
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_domodules(PFS_FILL_ARGS)
|
|
|
|
{
|
|
|
|
struct linker_file *lf;
|
2003-08-18 13:30:15 +00:00
|
|
|
|
2001-09-25 13:24:24 +00:00
|
|
|
TAILQ_FOREACH(lf, &linker_files, link) {
|
|
|
|
sbuf_printf(sb, "%-20s%8lu%4d\n", lf->filename,
|
|
|
|
(unsigned long)lf->size, lf->refs);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-06-10 23:23:59 +00:00
|
|
|
/*
|
2001-10-19 01:45:03 +00:00
|
|
|
* Constructor
|
2001-06-10 23:23:59 +00:00
|
|
|
*/
|
2001-10-19 01:45:03 +00:00
|
|
|
static int
|
|
|
|
linprocfs_init(PFS_INIT_ARGS)
|
|
|
|
{
|
|
|
|
struct pfs_node *root;
|
|
|
|
struct pfs_node *dir;
|
|
|
|
|
|
|
|
root = pi->pi_root;
|
|
|
|
|
2003-09-09 19:22:55 +00:00
|
|
|
/* /proc/... */
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_file(root, "cmdline", &linprocfs_docmdline,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_file(root, "cpuinfo", &linprocfs_docpuinfo,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_file(root, "devices", &linprocfs_dodevices,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_file(root, "loadavg", &linprocfs_doloadavg,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_file(root, "meminfo", &linprocfs_domeminfo,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-09-25 13:24:24 +00:00
|
|
|
#if 0
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_file(root, "modules", &linprocfs_domodules,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-09-25 13:24:24 +00:00
|
|
|
#endif
|
2006-05-05 16:10:45 +00:00
|
|
|
pfs_create_file(root, "mounts", &linprocfs_domtab,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_file(root, "mtab", &linprocfs_domtab,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2009-03-26 17:14:22 +00:00
|
|
|
pfs_create_file(root, "partitions", &linprocfs_dopartitions,
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-12-09 00:38:59 +00:00
|
|
|
pfs_create_link(root, "self", &procfs_docurproc,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, 0);
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_file(root, "stat", &linprocfs_dostat,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_file(root, "uptime", &linprocfs_douptime,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_file(root, "version", &linprocfs_doversion,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-10-19 01:45:03 +00:00
|
|
|
|
2003-09-09 19:22:55 +00:00
|
|
|
/* /proc/net/... */
|
2007-03-12 12:16:52 +00:00
|
|
|
dir = pfs_create_dir(root, "net", NULL, NULL, NULL, 0);
|
2001-10-19 01:45:03 +00:00
|
|
|
pfs_create_file(dir, "dev", &linprocfs_donetdev,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-10-19 01:45:03 +00:00
|
|
|
|
2003-09-09 19:22:55 +00:00
|
|
|
/* /proc/<pid>/... */
|
2007-03-12 12:16:52 +00:00
|
|
|
dir = pfs_create_dir(root, "pid", NULL, NULL, NULL, PFS_PROCDEP);
|
2001-10-19 01:45:03 +00:00
|
|
|
pfs_create_file(dir, "cmdline", &linprocfs_doproccmdline,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_link(dir, "cwd", &linprocfs_doproccwd,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, 0);
|
2003-06-10 21:29:12 +00:00
|
|
|
pfs_create_file(dir, "environ", &linprocfs_doprocenviron,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-12-09 00:38:59 +00:00
|
|
|
pfs_create_link(dir, "exe", &procfs_doprocfile,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, &procfs_notsystem, NULL, 0);
|
2003-06-10 21:29:12 +00:00
|
|
|
pfs_create_file(dir, "maps", &linprocfs_doprocmaps,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-10-19 01:45:03 +00:00
|
|
|
pfs_create_file(dir, "mem", &procfs_doprocmem,
|
2007-03-12 12:16:52 +00:00
|
|
|
&procfs_attr, &procfs_candebug, NULL, PFS_RDWR|PFS_RAW);
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_link(dir, "root", &linprocfs_doprocroot,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, 0);
|
2001-10-19 01:45:03 +00:00
|
|
|
pfs_create_file(dir, "stat", &linprocfs_doprocstat,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 08:19:06 +00:00
|
|
|
pfs_create_file(dir, "statm", &linprocfs_doprocstatm,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-10-19 01:45:03 +00:00
|
|
|
pfs_create_file(dir, "status", &linprocfs_doprocstatus,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-06-10 23:23:59 +00:00
|
|
|
|
2006-05-05 16:10:45 +00:00
|
|
|
/* /proc/scsi/... */
|
2007-03-12 12:16:52 +00:00
|
|
|
dir = pfs_create_dir(root, "scsi", NULL, NULL, NULL, 0);
|
2006-05-05 16:10:45 +00:00
|
|
|
pfs_create_file(dir, "device_info", &linprocfs_doscsidevinfo,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-05-05 16:10:45 +00:00
|
|
|
pfs_create_file(dir, "scsi", &linprocfs_doscsiscsi,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-10-08 16:55:27 +00:00
|
|
|
|
|
|
|
/* /proc/sys/... */
|
2007-03-12 12:16:52 +00:00
|
|
|
dir = pfs_create_dir(root, "sys", NULL, NULL, NULL, 0);
|
2006-10-08 16:55:27 +00:00
|
|
|
/* /proc/sys/kernel/... */
|
2007-03-12 12:16:52 +00:00
|
|
|
dir = pfs_create_dir(dir, "kernel", NULL, NULL, NULL, 0);
|
2007-03-02 01:10:26 +00:00
|
|
|
pfs_create_file(dir, "osrelease", &linprocfs_doosrelease,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2007-03-02 01:10:26 +00:00
|
|
|
pfs_create_file(dir, "ostype", &linprocfs_doostype,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2007-03-02 01:10:26 +00:00
|
|
|
pfs_create_file(dir, "version", &linprocfs_doosbuild,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-11-27 21:10:55 +00:00
|
|
|
pfs_create_file(dir, "msgmni", &linprocfs_domsgmni,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-10-08 16:55:27 +00:00
|
|
|
pfs_create_file(dir, "pid_max", &linprocfs_dopid_max,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-11-27 21:10:55 +00:00
|
|
|
pfs_create_file(dir, "sem", &linprocfs_dosem,
|
2007-03-12 12:16:52 +00:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-10-08 16:55:27 +00:00
|
|
|
|
2001-10-19 01:45:03 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Destructor
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
linprocfs_uninit(PFS_INIT_ARGS)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* nothing to do, pseudofs will GC */
|
|
|
|
return (0);
|
|
|
|
}
|
2001-06-10 23:23:59 +00:00
|
|
|
|
2001-10-19 01:45:03 +00:00
|
|
|
PSEUDOFS(linprocfs, 1);
|
2001-06-10 23:23:59 +00:00
|
|
|
MODULE_DEPEND(linprocfs, linux, 1, 1, 1);
|
|
|
|
MODULE_DEPEND(linprocfs, procfs, 1, 1, 1);
|
2007-04-06 18:15:56 +00:00
|
|
|
MODULE_DEPEND(linprocfs, sysvmsg, 1, 1, 1);
|
|
|
|
MODULE_DEPEND(linprocfs, sysvsem, 1, 1, 1);
|