2005-01-05 17:34:37 -05:00
|
|
|
/*-
|
2017-11-18 09:26:50 -05:00
|
|
|
* SPDX-License-Identifier: BSD-4-Clause
|
|
|
|
|
*
|
2008-11-05 10:08:09 -05:00
|
|
|
* Copyright (c) 2000 Dag-Erling Coïdan Smørgrav
|
2000-09-07 12:44:26 -04:00
|
|
|
* Copyright (c) 1999 Pierre Beyssac
|
2000-04-19 23:54:27 -04: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
|
|
|
|
|
*/
|
|
|
|
|
|
2003-06-10 17:29:12 -04:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
2000-04-19 23:54:27 -04:00
|
|
|
#include <sys/param.h>
|
2001-09-25 09:24:24 -04:00
|
|
|
#include <sys/queue.h>
|
2000-04-19 23:54:27 -04:00
|
|
|
#include <sys/blist.h>
|
2001-05-01 04:13:21 -04:00
|
|
|
#include <sys/conf.h>
|
2001-09-25 09:24:24 -04:00
|
|
|
#include <sys/exec.h>
|
2008-03-31 08:01:21 -04:00
|
|
|
#include <sys/fcntl.h>
|
2003-09-09 04:19:06 -04:00
|
|
|
#include <sys/filedesc.h>
|
2001-05-01 04:13:21 -04:00
|
|
|
#include <sys/jail.h>
|
2000-09-09 07:44:58 -04:00
|
|
|
#include <sys/kernel.h>
|
2015-04-15 05:13:11 -04:00
|
|
|
#include <sys/limits.h>
|
2001-09-25 09:24:24 -04:00
|
|
|
#include <sys/linker.h>
|
2001-05-01 04:13:21 -04:00
|
|
|
#include <sys/lock.h>
|
2001-03-11 22:16:56 -05:00
|
|
|
#include <sys/malloc.h>
|
2007-03-30 13:56:44 -04:00
|
|
|
#include <sys/msg.h>
|
2001-05-18 21:28:09 -04:00
|
|
|
#include <sys/mutex.h>
|
2001-10-21 11:56:46 -04:00
|
|
|
#include <sys/namei.h>
|
2000-09-09 07:44:58 -04:00
|
|
|
#include <sys/proc.h>
|
2010-09-28 07:32:17 -04:00
|
|
|
#include <sys/ptrace.h>
|
2000-04-19 23:54:27 -04:00
|
|
|
#include <sys/resourcevar.h>
|
2016-02-21 09:56:05 -05:00
|
|
|
#include <sys/resource.h>
|
2000-12-13 15:22:24 -05:00
|
|
|
#include <sys/sbuf.h>
|
2007-03-30 13:56:44 -04:00
|
|
|
#include <sys/sem.h>
|
2020-07-18 06:56:04 -04:00
|
|
|
#include <sys/shm.h>
|
2003-12-07 12:38:20 -05:00
|
|
|
#include <sys/smp.h>
|
2001-09-25 09:24:24 -04:00
|
|
|
#include <sys/socket.h>
|
2015-04-15 05:13:11 -04:00
|
|
|
#include <sys/syscallsubr.h>
|
2001-05-19 01:54:26 -04:00
|
|
|
#include <sys/sysctl.h>
|
2015-05-24 11:51:18 -04:00
|
|
|
#include <sys/sysent.h>
|
2001-09-25 09:24:24 -04:00
|
|
|
#include <sys/systm.h>
|
2006-06-27 16:11:58 -04:00
|
|
|
#include <sys/time.h>
|
2000-09-09 07:44:58 -04:00
|
|
|
#include <sys/tty.h>
|
2001-09-25 09:24:24 -04:00
|
|
|
#include <sys/user.h>
|
2014-02-26 19:43:10 -05:00
|
|
|
#include <sys/uuid.h>
|
2001-09-25 09:24:24 -04:00
|
|
|
#include <sys/vmmeter.h>
|
2000-09-09 07:44:58 -04:00
|
|
|
#include <sys/vnode.h>
|
2009-03-26 13:14:22 -04:00
|
|
|
#include <sys/bus.h>
|
2000-04-19 23:54:27 -04:00
|
|
|
|
2001-09-25 09:24:24 -04:00
|
|
|
#include <net/if.h>
|
2013-10-26 13:58:36 -04:00
|
|
|
#include <net/if_var.h>
|
2015-05-24 11:51:18 -04:00
|
|
|
#include <net/if_types.h>
|
2001-09-25 09:24:24 -04:00
|
|
|
|
2000-04-19 23:54:27 -04:00
|
|
|
#include <vm/vm.h>
|
2008-12-12 07:12:36 -05:00
|
|
|
#include <vm/vm_extern.h>
|
2000-04-19 23:54:27 -04:00
|
|
|
#include <vm/pmap.h>
|
2000-10-25 18:12:59 -04:00
|
|
|
#include <vm/vm_map.h>
|
2000-04-19 23:54:27 -04:00
|
|
|
#include <vm/vm_param.h>
|
2000-05-24 03:37:02 -04:00
|
|
|
#include <vm/vm_object.h>
|
2000-04-19 23:54:27 -04:00
|
|
|
#include <vm/swap_pager.h>
|
2000-12-09 08:25:54 -05:00
|
|
|
|
2000-10-25 18:38:23 -04:00
|
|
|
#include <machine/clock.h>
|
2001-06-11 17:55:40 -04:00
|
|
|
|
2009-03-26 13:14:22 -04:00
|
|
|
#include <geom/geom.h>
|
|
|
|
|
#include <geom/geom_int.h>
|
|
|
|
|
|
2004-08-16 04:19:18 -04:00
|
|
|
#if defined(__i386__) || defined(__amd64__)
|
2000-04-19 23:54:27 -04:00
|
|
|
#include <machine/cputypes.h>
|
2000-10-25 18:38:23 -04:00
|
|
|
#include <machine/md_var.h>
|
2004-08-16 04:19:18 -04:00
|
|
|
#endif /* __i386__ || __amd64__ */
|
2000-04-19 23:54:27 -04:00
|
|
|
|
2015-05-24 13:48:34 -04:00
|
|
|
#include <compat/linux/linux.h>
|
2000-12-13 15:22:24 -05:00
|
|
|
#include <compat/linux/linux_mib.h>
|
2013-01-29 13:41:30 -05:00
|
|
|
#include <compat/linux/linux_misc.h>
|
2001-10-21 11:56:46 -04:00
|
|
|
#include <compat/linux/linux_util.h>
|
2001-06-10 19:23:59 -04:00
|
|
|
#include <fs/pseudofs/pseudofs.h>
|
2001-10-01 00:31:05 -04:00
|
|
|
#include <fs/procfs/procfs.h>
|
2000-09-09 07:44:58 -04:00
|
|
|
|
2000-10-25 18:12:59 -04:00
|
|
|
/*
|
|
|
|
|
* Various conversion macros
|
|
|
|
|
*/
|
2010-04-02 02:50:28 -04:00
|
|
|
#define T2J(x) ((long)(((x) * 100ULL) / (stathz ? stathz : hz))) /* ticks to jiffies */
|
|
|
|
|
#define T2CS(x) ((unsigned long)(((x) * 100ULL) / (stathz ? stathz : hz))) /* ticks to centiseconds */
|
2000-10-25 18:12:59 -04:00
|
|
|
#define T2S(x) ((x) / (stathz ? stathz : hz)) /* ticks to seconds */
|
|
|
|
|
#define B2K(x) ((x) >> 10) /* bytes to kbytes */
|
2000-12-09 08:25:54 -05:00
|
|
|
#define B2P(x) ((x) >> PAGE_SHIFT) /* bytes to pages */
|
2000-10-25 18:12:59 -04:00
|
|
|
#define P2B(x) ((x) << PAGE_SHIFT) /* pages to bytes */
|
|
|
|
|
#define P2K(x) ((x) << (PAGE_SHIFT - 10)) /* pages to kbytes */
|
2010-04-02 02:50:28 -04:00
|
|
|
#define TV2J(x) ((x)->tv_sec * 100UL + (x)->tv_usec / 10000)
|
2001-03-11 22:16:56 -05:00
|
|
|
|
2006-06-27 16:11:58 -04: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 02:03:46 -04:00
|
|
|
* uninterruptible disk sleep, a zombie process, process is being traced
|
2006-06-27 16:11:58 -04: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 06:07:41 -05:00
|
|
|
static char linux_state[] = "RRSTZDD";
|
2006-06-27 16:11:58 -04:00
|
|
|
|
2001-06-11 17:55:40 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/meminfo
|
|
|
|
|
*/
|
2001-06-10 19:23:59 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_domeminfo(PFS_FILL_ARGS)
|
2000-04-19 23:54:27 -04:00
|
|
|
{
|
|
|
|
|
unsigned long memtotal; /* total memory in bytes */
|
|
|
|
|
unsigned long memfree; /* free memory in bytes */
|
2020-08-12 12:08:44 -04:00
|
|
|
unsigned long cached; /* page cache */
|
|
|
|
|
unsigned long buffers; /* buffer cache */
|
2003-04-16 15:46:26 -04: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 */
|
2020-08-12 12:08:44 -04:00
|
|
|
size_t sz;
|
|
|
|
|
int error, i, j;
|
2000-04-19 23:54:27 -04:00
|
|
|
|
|
|
|
|
memtotal = physmem * PAGE_SIZE;
|
2020-08-12 12:08:44 -04:00
|
|
|
memfree = (unsigned long)vm_free_count() * PAGE_SIZE;
|
2003-07-18 06:26:09 -04:00
|
|
|
swap_pager_status(&i, &j);
|
2005-12-11 16:37:42 -05:00
|
|
|
swaptotal = (unsigned long long)i * PAGE_SIZE;
|
|
|
|
|
swapused = (unsigned long long)j * PAGE_SIZE;
|
2003-07-18 06:26:09 -04:00
|
|
|
swapfree = swaptotal - swapused;
|
2020-08-12 12:08:44 -04:00
|
|
|
|
2000-04-19 23:54:27 -04:00
|
|
|
/*
|
2020-08-12 12:08:44 -04:00
|
|
|
* This value may exclude wired pages, but we have no good way of
|
|
|
|
|
* accounting for that.
|
2000-04-19 23:54:27 -04:00
|
|
|
*/
|
2020-08-12 12:08:44 -04:00
|
|
|
cached =
|
|
|
|
|
(vm_active_count() + vm_inactive_count() + vm_laundry_count()) *
|
|
|
|
|
PAGE_SIZE;
|
|
|
|
|
|
|
|
|
|
sz = sizeof(buffers);
|
|
|
|
|
error = kernel_sysctlbyname(curthread, "vfs.bufspace", &buffers, &sz,
|
|
|
|
|
NULL, 0, 0, 0);
|
|
|
|
|
if (error != 0)
|
|
|
|
|
buffers = 0;
|
2000-04-19 23:54:27 -04:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_printf(sb,
|
2000-12-09 08:25:54 -05:00
|
|
|
"MemTotal: %9lu kB\n"
|
|
|
|
|
"MemFree: %9lu kB\n"
|
|
|
|
|
"Buffers: %9lu kB\n"
|
|
|
|
|
"Cached: %9lu kB\n"
|
2001-05-19 01:54:26 -04:00
|
|
|
"SwapTotal:%9llu kB\n"
|
|
|
|
|
"SwapFree: %9llu kB\n",
|
2016-09-15 23:36:43 -04:00
|
|
|
B2K(memtotal), B2K(memfree), B2K(buffers),
|
|
|
|
|
B2K(cached), B2K(swaptotal), B2K(swapfree));
|
2000-04-19 23:54:27 -04:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
return (0);
|
2000-04-19 23:54:27 -04:00
|
|
|
}
|
|
|
|
|
|
2004-08-16 04:19:18 -04:00
|
|
|
#if defined(__i386__) || defined(__amd64__)
|
2001-06-11 17:55:40 -04:00
|
|
|
/*
|
2004-08-16 04:19:18 -04:00
|
|
|
* Filler function for proc/cpuinfo (i386 & amd64 version)
|
2001-06-11 17:55:40 -04:00
|
|
|
*/
|
2001-06-10 19:23:59 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_docpuinfo(PFS_FILL_ARGS)
|
2000-04-19 23:54:27 -04:00
|
|
|
{
|
2006-06-12 14:14:49 -04:00
|
|
|
int hw_model[2];
|
|
|
|
|
char model[128];
|
2011-04-07 19:28:28 -04:00
|
|
|
uint64_t freq;
|
2006-06-12 14:14:49 -04:00
|
|
|
size_t size;
|
2017-05-06 13:37:01 -04:00
|
|
|
u_int cache_size[4];
|
2016-09-15 13:05:54 -04:00
|
|
|
int fqmhz, fqkhz;
|
2017-05-06 13:37:01 -04:00
|
|
|
int i, j;
|
2003-08-04 06:55:22 -04:00
|
|
|
|
2000-12-09 08:25:54 -05:00
|
|
|
/*
|
2001-06-10 20:17:59 -04:00
|
|
|
* We default the flags to include all non-conflicting flags,
|
|
|
|
|
* and the Intel versions of conflicting flags.
|
2000-12-09 08:25:54 -05:00
|
|
|
*/
|
2019-05-03 04:27:03 -04:00
|
|
|
static char *cpu_feature_names[] = {
|
|
|
|
|
/* 0 */ "fpu", "vme", "de", "pse",
|
|
|
|
|
/* 4 */ "tsc", "msr", "pae", "mce",
|
|
|
|
|
/* 8 */ "cx8", "apic", "", "sep",
|
|
|
|
|
/* 12 */ "mtrr", "pge", "mca", "cmov",
|
|
|
|
|
/* 16 */ "pat", "pse36", "pn", "clflush",
|
|
|
|
|
/* 20 */ "", "dts", "acpi", "mmx",
|
|
|
|
|
/* 24 */ "fxsr", "sse", "sse2", "ss",
|
|
|
|
|
/* 28 */ "ht", "tm", "ia64", "pbe"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static char *amd_feature_names[] = {
|
|
|
|
|
/* 0 */ "", "", "", "",
|
|
|
|
|
/* 4 */ "", "", "", "",
|
|
|
|
|
/* 8 */ "", "", "", "syscall",
|
|
|
|
|
/* 12 */ "", "", "", "",
|
|
|
|
|
/* 16 */ "", "", "", "mp",
|
|
|
|
|
/* 20 */ "nx", "", "mmxext", "",
|
|
|
|
|
/* 24 */ "", "fxsr_opt", "pdpe1gb", "rdtscp",
|
|
|
|
|
/* 28 */ "", "lm", "3dnowext", "3dnow"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static char *cpu_feature2_names[] = {
|
2020-07-18 06:49:17 -04:00
|
|
|
/* 0 */ "pni", "pclmulqdq", "dtes64", "monitor",
|
2019-05-03 04:27:03 -04:00
|
|
|
/* 4 */ "ds_cpl", "vmx", "smx", "est",
|
|
|
|
|
/* 8 */ "tm2", "ssse3", "cid", "sdbg",
|
2020-07-18 06:49:17 -04:00
|
|
|
/* 12 */ "fma", "cx16", "xtpr", "pdcm",
|
2019-05-03 04:27:03 -04:00
|
|
|
/* 16 */ "", "pcid", "dca", "sse4_1",
|
|
|
|
|
/* 20 */ "sse4_2", "x2apic", "movbe", "popcnt",
|
|
|
|
|
/* 24 */ "tsc_deadline_timer", "aes", "xsave", "",
|
|
|
|
|
/* 28 */ "avx", "f16c", "rdrand", "hypervisor"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static char *amd_feature2_names[] = {
|
|
|
|
|
/* 0 */ "lahf_lm", "cmp_legacy", "svm", "extapic",
|
|
|
|
|
/* 4 */ "cr8_legacy", "abm", "sse4a", "misalignsse",
|
|
|
|
|
/* 8 */ "3dnowprefetch", "osvw", "ibs", "xop",
|
|
|
|
|
/* 12 */ "skinit", "wdt", "", "lwp",
|
|
|
|
|
/* 16 */ "fma4", "tce", "", "nodeid_msr",
|
|
|
|
|
/* 20 */ "", "tbm", "topoext", "perfctr_core",
|
|
|
|
|
/* 24 */ "perfctr_nb", "", "bpext", "ptsc",
|
|
|
|
|
/* 28 */ "perfctr_llc", "mwaitx", "", ""
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static char *cpu_stdext_feature_names[] = {
|
|
|
|
|
/* 0 */ "fsgsbase", "tsc_adjust", "", "bmi1",
|
|
|
|
|
/* 4 */ "hle", "avx2", "", "smep",
|
|
|
|
|
/* 8 */ "bmi2", "erms", "invpcid", "rtm",
|
|
|
|
|
/* 12 */ "cqm", "", "mpx", "rdt_a",
|
|
|
|
|
/* 16 */ "avx512f", "avx512dq", "rdseed", "adx",
|
|
|
|
|
/* 20 */ "smap", "avx512ifma", "", "clflushopt",
|
|
|
|
|
/* 24 */ "clwb", "intel_pt", "avx512pf", "avx512er",
|
|
|
|
|
/* 28 */ "avx512cd", "sha_ni", "avx512bw", "avx512vl"
|
2000-10-25 18:38:23 -04:00
|
|
|
};
|
2000-04-19 23:54:27 -04:00
|
|
|
|
2017-05-06 13:37:01 -04:00
|
|
|
static char *power_flags[] = {
|
|
|
|
|
"ts", "fid", "vid",
|
|
|
|
|
"ttp", "tm", "stc",
|
|
|
|
|
"100mhzsteps", "hwpstate", "",
|
|
|
|
|
"cpb", "eff_freq_ro", "proc_feedback",
|
|
|
|
|
"acc_power",
|
|
|
|
|
};
|
|
|
|
|
|
2006-06-12 14:14:49 -04: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");
|
2009-01-22 12:06:33 -05:00
|
|
|
#ifdef __i386__
|
|
|
|
|
switch (cpu_vendor_id) {
|
|
|
|
|
case CPU_VENDOR_AMD:
|
2016-09-15 13:05:54 -04:00
|
|
|
if (cpu_class < CPUCLASS_686)
|
2019-05-03 04:27:03 -04:00
|
|
|
cpu_feature_names[16] = "fcmov";
|
2009-01-22 12:06:33 -05:00
|
|
|
break;
|
|
|
|
|
case CPU_VENDOR_CYRIX:
|
2019-05-03 04:27:03 -04:00
|
|
|
cpu_feature_names[24] = "cxmmx";
|
2009-01-22 12:06:33 -05:00
|
|
|
break;
|
2001-06-10 20:17:59 -04:00
|
|
|
}
|
2009-01-22 12:06:33 -05:00
|
|
|
#endif
|
2017-06-23 06:36:27 -04:00
|
|
|
if (cpu_exthigh >= 0x80000006)
|
|
|
|
|
do_cpuid(0x80000006, cache_size);
|
|
|
|
|
else
|
|
|
|
|
memset(cache_size, 0, sizeof(cache_size));
|
2017-05-06 13:37:01 -04:00
|
|
|
for (i = 0; i < mp_ncpus; ++i) {
|
|
|
|
|
fqmhz = 0;
|
|
|
|
|
fqkhz = 0;
|
|
|
|
|
freq = atomic_load_acq_64(&tsc_freq);
|
|
|
|
|
if (freq != 0) {
|
|
|
|
|
fqmhz = (freq + 4999) / 1000000;
|
|
|
|
|
fqkhz = ((freq + 4999) / 10000) % 100;
|
|
|
|
|
}
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_printf(sb,
|
2017-05-06 13:37:01 -04:00
|
|
|
"processor\t: %d\n"
|
|
|
|
|
"vendor_id\t: %.20s\n"
|
|
|
|
|
"cpu family\t: %u\n"
|
|
|
|
|
"model\t\t: %u\n"
|
|
|
|
|
"model name\t: %s\n"
|
|
|
|
|
"stepping\t: %u\n"
|
2000-12-09 08:25:54 -05:00
|
|
|
"cpu MHz\t\t: %d.%02d\n"
|
2017-05-06 13:37:01 -04:00
|
|
|
"cache size\t: %d KB\n"
|
|
|
|
|
"physical id\t: %d\n"
|
|
|
|
|
"siblings\t: %d\n"
|
|
|
|
|
"core id\t\t: %d\n"
|
|
|
|
|
"cpu cores\t: %d\n"
|
|
|
|
|
"apicid\t\t: %d\n"
|
|
|
|
|
"initial apicid\t: %d\n"
|
|
|
|
|
"fpu\t\t: %s\n"
|
|
|
|
|
"fpu_exception\t: %s\n"
|
|
|
|
|
"cpuid level\t: %d\n"
|
|
|
|
|
"wp\t\t: %s\n",
|
|
|
|
|
i, cpu_vendor, CPUID_TO_FAMILY(cpu_id),
|
|
|
|
|
CPUID_TO_MODEL(cpu_id), model, cpu_id & CPUID_STEPPING,
|
|
|
|
|
fqmhz, fqkhz,
|
|
|
|
|
(cache_size[2] >> 16), 0, mp_ncpus, i, mp_ncpus,
|
|
|
|
|
i, i, /*cpu_id & CPUID_LOCAL_APIC_ID ??*/
|
|
|
|
|
(cpu_feature & CPUID_FPU) ? "yes" : "no", "yes",
|
|
|
|
|
CPUID_TO_FAMILY(cpu_id), "yes");
|
|
|
|
|
sbuf_cat(sb, "flags\t\t:");
|
2019-05-03 04:27:03 -04:00
|
|
|
for (j = 0; j < nitems(cpu_feature_names); j++)
|
|
|
|
|
if (cpu_feature & (1 << j) &&
|
|
|
|
|
cpu_feature_names[j][0] != '\0')
|
|
|
|
|
sbuf_printf(sb, " %s", cpu_feature_names[j]);
|
|
|
|
|
for (j = 0; j < nitems(amd_feature_names); j++)
|
|
|
|
|
if (amd_feature & (1 << j) &&
|
|
|
|
|
amd_feature_names[j][0] != '\0')
|
|
|
|
|
sbuf_printf(sb, " %s", amd_feature_names[j]);
|
|
|
|
|
for (j = 0; j < nitems(cpu_feature2_names); j++)
|
|
|
|
|
if (cpu_feature2 & (1 << j) &&
|
|
|
|
|
cpu_feature2_names[j][0] != '\0')
|
|
|
|
|
sbuf_printf(sb, " %s", cpu_feature2_names[j]);
|
|
|
|
|
for (j = 0; j < nitems(amd_feature2_names); j++)
|
|
|
|
|
if (amd_feature2 & (1 << j) &&
|
|
|
|
|
amd_feature2_names[j][0] != '\0')
|
|
|
|
|
sbuf_printf(sb, " %s", amd_feature2_names[j]);
|
|
|
|
|
for (j = 0; j < nitems(cpu_stdext_feature_names); j++)
|
|
|
|
|
if (cpu_stdext_feature & (1 << j) &&
|
|
|
|
|
cpu_stdext_feature_names[j][0] != '\0')
|
|
|
|
|
sbuf_printf(sb, " %s",
|
|
|
|
|
cpu_stdext_feature_names[j]);
|
2017-05-06 13:37:01 -04:00
|
|
|
sbuf_cat(sb, "\n");
|
|
|
|
|
sbuf_printf(sb,
|
|
|
|
|
"bugs\t\t: %s\n"
|
|
|
|
|
"bogomips\t: %d.%02d\n"
|
|
|
|
|
"clflush size\t: %d\n"
|
|
|
|
|
"cache_alignment\t: %d\n"
|
|
|
|
|
"address sizes\t: %d bits physical, %d bits virtual\n",
|
|
|
|
|
#if defined(I586_CPU) && !defined(NO_F00F_HACK)
|
|
|
|
|
(has_f00f_bug) ? "Intel F00F" : "",
|
|
|
|
|
#else
|
|
|
|
|
"",
|
|
|
|
|
#endif
|
2020-07-18 06:53:56 -04:00
|
|
|
fqmhz * 2, fqkhz,
|
2017-05-06 13:37:01 -04:00
|
|
|
cpu_clflush_line_size, cpu_clflush_line_size,
|
|
|
|
|
cpu_maxphyaddr,
|
|
|
|
|
(cpu_maxphyaddr > 32) ? 48 : 0);
|
|
|
|
|
sbuf_cat(sb, "power management: ");
|
|
|
|
|
for (j = 0; j < nitems(power_flags); j++)
|
|
|
|
|
if (amd_pminfo & (1 << j))
|
|
|
|
|
sbuf_printf(sb, " %s", power_flags[j]);
|
|
|
|
|
sbuf_cat(sb, "\n\n");
|
|
|
|
|
|
|
|
|
|
/* XXX per-cpu vendor / class / model / id? */
|
2001-06-10 20:17:59 -04:00
|
|
|
}
|
2017-05-06 13:37:01 -04:00
|
|
|
sbuf_cat(sb, "\n");
|
2000-12-13 15:22:24 -05:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
return (0);
|
2000-09-09 07:44:58 -04:00
|
|
|
}
|
2018-06-15 09:53:37 -04:00
|
|
|
#else
|
|
|
|
|
/* ARM64TODO: implement non-stubbed linprocfs_docpuinfo */
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_docpuinfo(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < mp_ncpus; ++i) {
|
|
|
|
|
sbuf_printf(sb,
|
|
|
|
|
"processor\t: %d\n"
|
|
|
|
|
"BogoMIPS\t: %d.%02d\n",
|
|
|
|
|
i, 0, 0);
|
|
|
|
|
sbuf_cat(sb, "Features\t: ");
|
|
|
|
|
sbuf_cat(sb, "\n");
|
|
|
|
|
sbuf_printf(sb,
|
|
|
|
|
"CPU implementer\t: \n"
|
|
|
|
|
"CPU architecture: \n"
|
|
|
|
|
"CPU variant\t: 0x%x\n"
|
|
|
|
|
"CPU part\t: 0x%x\n"
|
|
|
|
|
"CPU revision\t: %d\n",
|
|
|
|
|
0, 0, 0);
|
|
|
|
|
sbuf_cat(sb, "\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
2004-08-16 04:19:18 -04:00
|
|
|
#endif /* __i386__ || __amd64__ */
|
2000-09-09 07:44:58 -04:00
|
|
|
|
2001-10-21 11:56:46 -04: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;
|
2002-02-26 18:38:34 -05:00
|
|
|
const char *lep;
|
|
|
|
|
char *dlep, *flep, *mntto, *mntfrom, *fstype;
|
2001-10-21 11:56:46 -04:00
|
|
|
size_t lep_len;
|
|
|
|
|
int error;
|
2015-04-15 05:13:11 -04:00
|
|
|
struct statfs *buf, *sp;
|
|
|
|
|
size_t count;
|
2001-10-21 11:56:46 -04:00
|
|
|
|
|
|
|
|
/* resolve symlinks etc. in the emulation tree prefix */
|
2012-10-22 13:50:54 -04:00
|
|
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path, td);
|
2001-10-21 11:56:46 -04:00
|
|
|
flep = NULL;
|
2007-04-22 04:41:52 -04:00
|
|
|
error = namei(&nd);
|
2008-11-04 13:53:33 -05:00
|
|
|
lep = linux_emul_path;
|
|
|
|
|
if (error == 0) {
|
2020-08-24 04:57:02 -04:00
|
|
|
if (vn_fullpath(nd.ni_vp, &dlep, &flep) == 0)
|
2008-11-04 13:53:33 -05:00
|
|
|
lep = dlep;
|
|
|
|
|
vrele(nd.ni_vp);
|
|
|
|
|
}
|
2001-10-21 11:56:46 -04:00
|
|
|
lep_len = strlen(lep);
|
2003-08-18 09:30:15 -04:00
|
|
|
|
2015-04-15 05:13:11 -04:00
|
|
|
buf = NULL;
|
|
|
|
|
error = kern_getfsstat(td, &buf, SIZE_T_MAX, &count,
|
|
|
|
|
UIO_SYSSPACE, MNT_WAIT);
|
|
|
|
|
if (error != 0) {
|
|
|
|
|
free(buf, M_TEMP);
|
|
|
|
|
free(flep, M_TEMP);
|
|
|
|
|
return (error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (sp = buf; count > 0; sp++, count--) {
|
2001-10-21 11:56:46 -04:00
|
|
|
/* determine device name */
|
2015-04-15 05:13:11 -04:00
|
|
|
mntfrom = sp->f_mntfromname;
|
2003-08-18 09:30:15 -04:00
|
|
|
|
2001-10-21 11:56:46 -04:00
|
|
|
/* determine mount point */
|
2015-04-15 05:13:11 -04:00
|
|
|
mntto = sp->f_mntonname;
|
|
|
|
|
if (strncmp(mntto, lep, lep_len) == 0 && mntto[lep_len] == '/')
|
2001-10-21 11:56:46 -04:00
|
|
|
mntto += lep_len;
|
|
|
|
|
|
|
|
|
|
/* determine fs type */
|
2015-04-15 05:13:11 -04:00
|
|
|
fstype = sp->f_fstypename;
|
2001-10-21 11:56:46 -04:00
|
|
|
if (strcmp(fstype, pn->pn_info->pi_name) == 0)
|
|
|
|
|
mntfrom = fstype = "proc";
|
|
|
|
|
else if (strcmp(fstype, "procfs") == 0)
|
|
|
|
|
continue;
|
2003-08-18 09:30:15 -04:00
|
|
|
|
2019-09-04 14:00:54 -04:00
|
|
|
if (strcmp(fstype, "autofs") == 0) {
|
|
|
|
|
/*
|
|
|
|
|
* FreeBSD uses eg "map -hosts", whereas Linux
|
|
|
|
|
* expects just "-hosts".
|
|
|
|
|
*/
|
|
|
|
|
if (strncmp(mntfrom, "map ", 4) == 0)
|
|
|
|
|
mntfrom += 4;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-05 12:10:45 -04:00
|
|
|
if (strcmp(fstype, "linsysfs") == 0) {
|
|
|
|
|
sbuf_printf(sb, "/sys %s sysfs %s", mntto,
|
2015-04-15 05:13:11 -04:00
|
|
|
sp->f_flags & MNT_RDONLY ? "ro" : "rw");
|
2006-05-05 12:10:45 -04:00
|
|
|
} else {
|
2009-03-26 13:14:22 -04:00
|
|
|
/* For Linux msdosfs is called vfat */
|
|
|
|
|
if (strcmp(fstype, "msdosfs") == 0)
|
|
|
|
|
fstype = "vfat";
|
2006-05-05 12:10:45 -04:00
|
|
|
sbuf_printf(sb, "%s %s %s %s", mntfrom, mntto, fstype,
|
2015-04-15 05:13:11 -04:00
|
|
|
sp->f_flags & MNT_RDONLY ? "ro" : "rw");
|
2006-05-05 12:10:45 -04:00
|
|
|
}
|
2001-10-21 11:56:46 -04:00
|
|
|
#define ADD_OPTION(opt, name) \
|
2015-04-15 05:13:11 -04:00
|
|
|
if (sp->f_flags & (opt)) sbuf_printf(sb, "," name);
|
2001-10-21 11:56:46 -04:00
|
|
|
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");
|
|
|
|
|
}
|
2015-04-15 05:13:11 -04:00
|
|
|
|
|
|
|
|
free(buf, M_TEMP);
|
2013-03-03 21:21:34 -05:00
|
|
|
free(flep, M_TEMP);
|
2001-10-21 11:56:46 -04:00
|
|
|
return (error);
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-26 13:14:22 -04: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;
|
|
|
|
|
int major, minor;
|
|
|
|
|
|
|
|
|
|
g_topology_lock();
|
|
|
|
|
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();
|
|
|
|
|
|
2015-04-02 06:19:24 -04:00
|
|
|
return (0);
|
2009-03-26 13:14:22 -04:00
|
|
|
}
|
|
|
|
|
|
2001-06-11 17:55:40 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/stat
|
Fix output of linprocfs stat entry
The Linux /proc/stat entry has grown over time
v2.5.41 <
user, nice, system, idle
v2.5.41
user, nice, system, idle, iowait, irq
v2.6.11
user, nice, system, idle, iowait, irq, softirq, steal
v2.6.24
user, nice, system, idle, iowait, irq, softirq, steal, guest
v2.6.32 >
user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice
Some applications (e.g. nodejs) depend on the correct number of entries
and will abort otherwise.
Fix is to print the correct number of entries based on the value of
osrelease set either in sysctl or the jail settings. Change is similar
to approach used by illumos.
Reviewed by: emaste, imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15858
2018-06-21 20:02:05 -04:00
|
|
|
*
|
|
|
|
|
* Output depends on kernel version:
|
|
|
|
|
*
|
|
|
|
|
* v2.5.40 <=
|
|
|
|
|
* user nice system idle
|
|
|
|
|
* v2.5.41
|
|
|
|
|
* user nice system idle iowait
|
|
|
|
|
* v2.6.11
|
|
|
|
|
* user nice system idle iowait irq softirq steal
|
|
|
|
|
* v2.6.24
|
|
|
|
|
* user nice system idle iowait irq softirq steal guest
|
|
|
|
|
* v2.6.33 >=
|
|
|
|
|
* user nice system idle iowait irq softirq steal guest guest_nice
|
2001-06-11 17:55:40 -04:00
|
|
|
*/
|
2001-06-10 19:23:59 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_dostat(PFS_FILL_ARGS)
|
2000-09-09 07:44:58 -04:00
|
|
|
{
|
2007-11-29 01:34:30 -05:00
|
|
|
struct pcpu *pcpu;
|
|
|
|
|
long cp_time[CPUSTATES];
|
|
|
|
|
long *cp;
|
2016-07-27 07:08:59 -04:00
|
|
|
struct timeval boottime;
|
2003-12-07 12:38:20 -05:00
|
|
|
int i;
|
Fix output of linprocfs stat entry
The Linux /proc/stat entry has grown over time
v2.5.41 <
user, nice, system, idle
v2.5.41
user, nice, system, idle, iowait, irq
v2.6.11
user, nice, system, idle, iowait, irq, softirq, steal
v2.6.24
user, nice, system, idle, iowait, irq, softirq, steal, guest
v2.6.32 >
user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice
Some applications (e.g. nodejs) depend on the correct number of entries
and will abort otherwise.
Fix is to print the correct number of entries based on the value of
osrelease set either in sysctl or the jail settings. Change is similar
to approach used by illumos.
Reviewed by: emaste, imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15858
2018-06-21 20:02:05 -04:00
|
|
|
char *zero_pad;
|
|
|
|
|
bool has_intr = true;
|
|
|
|
|
|
|
|
|
|
if (linux_kernver(td) >= LINUX_KERNVER(2,6,33)) {
|
|
|
|
|
zero_pad = " 0 0 0 0\n";
|
|
|
|
|
} else if (linux_kernver(td) >= LINUX_KERNVER(2,6,24)) {
|
|
|
|
|
zero_pad = " 0 0 0\n";
|
|
|
|
|
} else if (linux_kernver(td) >= LINUX_KERNVER(2,6,11)) {
|
|
|
|
|
zero_pad = " 0 0\n";
|
|
|
|
|
} else if (linux_kernver(td) >= LINUX_KERNVER(2,5,41)) {
|
|
|
|
|
has_intr = false;
|
|
|
|
|
zero_pad = " 0\n";
|
|
|
|
|
} else {
|
|
|
|
|
has_intr = false;
|
|
|
|
|
zero_pad = "\n";
|
|
|
|
|
}
|
2003-12-07 12:38:20 -05:00
|
|
|
|
2007-11-29 01:34:30 -05:00
|
|
|
read_cpu_time(cp_time);
|
2016-07-27 07:08:59 -04:00
|
|
|
getboottime(&boottime);
|
Fix output of linprocfs stat entry
The Linux /proc/stat entry has grown over time
v2.5.41 <
user, nice, system, idle
v2.5.41
user, nice, system, idle, iowait, irq
v2.6.11
user, nice, system, idle, iowait, irq, softirq, steal
v2.6.24
user, nice, system, idle, iowait, irq, softirq, steal, guest
v2.6.32 >
user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice
Some applications (e.g. nodejs) depend on the correct number of entries
and will abort otherwise.
Fix is to print the correct number of entries based on the value of
osrelease set either in sysctl or the jail settings. Change is similar
to approach used by illumos.
Reviewed by: emaste, imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15858
2018-06-21 20:02:05 -04:00
|
|
|
/* Parameters common to all versions */
|
|
|
|
|
sbuf_printf(sb, "cpu %lu %lu %lu %lu",
|
2003-09-22 11:52:32 -04:00
|
|
|
T2J(cp_time[CP_USER]),
|
|
|
|
|
T2J(cp_time[CP_NICE]),
|
Fix output of linprocfs stat entry
The Linux /proc/stat entry has grown over time
v2.5.41 <
user, nice, system, idle
v2.5.41
user, nice, system, idle, iowait, irq
v2.6.11
user, nice, system, idle, iowait, irq, softirq, steal
v2.6.24
user, nice, system, idle, iowait, irq, softirq, steal, guest
v2.6.32 >
user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice
Some applications (e.g. nodejs) depend on the correct number of entries
and will abort otherwise.
Fix is to print the correct number of entries based on the value of
osrelease set either in sysctl or the jail settings. Change is similar
to approach used by illumos.
Reviewed by: emaste, imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15858
2018-06-21 20:02:05 -04:00
|
|
|
T2J(cp_time[CP_SYS]),
|
2003-09-22 11:52:32 -04:00
|
|
|
T2J(cp_time[CP_IDLE]));
|
Fix output of linprocfs stat entry
The Linux /proc/stat entry has grown over time
v2.5.41 <
user, nice, system, idle
v2.5.41
user, nice, system, idle, iowait, irq
v2.6.11
user, nice, system, idle, iowait, irq, softirq, steal
v2.6.24
user, nice, system, idle, iowait, irq, softirq, steal, guest
v2.6.32 >
user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice
Some applications (e.g. nodejs) depend on the correct number of entries
and will abort otherwise.
Fix is to print the correct number of entries based on the value of
osrelease set either in sysctl or the jail settings. Change is similar
to approach used by illumos.
Reviewed by: emaste, imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15858
2018-06-21 20:02:05 -04:00
|
|
|
|
|
|
|
|
/* Print interrupt stats if available */
|
|
|
|
|
if (has_intr) {
|
|
|
|
|
sbuf_printf(sb, " 0 %lu", T2J(cp_time[CP_INTR]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pad out remaining fields depending on version */
|
|
|
|
|
sbuf_printf(sb, "%s", zero_pad);
|
|
|
|
|
|
2010-06-11 14:46:34 -04:00
|
|
|
CPU_FOREACH(i) {
|
2007-11-29 01:34:30 -05:00
|
|
|
pcpu = pcpu_find(i);
|
|
|
|
|
cp = pcpu->pc_cp_time;
|
Fix output of linprocfs stat entry
The Linux /proc/stat entry has grown over time
v2.5.41 <
user, nice, system, idle
v2.5.41
user, nice, system, idle, iowait, irq
v2.6.11
user, nice, system, idle, iowait, irq, softirq, steal
v2.6.24
user, nice, system, idle, iowait, irq, softirq, steal, guest
v2.6.32 >
user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice
Some applications (e.g. nodejs) depend on the correct number of entries
and will abort otherwise.
Fix is to print the correct number of entries based on the value of
osrelease set either in sysctl or the jail settings. Change is similar
to approach used by illumos.
Reviewed by: emaste, imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15858
2018-06-21 20:02:05 -04:00
|
|
|
sbuf_printf(sb, "cpu%d %lu %lu %lu %lu", i,
|
2007-11-29 01:34:30 -05:00
|
|
|
T2J(cp[CP_USER]),
|
|
|
|
|
T2J(cp[CP_NICE]),
|
Fix output of linprocfs stat entry
The Linux /proc/stat entry has grown over time
v2.5.41 <
user, nice, system, idle
v2.5.41
user, nice, system, idle, iowait, irq
v2.6.11
user, nice, system, idle, iowait, irq, softirq, steal
v2.6.24
user, nice, system, idle, iowait, irq, softirq, steal, guest
v2.6.32 >
user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice
Some applications (e.g. nodejs) depend on the correct number of entries
and will abort otherwise.
Fix is to print the correct number of entries based on the value of
osrelease set either in sysctl or the jail settings. Change is similar
to approach used by illumos.
Reviewed by: emaste, imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15858
2018-06-21 20:02:05 -04:00
|
|
|
T2J(cp[CP_SYS]),
|
2007-11-29 01:34:30 -05:00
|
|
|
T2J(cp[CP_IDLE]));
|
Fix output of linprocfs stat entry
The Linux /proc/stat entry has grown over time
v2.5.41 <
user, nice, system, idle
v2.5.41
user, nice, system, idle, iowait, irq
v2.6.11
user, nice, system, idle, iowait, irq, softirq, steal
v2.6.24
user, nice, system, idle, iowait, irq, softirq, steal, guest
v2.6.32 >
user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice
Some applications (e.g. nodejs) depend on the correct number of entries
and will abort otherwise.
Fix is to print the correct number of entries based on the value of
osrelease set either in sysctl or the jail settings. Change is similar
to approach used by illumos.
Reviewed by: emaste, imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15858
2018-06-21 20:02:05 -04:00
|
|
|
|
|
|
|
|
if (has_intr) {
|
|
|
|
|
sbuf_printf(sb, " 0 %lu", T2J(cp[CP_INTR]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sbuf_printf(sb, "%s", zero_pad);
|
2007-11-29 01:34:30 -05:00
|
|
|
}
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_printf(sb,
|
2000-12-09 08:25:54 -05:00
|
|
|
"disk 0 0 0 0\n"
|
- Remove 'struct vmmeter' from 'struct pcpu', leaving only global vmmeter
in place. To do per-cpu stats, convert all fields that previously were
maintained in the vmmeters that sit in pcpus to counter(9).
- Since some vmmeter stats may be touched at very early stages of boot,
before we have set up UMA and we can do counter_u64_alloc(), provide an
early counter mechanism:
o Leave one spare uint64_t in struct pcpu, named pc_early_dummy_counter.
o Point counter(9) fields of vmmeter to pcpu[0].pc_early_dummy_counter,
so that at early stages of boot, before counters are allocated we already
point to a counter that can be safely written to.
o For sparc64 that required a whole dummy pcpu[MAXCPU] array.
Further related changes:
- Don't include vmmeter.h into pcpu.h.
- vm.stats.vm.v_swappgsout and vm.stats.vm.v_swappgsin changed to 64-bit,
to match kernel representation.
- struct vmmeter hidden under _KERNEL, and only vmstat(1) is an exclusion.
This is based on benno@'s 4-year old patch:
https://lists.freebsd.org/pipermail/freebsd-arch/2013-July/014471.html
Reviewed by: kib, gallatin, marius, lidl
Differential Revision: https://reviews.freebsd.org/D10156
2017-04-17 13:34:47 -04:00
|
|
|
"page %ju %ju\n"
|
|
|
|
|
"swap %ju %ju\n"
|
|
|
|
|
"intr %ju\n"
|
|
|
|
|
"ctxt %ju\n"
|
2001-10-28 21:17:41 -05:00
|
|
|
"btime %lld\n",
|
- Remove 'struct vmmeter' from 'struct pcpu', leaving only global vmmeter
in place. To do per-cpu stats, convert all fields that previously were
maintained in the vmmeters that sit in pcpus to counter(9).
- Since some vmmeter stats may be touched at very early stages of boot,
before we have set up UMA and we can do counter_u64_alloc(), provide an
early counter mechanism:
o Leave one spare uint64_t in struct pcpu, named pc_early_dummy_counter.
o Point counter(9) fields of vmmeter to pcpu[0].pc_early_dummy_counter,
so that at early stages of boot, before counters are allocated we already
point to a counter that can be safely written to.
o For sparc64 that required a whole dummy pcpu[MAXCPU] array.
Further related changes:
- Don't include vmmeter.h into pcpu.h.
- vm.stats.vm.v_swappgsout and vm.stats.vm.v_swappgsin changed to 64-bit,
to match kernel representation.
- struct vmmeter hidden under _KERNEL, and only vmstat(1) is an exclusion.
This is based on benno@'s 4-year old patch:
https://lists.freebsd.org/pipermail/freebsd-arch/2013-July/014471.html
Reviewed by: kib, gallatin, marius, lidl
Differential Revision: https://reviews.freebsd.org/D10156
2017-04-17 13:34:47 -04:00
|
|
|
(uintmax_t)VM_CNT_FETCH(v_vnodepgsin),
|
|
|
|
|
(uintmax_t)VM_CNT_FETCH(v_vnodepgsout),
|
|
|
|
|
(uintmax_t)VM_CNT_FETCH(v_swappgsin),
|
|
|
|
|
(uintmax_t)VM_CNT_FETCH(v_swappgsout),
|
2017-04-17 14:57:26 -04:00
|
|
|
(uintmax_t)VM_CNT_FETCH(v_intr),
|
- Remove 'struct vmmeter' from 'struct pcpu', leaving only global vmmeter
in place. To do per-cpu stats, convert all fields that previously were
maintained in the vmmeters that sit in pcpus to counter(9).
- Since some vmmeter stats may be touched at very early stages of boot,
before we have set up UMA and we can do counter_u64_alloc(), provide an
early counter mechanism:
o Leave one spare uint64_t in struct pcpu, named pc_early_dummy_counter.
o Point counter(9) fields of vmmeter to pcpu[0].pc_early_dummy_counter,
so that at early stages of boot, before counters are allocated we already
point to a counter that can be safely written to.
o For sparc64 that required a whole dummy pcpu[MAXCPU] array.
Further related changes:
- Don't include vmmeter.h into pcpu.h.
- vm.stats.vm.v_swappgsout and vm.stats.vm.v_swappgsin changed to 64-bit,
to match kernel representation.
- struct vmmeter hidden under _KERNEL, and only vmstat(1) is an exclusion.
This is based on benno@'s 4-year old patch:
https://lists.freebsd.org/pipermail/freebsd-arch/2013-July/014471.html
Reviewed by: kib, gallatin, marius, lidl
Differential Revision: https://reviews.freebsd.org/D10156
2017-04-17 13:34:47 -04:00
|
|
|
(uintmax_t)VM_CNT_FETCH(v_swtch),
|
2003-04-16 15:46:26 -04:00
|
|
|
(long long)boottime.tv_sec);
|
2001-06-10 19:23:59 -04:00
|
|
|
return (0);
|
2000-09-09 07:44:58 -04:00
|
|
|
}
|
|
|
|
|
|
2011-08-01 15:12:15 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_doswaps(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
struct xswdev xsw;
|
|
|
|
|
uintmax_t total, used;
|
|
|
|
|
int n;
|
|
|
|
|
char devname[SPECNAMELEN + 1];
|
|
|
|
|
|
|
|
|
|
sbuf_printf(sb, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
|
|
|
|
|
for (n = 0; ; n++) {
|
|
|
|
|
if (swap_dev_info(n, &xsw, devname, sizeof(devname)) != 0)
|
|
|
|
|
break;
|
|
|
|
|
total = (uintmax_t)xsw.xsw_nblks * PAGE_SIZE / 1024;
|
|
|
|
|
used = (uintmax_t)xsw.xsw_used * PAGE_SIZE / 1024;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The space and not tab after the device name is on
|
|
|
|
|
* purpose. Linux does so.
|
|
|
|
|
*/
|
|
|
|
|
sbuf_printf(sb, "/dev/%-34s unknown\t\t%jd\t%jd\t-1\n",
|
|
|
|
|
devname, total, used);
|
|
|
|
|
}
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-11 17:55:40 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/uptime
|
|
|
|
|
*/
|
2001-06-10 19:23:59 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_douptime(PFS_FILL_ARGS)
|
2000-09-09 07:44:58 -04:00
|
|
|
{
|
2007-11-29 01:34:30 -05:00
|
|
|
long cp_time[CPUSTATES];
|
2000-09-09 07:44:58 -04:00
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
|
|
getmicrouptime(&tv);
|
2007-11-29 01:34:30 -05:00
|
|
|
read_cpu_time(cp_time);
|
2010-04-02 02:50:28 -04:00
|
|
|
sbuf_printf(sb, "%lld.%02ld %ld.%02lu\n",
|
2003-04-16 15:46:26 -04:00
|
|
|
(long long)tv.tv_sec, tv.tv_usec / 10000,
|
2010-04-02 02:50:28 -04:00
|
|
|
T2S(cp_time[CP_IDLE] / mp_ncpus),
|
|
|
|
|
T2CS(cp_time[CP_IDLE] / mp_ncpus) % 100);
|
2001-06-10 19:23:59 -04:00
|
|
|
return (0);
|
2000-09-09 07:44:58 -04:00
|
|
|
}
|
|
|
|
|
|
2007-03-01 20:10:26 -05: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 13:02:03 -04:00
|
|
|
#if 0
|
2007-03-01 20:10:26 -05: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 13:02:03 -04:00
|
|
|
#endif
|
2007-03-01 20:10:26 -05:00
|
|
|
sbuf_cat(sb, "des@freebsd.org");
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-11 17:55:40 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/version
|
|
|
|
|
*/
|
2001-06-10 19:23:59 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_doversion(PFS_FILL_ARGS)
|
2000-09-09 07:44:58 -04: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 11:12:27 -05:00
|
|
|
char osname[LINUX_MAX_UTSNAME];
|
|
|
|
|
char osrelease[LINUX_MAX_UTSNAME];
|
|
|
|
|
|
2003-03-13 17:45:43 -05:00
|
|
|
linux_get_osname(td, osname);
|
|
|
|
|
linux_get_osrelease(td, osrelease);
|
2007-03-01 20:10:26 -05: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 11:12:27 -05:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
return (0);
|
2000-04-19 23:54:27 -04:00
|
|
|
}
|
2000-09-09 07:44:58 -04:00
|
|
|
|
2001-06-11 17:55:40 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/loadavg
|
|
|
|
|
*/
|
2001-06-10 19:23:59 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_doloadavg(PFS_FILL_ARGS)
|
2001-05-19 01:54:26 -04:00
|
|
|
{
|
2007-04-15 13:02:03 -04:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_printf(sb,
|
2001-05-19 01:54:26 -04: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 19:00:35 -04:00
|
|
|
lastpid /* the last pid */
|
2001-05-19 01:54:26 -04:00
|
|
|
);
|
2001-06-10 19:23:59 -04:00
|
|
|
return (0);
|
2001-05-19 01:54:26 -04:00
|
|
|
}
|
|
|
|
|
|
2020-07-11 09:11:54 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_get_tty_nr(struct proc *p)
|
|
|
|
|
{
|
|
|
|
|
struct session *sp;
|
|
|
|
|
const char *ttyname;
|
|
|
|
|
int error, major, minor, nr;
|
|
|
|
|
|
|
|
|
|
PROC_LOCK_ASSERT(p, MA_OWNED);
|
|
|
|
|
sx_assert(&proctree_lock, SX_LOCKED);
|
|
|
|
|
|
|
|
|
|
if ((p->p_flag & P_CONTROLT) == 0)
|
|
|
|
|
return (-1);
|
|
|
|
|
|
|
|
|
|
sp = p->p_pgrp->pg_session;
|
|
|
|
|
if (sp == NULL)
|
|
|
|
|
return (-1);
|
|
|
|
|
|
|
|
|
|
ttyname = devtoname(sp->s_ttyp->t_dev);
|
|
|
|
|
error = linux_driver_get_major_minor(ttyname, &major, &minor);
|
|
|
|
|
if (error != 0)
|
|
|
|
|
return (-1);
|
|
|
|
|
|
|
|
|
|
nr = makedev(major, minor);
|
|
|
|
|
return (nr);
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-11 17:55:40 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/pid/stat
|
|
|
|
|
*/
|
2001-06-10 19:23:59 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_doprocstat(PFS_FILL_ARGS)
|
2000-10-25 18:12:59 -04:00
|
|
|
{
|
2000-12-13 15:22:24 -05:00
|
|
|
struct kinfo_proc kp;
|
2016-07-27 07:08:59 -04:00
|
|
|
struct timeval boottime;
|
2007-01-20 06:07:41 -05:00
|
|
|
char state;
|
|
|
|
|
static int ratelimit = 0;
|
2020-07-11 09:11:54 -04:00
|
|
|
int tty_nr;
|
2010-04-02 02:50:28 -04:00
|
|
|
vm_offset_t startcode, startdata;
|
2000-12-13 15:22:24 -05:00
|
|
|
|
2016-07-27 07:08:59 -04:00
|
|
|
getboottime(&boottime);
|
2014-08-29 23:10:55 -04:00
|
|
|
sx_slock(&proctree_lock);
|
2002-04-09 16:10:46 -04:00
|
|
|
PROC_LOCK(p);
|
2000-12-13 15:22:24 -05:00
|
|
|
fill_kinfo_proc(p, &kp);
|
2020-07-11 09:11:54 -04:00
|
|
|
tty_nr = linprocfs_get_tty_nr(p);
|
2014-08-29 23:10:55 -04:00
|
|
|
sx_sunlock(&proctree_lock);
|
2010-04-02 02:50:28 -04:00
|
|
|
if (p->p_vmspace) {
|
|
|
|
|
startcode = (vm_offset_t)p->p_vmspace->vm_taddr;
|
|
|
|
|
startdata = (vm_offset_t)p->p_vmspace->vm_daddr;
|
|
|
|
|
} else {
|
|
|
|
|
startcode = 0;
|
|
|
|
|
startdata = 0;
|
2016-04-10 19:07:00 -04:00
|
|
|
}
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_printf(sb, "%d", p->p_pid);
|
|
|
|
|
#define PS_ADD(name, fmt, arg) sbuf_printf(sb, " " fmt, arg)
|
2000-10-25 18:12:59 -04:00
|
|
|
PS_ADD("comm", "(%s)", p->p_comm);
|
2007-01-20 06:07:41 -05:00
|
|
|
if (kp.ki_stat > sizeof(linux_state)) {
|
|
|
|
|
state = 'R';
|
|
|
|
|
|
2007-01-20 06:31:14 -05:00
|
|
|
if (ratelimit == 0) {
|
2007-01-21 08:18:52 -05: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 06:31:14 -05:00
|
|
|
++ratelimit;
|
|
|
|
|
}
|
2007-01-20 06:07:41 -05:00
|
|
|
} else
|
|
|
|
|
state = linux_state[kp.ki_stat - 1];
|
|
|
|
|
PS_ADD("state", "%c", state);
|
2001-03-06 22:21:26 -05:00
|
|
|
PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0);
|
2000-10-25 18:12:59 -04:00
|
|
|
PS_ADD("pgrp", "%d", p->p_pgid);
|
|
|
|
|
PS_ADD("session", "%d", p->p_session->s_sid);
|
2002-02-23 06:12:57 -05:00
|
|
|
PROC_UNLOCK(p);
|
2020-07-11 09:11:54 -04:00
|
|
|
PS_ADD("tty", "%d", tty_nr);
|
2006-06-27 16:11:58 -04:00
|
|
|
PS_ADD("tpgid", "%d", kp.ki_tpgid);
|
2000-10-25 18:12:59 -04:00
|
|
|
PS_ADD("flags", "%u", 0); /* XXX */
|
2006-06-27 16:11:58 -04: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);
|
2010-04-02 02:50:28 -04:00
|
|
|
PS_ADD("utime", "%ld", TV2J(&kp.ki_rusage.ru_utime));
|
|
|
|
|
PS_ADD("stime", "%ld", TV2J(&kp.ki_rusage.ru_stime));
|
|
|
|
|
PS_ADD("cutime", "%ld", TV2J(&kp.ki_rusage_ch.ru_utime));
|
|
|
|
|
PS_ADD("cstime", "%ld", TV2J(&kp.ki_rusage_ch.ru_stime));
|
2006-06-27 16:11:58 -04:00
|
|
|
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 */
|
2010-04-02 02:50:28 -04:00
|
|
|
PS_ADD("starttime", "%lu", TV2J(&kp.ki_start) - TV2J(&boottime));
|
2006-06-27 16:11:58 -04:00
|
|
|
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);
|
2010-04-02 02:50:28 -04:00
|
|
|
PS_ADD("startcode", "%ju", (uintmax_t)startcode);
|
|
|
|
|
PS_ADD("endcode", "%ju", (uintmax_t)startdata);
|
2000-10-25 18:12:59 -04:00
|
|
|
PS_ADD("startstack", "%u", 0); /* XXX */
|
2006-06-27 16:11:58 -04: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 18:12:59 -04:00
|
|
|
PS_ADD("wchan", "%u", 0); /* XXX */
|
2006-06-27 16:11:58 -04:00
|
|
|
PS_ADD("nswap", "%lu", kp.ki_rusage.ru_nswap);
|
|
|
|
|
PS_ADD("cnswap", "%lu", kp.ki_rusage_ch.ru_nswap);
|
2000-12-09 08:25:54 -05:00
|
|
|
PS_ADD("exitsignal", "%d", 0); /* XXX */
|
2006-06-27 16:11:58 -04: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 18:12:59 -04:00
|
|
|
#undef PS_ADD
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_putc(sb, '\n');
|
2003-08-18 09:30:15 -04:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
return (0);
|
2000-10-25 18:12:59 -04:00
|
|
|
}
|
|
|
|
|
|
2003-09-09 04:19:06 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/pid/statm
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doprocstatm(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
struct kinfo_proc kp;
|
|
|
|
|
segsz_t lsize;
|
2003-09-22 12:05:11 -04:00
|
|
|
|
2014-08-29 23:10:55 -04:00
|
|
|
sx_slock(&proctree_lock);
|
2003-09-09 04:19:06 -04:00
|
|
|
PROC_LOCK(p);
|
|
|
|
|
fill_kinfo_proc(p, &kp);
|
|
|
|
|
PROC_UNLOCK(p);
|
2014-08-29 23:10:55 -04:00
|
|
|
sx_sunlock(&proctree_lock);
|
2003-09-09 04:19:06 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 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 17:55:40 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/pid/status
|
|
|
|
|
*/
|
2001-06-10 19:23:59 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_doprocstatus(PFS_FILL_ARGS)
|
2000-10-25 18:12:59 -04:00
|
|
|
{
|
2000-12-13 15:22:24 -05:00
|
|
|
struct kinfo_proc kp;
|
2000-10-25 18:12:59 -04:00
|
|
|
char *state;
|
2000-12-09 08:25:54 -05: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 13:26:22 -04: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 16:36:02 -04:00
|
|
|
struct sigacts *ps;
|
2015-05-24 13:48:34 -04:00
|
|
|
l_sigset_t siglist, sigignore, sigcatch;
|
2001-03-11 22:16:56 -05:00
|
|
|
int i;
|
2000-10-25 18:12:59 -04:00
|
|
|
|
2014-08-29 23:10:55 -04:00
|
|
|
sx_slock(&proctree_lock);
|
2003-04-17 17:58:45 -04: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 13:26:22 -04:00
|
|
|
td2 = FIRST_THREAD_IN_PROC(p); /* XXXKSE pretend only one thread */
|
|
|
|
|
|
|
|
|
|
if (P_SHOULDSTOP(p)) {
|
|
|
|
|
state = "T (stopped)";
|
|
|
|
|
} else {
|
|
|
|
|
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 04:13:56 -04: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 13:26:22 -04: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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-10-25 18:12:59 -04:00
|
|
|
|
2000-12-13 15:22:24 -05:00
|
|
|
fill_kinfo_proc(p, &kp);
|
2014-08-29 23:10:55 -04:00
|
|
|
sx_sunlock(&proctree_lock);
|
|
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_printf(sb, "Name:\t%s\n", p->p_comm); /* XXX escape */
|
2001-06-10 20:17:59 -04:00
|
|
|
sbuf_printf(sb, "State:\t%s\n", state);
|
2000-10-25 18:12:59 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Credentials
|
|
|
|
|
*/
|
2019-09-03 12:33:02 -04:00
|
|
|
sbuf_printf(sb, "Tgid:\t%d\n", p->p_pid);
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_printf(sb, "Pid:\t%d\n", p->p_pid);
|
2018-06-15 09:56:58 -04:00
|
|
|
sbuf_printf(sb, "PPid:\t%d\n", kp.ki_ppid );
|
|
|
|
|
sbuf_printf(sb, "TracerPid:\t%d\n", kp.ki_tracer );
|
2001-06-10 20:17:59 -04: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 19:23:59 -04:00
|
|
|
sbuf_cat(sb, "Groups:\t");
|
2000-10-25 18:12:59 -04:00
|
|
|
for (i = 0; i < p->p_ucred->cr_ngroups; i++)
|
2001-06-10 20:17:59 -04:00
|
|
|
sbuf_printf(sb, "%d ", p->p_ucred->cr_groups[i]);
|
2001-01-23 17:13:07 -05:00
|
|
|
PROC_UNLOCK(p);
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_putc(sb, '\n');
|
2003-08-18 09:30:15 -04:00
|
|
|
|
2000-10-25 18:12:59 -04:00
|
|
|
/*
|
|
|
|
|
* Memory
|
2000-12-09 08:25:54 -05: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 18:12:59 -04:00
|
|
|
*/
|
2003-04-16 15:46:26 -04:00
|
|
|
sbuf_printf(sb, "VmSize:\t%8ju kB\n", B2K((uintmax_t)kp.ki_size));
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_printf(sb, "VmLck:\t%8u kB\n", P2K(0)); /* XXX */
|
2010-04-02 02:50:28 -04:00
|
|
|
sbuf_printf(sb, "VmRSS:\t%8ju kB\n", P2K((uintmax_t)kp.ki_rssize));
|
2003-04-16 15:46:26 -04:00
|
|
|
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 15:22:24 -05:00
|
|
|
lsize = B2P(kp.ki_size) - kp.ki_dsize -
|
|
|
|
|
kp.ki_ssize - kp.ki_tsize - 1;
|
2003-04-16 15:46:26 -04:00
|
|
|
sbuf_printf(sb, "VmLib:\t%8ju kB\n", P2K((uintmax_t)lsize));
|
2000-10-25 18:12:59 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Signal masks
|
|
|
|
|
*/
|
2001-01-23 17:13:07 -05:00
|
|
|
PROC_LOCK(p);
|
2015-05-24 13:48:34 -04:00
|
|
|
bsd_to_linux_sigset(&p->p_siglist, &siglist);
|
- 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 16:36:02 -04:00
|
|
|
ps = p->p_sigacts;
|
|
|
|
|
mtx_lock(&ps->ps_mtx);
|
2015-05-24 13:48:34 -04:00
|
|
|
bsd_to_linux_sigset(&ps->ps_sigignore, &sigignore);
|
|
|
|
|
bsd_to_linux_sigset(&ps->ps_sigcatch, &sigcatch);
|
- 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 16:36:02 -04:00
|
|
|
mtx_unlock(&ps->ps_mtx);
|
2001-01-23 17:13:07 -05:00
|
|
|
PROC_UNLOCK(p);
|
2003-08-18 09:30:15 -04:00
|
|
|
|
2015-05-24 13:48:34 -04:00
|
|
|
sbuf_printf(sb, "SigPnd:\t%016jx\n", siglist.__mask);
|
|
|
|
|
/*
|
|
|
|
|
* XXX. SigBlk - target thread's signal mask, td_sigmask.
|
|
|
|
|
* To implement SigBlk pseudofs should support proc/tid dir entries.
|
|
|
|
|
*/
|
|
|
|
|
sbuf_printf(sb, "SigBlk:\t%016x\n", 0);
|
|
|
|
|
sbuf_printf(sb, "SigIgn:\t%016jx\n", sigignore.__mask);
|
|
|
|
|
sbuf_printf(sb, "SigCgt:\t%016jx\n", sigcatch.__mask);
|
|
|
|
|
|
2000-10-25 18:12:59 -04: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 19:23:59 -04: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 09:30:15 -04:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
return (0);
|
2001-03-11 22:16:56 -05:00
|
|
|
}
|
|
|
|
|
|
2003-09-09 04:19:06 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/pid/cwd
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doproccwd(PFS_FILL_ARGS)
|
|
|
|
|
{
|
2020-03-01 16:53:46 -05:00
|
|
|
struct pwd *pwd;
|
2003-09-09 04:19:06 -04:00
|
|
|
char *fullpath = "unknown";
|
|
|
|
|
char *freepath = NULL;
|
|
|
|
|
|
2020-03-01 16:53:46 -05:00
|
|
|
pwd = pwd_hold(td);
|
2020-08-24 04:57:02 -04:00
|
|
|
vn_fullpath(pwd->pwd_cdir, &fullpath, &freepath);
|
2003-09-09 04:19:06 -04:00
|
|
|
sbuf_printf(sb, "%s", fullpath);
|
|
|
|
|
if (freepath)
|
|
|
|
|
free(freepath, M_TEMP);
|
2020-03-01 16:53:46 -05:00
|
|
|
pwd_drop(pwd);
|
2003-09-09 04:19:06 -04:00
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Filler function for proc/pid/root
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doprocroot(PFS_FILL_ARGS)
|
|
|
|
|
{
|
2020-03-01 16:53:46 -05:00
|
|
|
struct pwd *pwd;
|
2015-07-11 12:44:28 -04:00
|
|
|
struct vnode *vp;
|
2003-09-09 04:19:06 -04:00
|
|
|
char *fullpath = "unknown";
|
|
|
|
|
char *freepath = NULL;
|
|
|
|
|
|
2020-03-01 16:53:46 -05:00
|
|
|
pwd = pwd_hold(td);
|
|
|
|
|
vp = jailed(p->p_ucred) ? pwd->pwd_jdir : pwd->pwd_rdir;
|
2020-08-24 04:57:02 -04:00
|
|
|
vn_fullpath(vp, &fullpath, &freepath);
|
2003-09-09 04:19:06 -04:00
|
|
|
sbuf_printf(sb, "%s", fullpath);
|
|
|
|
|
if (freepath)
|
|
|
|
|
free(freepath, M_TEMP);
|
2020-03-01 16:53:46 -05:00
|
|
|
pwd_drop(pwd);
|
2003-09-09 04:19:06 -04:00
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-28 07:32:17 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/pid/cmdline
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doproccmdline(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
PROC_LOCK(p);
|
|
|
|
|
if ((ret = p_cansee(td, p)) != 0) {
|
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
return (ret);
|
|
|
|
|
}
|
2011-06-17 03:30:56 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Mimic linux behavior and pass only processes with usermode
|
|
|
|
|
* address space as valid. Return zero silently otherwize.
|
|
|
|
|
*/
|
|
|
|
|
if (p->p_vmspace == &vmspace0) {
|
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
2010-09-28 07:32:17 -04:00
|
|
|
if (p->p_args != NULL) {
|
|
|
|
|
sbuf_bcpy(sb, p->p_args->ar_args, p->p_args->ar_length);
|
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
2011-11-22 15:45:11 -05:00
|
|
|
|
|
|
|
|
if ((p->p_flag & P_SYSTEM) != 0) {
|
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-28 07:32:17 -04:00
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
|
2012-01-15 13:47:24 -05:00
|
|
|
ret = proc_getargv(td, p, sb);
|
2010-09-28 07:32:17 -04:00
|
|
|
return (ret);
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-10 17:29:12 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/pid/environ
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doprocenviron(PFS_FILL_ARGS)
|
|
|
|
|
{
|
2011-06-17 03:30:56 -04:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Mimic linux behavior and pass only processes with usermode
|
|
|
|
|
* address space as valid. Return zero silently otherwize.
|
|
|
|
|
*/
|
2015-05-24 13:53:48 -04:00
|
|
|
if (p->p_vmspace == &vmspace0)
|
2011-11-22 15:45:11 -05:00
|
|
|
return (0);
|
|
|
|
|
|
2015-05-24 13:53:48 -04:00
|
|
|
return (proc_getenvv(td, p, sb));
|
2003-06-10 17:29:12 -04:00
|
|
|
}
|
|
|
|
|
|
2015-05-24 11:42:36 -04:00
|
|
|
static char l32_map_str[] = "%08lx-%08lx %s%s%s%s %08lx %02x:%02x %lu%s%s\n";
|
|
|
|
|
static char l64_map_str[] = "%016lx-%016lx %s%s%s%s %08lx %02x:%02x %lu%s%s\n";
|
2015-05-24 13:44:42 -04:00
|
|
|
static char vdso_str[] = " [vdso]";
|
|
|
|
|
static char stack_str[] = " [stack]";
|
2015-05-24 11:42:36 -04:00
|
|
|
|
2003-06-10 17:29:12 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/pid/maps
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doprocmaps(PFS_FILL_ARGS)
|
|
|
|
|
{
|
2008-12-12 07:12:36 -05:00
|
|
|
struct vmspace *vm;
|
|
|
|
|
vm_map_t map;
|
2008-12-08 07:34:52 -05:00
|
|
|
vm_map_entry_t entry, tmp_entry;
|
2003-10-20 00:10:20 -04:00
|
|
|
vm_object_t obj, tobj, lobj;
|
2008-12-08 07:34:52 -05:00
|
|
|
vm_offset_t e_start, e_end;
|
2020-01-08 11:57:08 -05:00
|
|
|
vm_ooffset_t off;
|
2008-12-08 07:34:52 -05:00
|
|
|
vm_prot_t e_prot;
|
|
|
|
|
unsigned int last_timestamp;
|
2003-10-20 00:10:20 -04:00
|
|
|
char *name = "", *freename = NULL;
|
2015-05-24 11:42:36 -04:00
|
|
|
const char *l_map_str;
|
2003-10-20 00:10:20 -04:00
|
|
|
ino_t ino;
|
|
|
|
|
int ref_count, shadow_count, flags;
|
|
|
|
|
int error;
|
2004-11-10 02:25:37 -05:00
|
|
|
struct vnode *vp;
|
|
|
|
|
struct vattr vat;
|
2020-01-08 11:57:08 -05:00
|
|
|
bool private;
|
2007-04-15 13:02:03 -04:00
|
|
|
|
2003-10-19 10:13:51 -04:00
|
|
|
PROC_LOCK(p);
|
|
|
|
|
error = p_candebug(td, p);
|
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
if (error)
|
|
|
|
|
return (error);
|
2007-04-15 13:02:03 -04:00
|
|
|
|
2003-10-19 10:13:51 -04:00
|
|
|
if (uio->uio_rw != UIO_READ)
|
|
|
|
|
return (EOPNOTSUPP);
|
2007-04-15 13:02:03 -04:00
|
|
|
|
2003-10-19 10:13:51 -04:00
|
|
|
error = 0;
|
2008-12-12 07:12:36 -05:00
|
|
|
vm = vmspace_acquire_ref(p);
|
|
|
|
|
if (vm == NULL)
|
|
|
|
|
return (ESRCH);
|
2015-05-24 13:44:42 -04:00
|
|
|
|
|
|
|
|
if (SV_CURPROC_FLAG(SV_LP64))
|
|
|
|
|
l_map_str = l64_map_str;
|
|
|
|
|
else
|
|
|
|
|
l_map_str = l32_map_str;
|
2008-12-12 07:12:36 -05:00
|
|
|
map = &vm->vm_map;
|
2007-04-30 23:09:57 -04:00
|
|
|
vm_map_lock_read(map);
|
2019-10-08 03:14:21 -04:00
|
|
|
VM_MAP_ENTRY_FOREACH(entry, map) {
|
2003-10-20 00:10:20 -04:00
|
|
|
name = "";
|
|
|
|
|
freename = NULL;
|
2003-10-19 10:13:51 -04:00
|
|
|
if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
|
|
|
|
|
continue;
|
2008-12-08 07:34:52 -05:00
|
|
|
e_prot = entry->protection;
|
|
|
|
|
e_start = entry->start;
|
|
|
|
|
e_end = entry->end;
|
2003-10-19 10:13:51 -04:00
|
|
|
obj = entry->object.vm_object;
|
2020-01-08 11:57:08 -05:00
|
|
|
off = entry->offset;
|
|
|
|
|
for (lobj = tobj = obj; tobj != NULL;
|
|
|
|
|
lobj = tobj, tobj = tobj->backing_object) {
|
2013-06-05 13:00:10 -04:00
|
|
|
VM_OBJECT_RLOCK(tobj);
|
2020-01-08 11:57:08 -05:00
|
|
|
off += lobj->backing_object_offset;
|
2007-04-30 23:09:57 -04:00
|
|
|
if (lobj != obj)
|
2013-06-05 13:00:10 -04:00
|
|
|
VM_OBJECT_RUNLOCK(lobj);
|
2007-04-30 23:09:57 -04:00
|
|
|
}
|
2020-01-08 11:57:08 -05:00
|
|
|
private = (entry->eflags & MAP_ENTRY_COW) != 0 || obj == NULL ||
|
|
|
|
|
(obj->flags & OBJ_ANON) != 0;
|
2008-12-08 07:34:52 -05:00
|
|
|
last_timestamp = map->timestamp;
|
|
|
|
|
vm_map_unlock_read(map);
|
2003-10-19 10:13:51 -04:00
|
|
|
ino = 0;
|
|
|
|
|
if (lobj) {
|
2015-06-02 14:37:04 -04:00
|
|
|
vp = vm_object_vnode(lobj);
|
|
|
|
|
if (vp != NULL)
|
|
|
|
|
vref(vp);
|
2007-04-30 23:09:57 -04:00
|
|
|
if (lobj != obj)
|
2013-06-05 13:00:10 -04:00
|
|
|
VM_OBJECT_RUNLOCK(lobj);
|
2003-10-19 10:13:51 -04:00
|
|
|
flags = obj->flags;
|
|
|
|
|
ref_count = obj->ref_count;
|
|
|
|
|
shadow_count = obj->shadow_count;
|
2013-06-05 13:00:10 -04:00
|
|
|
VM_OBJECT_RUNLOCK(obj);
|
2015-06-02 14:37:04 -04:00
|
|
|
if (vp != NULL) {
|
2020-08-24 04:57:02 -04:00
|
|
|
vn_fullpath(vp, &name, &freename);
|
2008-01-09 20:10:58 -05:00
|
|
|
vn_lock(vp, LK_SHARED | LK_RETRY);
|
2008-08-28 11:23:18 -04:00
|
|
|
VOP_GETATTR(vp, &vat, td->td_ucred);
|
2006-08-08 08:29:26 -04:00
|
|
|
ino = vat.va_fileid;
|
|
|
|
|
vput(vp);
|
2015-05-24 13:44:42 -04:00
|
|
|
} else if (SV_PROC_ABI(p) == SV_ABI_LINUX) {
|
|
|
|
|
if (e_start == p->p_sysent->sv_shared_page_base)
|
|
|
|
|
name = vdso_str;
|
|
|
|
|
if (e_end == p->p_sysent->sv_usrstack)
|
|
|
|
|
name = stack_str;
|
2006-08-08 08:29:26 -04:00
|
|
|
}
|
2003-10-19 10:13:51 -04:00
|
|
|
} else {
|
|
|
|
|
flags = 0;
|
|
|
|
|
ref_count = 0;
|
|
|
|
|
shadow_count = 0;
|
|
|
|
|
}
|
2007-04-15 13:02:03 -04:00
|
|
|
|
2003-10-19 10:13:51 -04:00
|
|
|
/*
|
2007-04-15 13:02:03 -04:00
|
|
|
* format:
|
2003-10-19 10:13:51 -04:00
|
|
|
* start, end, access, offset, major, minor, inode, name.
|
|
|
|
|
*/
|
2015-05-24 11:42:36 -04:00
|
|
|
error = sbuf_printf(sb, l_map_str,
|
2008-12-08 07:34:52 -05: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":"-",
|
2020-01-08 11:57:08 -05:00
|
|
|
private ? "p" : "s",
|
2003-10-20 00:10:20 -04:00
|
|
|
(u_long)off,
|
2003-10-19 10:13:51 -04:00
|
|
|
0,
|
|
|
|
|
0,
|
2003-10-20 00:10:20 -04:00
|
|
|
(u_long)ino,
|
2003-10-19 10:13:51 -04:00
|
|
|
*name ? " " : "",
|
|
|
|
|
name
|
|
|
|
|
);
|
|
|
|
|
if (freename)
|
|
|
|
|
free(freename, M_TEMP);
|
2008-12-10 11:11:09 -05:00
|
|
|
vm_map_lock_read(map);
|
2008-10-04 10:08:16 -04:00
|
|
|
if (error == -1) {
|
|
|
|
|
error = 0;
|
2003-10-19 10:13:51 -04:00
|
|
|
break;
|
2007-04-30 23:09:57 -04:00
|
|
|
}
|
2008-12-29 07:45:11 -05:00
|
|
|
if (last_timestamp != map->timestamp) {
|
2008-12-08 07:34:52 -05: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 10:13:51 -04:00
|
|
|
}
|
2007-04-30 23:09:57 -04:00
|
|
|
vm_map_unlock_read(map);
|
2008-12-12 07:12:36 -05:00
|
|
|
vmspace_free(vm);
|
2007-04-15 13:02:03 -04:00
|
|
|
|
2003-10-19 10:13:51 -04:00
|
|
|
return (error);
|
2007-04-15 13:02:03 -04:00
|
|
|
}
|
|
|
|
|
|
2015-05-24 11:51:18 -04:00
|
|
|
/*
|
|
|
|
|
* Criteria for interface name translation
|
|
|
|
|
*/
|
|
|
|
|
#define IFP_IS_ETH(ifp) (ifp->if_type == IFT_ETHER)
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen)
|
|
|
|
|
{
|
|
|
|
|
struct ifnet *ifscan;
|
|
|
|
|
int ethno;
|
|
|
|
|
|
|
|
|
|
IFNET_RLOCK_ASSERT();
|
|
|
|
|
|
|
|
|
|
/* Short-circuit non ethernet interfaces */
|
|
|
|
|
if (!IFP_IS_ETH(ifp))
|
|
|
|
|
return (strlcpy(buffer, ifp->if_xname, buflen));
|
|
|
|
|
|
|
|
|
|
/* Determine the (relative) unit number for ethernet interfaces */
|
|
|
|
|
ethno = 0;
|
2018-05-23 17:02:14 -04:00
|
|
|
CK_STAILQ_FOREACH(ifscan, &V_ifnet, if_link) {
|
2015-05-24 11:51:18 -04:00
|
|
|
if (ifscan == ifp)
|
|
|
|
|
return (snprintf(buffer, buflen, "eth%d", ethno));
|
|
|
|
|
if (IFP_IS_ETH(ifscan))
|
|
|
|
|
ethno++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-11 17:55:40 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/net/dev
|
|
|
|
|
*/
|
2001-06-10 19:23:59 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_donetdev(PFS_FILL_ARGS)
|
2001-03-11 22:16:56 -05:00
|
|
|
{
|
2001-10-18 21:45:03 -04:00
|
|
|
char ifname[16]; /* XXX LINUX_IFNAMSIZ */
|
2001-03-11 22:16:56 -05:00
|
|
|
struct ifnet *ifp;
|
|
|
|
|
|
2011-01-30 19:09:52 -05:00
|
|
|
sbuf_printf(sb, "%6s|%58s|%s\n"
|
|
|
|
|
"%6s|%58s|%58s\n",
|
|
|
|
|
"Inter-", " Receive", " Transmit",
|
|
|
|
|
" face",
|
|
|
|
|
"bytes packets errs drop fifo frame compressed multicast",
|
|
|
|
|
"bytes packets errs drop fifo colls carrier compressed");
|
2001-03-11 22:16:56 -05:00
|
|
|
|
2009-08-28 18:51:07 -04:00
|
|
|
CURVNET_SET(TD_TO_VNET(curthread));
|
2002-12-22 00:35:03 -05:00
|
|
|
IFNET_RLOCK();
|
2018-05-23 17:02:14 -04:00
|
|
|
CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) {
|
2001-10-18 21:45:03 -04:00
|
|
|
linux_ifname(ifp, ifname, sizeof ifname);
|
2011-01-30 19:09:52 -05:00
|
|
|
sbuf_printf(sb, "%6.6s: ", ifname);
|
2014-03-12 23:42:24 -04:00
|
|
|
sbuf_printf(sb, "%7ju %7ju %4ju %4ju %4lu %5lu %10lu %9ju ",
|
2014-09-18 12:44:28 -04:00
|
|
|
(uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IBYTES),
|
|
|
|
|
(uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IPACKETS),
|
|
|
|
|
(uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IERRORS),
|
|
|
|
|
(uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IQDROPS),
|
|
|
|
|
/* rx_missed_errors */
|
2014-03-12 23:42:24 -04:00
|
|
|
0UL, /* rx_fifo_errors */
|
|
|
|
|
0UL, /* rx_length_errors +
|
|
|
|
|
* rx_over_errors +
|
|
|
|
|
* rx_crc_errors +
|
|
|
|
|
* rx_frame_errors */
|
|
|
|
|
0UL, /* rx_compressed */
|
2014-09-18 12:44:28 -04:00
|
|
|
(uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IMCASTS));
|
|
|
|
|
/* XXX-BZ rx only? */
|
2014-09-18 16:29:17 -04:00
|
|
|
sbuf_printf(sb, "%8ju %7ju %4ju %4ju %4lu %5ju %7lu %10lu\n",
|
2014-09-18 12:44:28 -04:00
|
|
|
(uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OBYTES),
|
|
|
|
|
(uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS),
|
|
|
|
|
(uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OERRORS),
|
|
|
|
|
(uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OQDROPS),
|
2014-03-12 23:42:24 -04:00
|
|
|
0UL, /* tx_fifo_errors */
|
2014-09-18 12:44:28 -04:00
|
|
|
(uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_COLLISIONS),
|
2014-03-12 23:42:24 -04:00
|
|
|
0UL, /* tx_carrier_errors +
|
|
|
|
|
* tx_aborted_errors +
|
|
|
|
|
* tx_window_errors +
|
|
|
|
|
* tx_heartbeat_errors*/
|
|
|
|
|
0UL); /* tx_compressed */
|
2001-03-11 22:16:56 -05:00
|
|
|
}
|
2002-12-22 00:35:03 -05:00
|
|
|
IFNET_RUNLOCK();
|
2009-08-28 18:51:07 -04:00
|
|
|
CURVNET_RESTORE();
|
2003-08-18 09:30:15 -04:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
return (0);
|
2001-03-11 22:16:56 -05:00
|
|
|
}
|
|
|
|
|
|
2007-03-01 20:10:26 -05: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 13:02:03 -04:00
|
|
|
|
2007-03-01 20:10:26 -05:00
|
|
|
linprocfs_osbuild(td, sb);
|
|
|
|
|
sbuf_cat(sb, "\n");
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-18 06:56:04 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/sys/kernel/msgmax
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_domsgmax(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
sbuf_printf(sb, "%d\n", msginfo.msgmax);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-27 16:10:55 -05:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/sys/kernel/msgmni
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_domsgmni(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
2007-03-30 13:56:44 -04:00
|
|
|
sbuf_printf(sb, "%d\n", msginfo.msgmni);
|
2006-11-27 16:10:55 -05:00
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-18 06:56:04 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/sys/kernel/msgmnb
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_domsgmnb(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
sbuf_printf(sb, "%d\n", msginfo.msgmnb);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-08 12:55:27 -04:00
|
|
|
/*
|
2006-10-11 16:32:46 -04:00
|
|
|
* Filler function for proc/sys/kernel/pid_max
|
2006-10-08 12:55:27 -04:00
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_dopid_max(PFS_FILL_ARGS)
|
|
|
|
|
{
|
2006-10-29 04:50:55 -05:00
|
|
|
|
2006-10-08 12:55:27 -04:00
|
|
|
sbuf_printf(sb, "%i\n", PID_MAX);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-27 16:10:55 -05:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/sys/kernel/sem
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_dosem(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
2007-03-30 13:56:44 -04:00
|
|
|
sbuf_printf(sb, "%d %d %d %d\n", seminfo.semmsl, seminfo.semmns,
|
|
|
|
|
seminfo.semopm, seminfo.semmni);
|
2006-11-27 16:10:55 -05:00
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-18 06:56:04 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/sys/kernel/shmall
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doshmall(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
sbuf_printf(sb, "%lu\n", shminfo.shmall);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Filler function for proc/sys/kernel/shmmax
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doshmmax(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
sbuf_printf(sb, "%lu\n", shminfo.shmmax);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Filler function for proc/sys/kernel/shmmni
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doshmmni(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
sbuf_printf(sb, "%lu\n", shminfo.shmmni);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-04 07:26:03 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/sys/kernel/tainted
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_dotainted(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
sbuf_printf(sb, "0\n");
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-15 11:22:27 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/sys/vm/min_free_kbytes
|
|
|
|
|
*
|
|
|
|
|
* This mirrors the approach in illumos to return zero for reads. Effectively,
|
|
|
|
|
* it says, no memory is kept in reserve for "atomic allocations". This class
|
|
|
|
|
* of allocation can be used at times when a thread cannot be suspended.
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_dominfree(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
sbuf_printf(sb, "%d\n", 0);
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-05 12:10:45 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/scsi/device_info
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doscsidevinfo(PFS_FILL_ARGS)
|
|
|
|
|
{
|
2007-04-15 13:02:03 -04:00
|
|
|
|
2006-05-05 12:10:45 -04:00
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Filler function for proc/scsi/scsi
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doscsiscsi(PFS_FILL_ARGS)
|
|
|
|
|
{
|
2007-04-15 13:02:03 -04:00
|
|
|
|
2006-05-05 12:10:45 -04:00
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-11 17:55:40 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/devices
|
|
|
|
|
*/
|
2001-06-10 19:23:59 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_dodevices(PFS_FILL_ARGS)
|
2001-03-11 22:16:56 -05:00
|
|
|
{
|
2006-05-05 12:10:45 -04:00
|
|
|
char *char_devices;
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_printf(sb, "Character devices:\n");
|
2001-03-11 22:16:56 -05:00
|
|
|
|
2006-05-05 12:10:45 -04:00
|
|
|
char_devices = linux_get_char_devices();
|
|
|
|
|
sbuf_printf(sb, "%s", char_devices);
|
|
|
|
|
linux_free_get_char_devices(char_devices);
|
2001-03-11 22:16:56 -05:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_printf(sb, "\nBlock devices:\n");
|
2003-08-18 09:30:15 -04:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
return (0);
|
2001-03-11 22:16:56 -05:00
|
|
|
}
|
|
|
|
|
|
2001-06-11 17:55:40 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/cmdline
|
|
|
|
|
*/
|
2001-06-10 19:23:59 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_docmdline(PFS_FILL_ARGS)
|
2001-03-11 22:16:56 -05:00
|
|
|
{
|
2007-04-15 13:02:03 -04:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
sbuf_printf(sb, "BOOT_IMAGE=%s", kernelname);
|
|
|
|
|
sbuf_printf(sb, " ro root=302\n");
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-23 17:49:33 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/filesystems
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_dofilesystems(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
struct vfsconf *vfsp;
|
|
|
|
|
|
2016-06-12 07:13:38 -04:00
|
|
|
vfsconf_slock();
|
2010-03-23 17:49:33 -04:00
|
|
|
TAILQ_FOREACH(vfsp, &vfsconf, vfc_list) {
|
|
|
|
|
if (vfsp->vfc_flags & VFCF_SYNTHETIC)
|
|
|
|
|
sbuf_printf(sb, "nodev");
|
|
|
|
|
sbuf_printf(sb, "\t%s\n", vfsp->vfc_name);
|
|
|
|
|
}
|
2016-06-12 07:13:38 -04:00
|
|
|
vfsconf_sunlock();
|
2010-03-23 17:49:33 -04:00
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-25 09:24:24 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/modules
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_domodules(PFS_FILL_ARGS)
|
|
|
|
|
{
|
2019-12-29 10:46:59 -05:00
|
|
|
#if 0
|
2001-09-25 09:24:24 -04:00
|
|
|
struct linker_file *lf;
|
2003-08-18 09:30:15 -04:00
|
|
|
|
2001-09-25 09:24:24 -04:00
|
|
|
TAILQ_FOREACH(lf, &linker_files, link) {
|
|
|
|
|
sbuf_printf(sb, "%-20s%8lu%4d\n", lf->filename,
|
|
|
|
|
(unsigned long)lf->size, lf->refs);
|
|
|
|
|
}
|
2019-12-29 10:46:59 -05:00
|
|
|
#endif
|
2001-09-25 09:24:24 -04:00
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-07 05:43:45 -05:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/pid/fd
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_dofdescfs(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (p == curproc)
|
|
|
|
|
sbuf_printf(sb, "/dev/fd");
|
|
|
|
|
else
|
|
|
|
|
sbuf_printf(sb, "unknown");
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-21 09:56:05 -05:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/pid/limits
|
|
|
|
|
*/
|
2016-04-10 03:11:29 -04:00
|
|
|
static const struct linux_rlimit_ident {
|
2016-02-21 09:56:05 -05:00
|
|
|
const char *desc;
|
|
|
|
|
const char *unit;
|
2016-04-10 03:11:29 -04:00
|
|
|
unsigned int rlim_id;
|
|
|
|
|
} linux_rlimits_ident[] = {
|
|
|
|
|
{ "Max cpu time", "seconds", RLIMIT_CPU },
|
|
|
|
|
{ "Max file size", "bytes", RLIMIT_FSIZE },
|
|
|
|
|
{ "Max data size", "bytes", RLIMIT_DATA },
|
|
|
|
|
{ "Max stack size", "bytes", RLIMIT_STACK },
|
|
|
|
|
{ "Max core file size", "bytes", RLIMIT_CORE },
|
|
|
|
|
{ "Max resident set", "bytes", RLIMIT_RSS },
|
|
|
|
|
{ "Max processes", "processes", RLIMIT_NPROC },
|
|
|
|
|
{ "Max open files", "files", RLIMIT_NOFILE },
|
|
|
|
|
{ "Max locked memory", "bytes", RLIMIT_MEMLOCK },
|
|
|
|
|
{ "Max address space", "bytes", RLIMIT_AS },
|
|
|
|
|
{ "Max file locks", "locks", LINUX_RLIMIT_LOCKS },
|
|
|
|
|
{ "Max pending signals", "signals", LINUX_RLIMIT_SIGPENDING },
|
|
|
|
|
{ "Max msgqueue size", "bytes", LINUX_RLIMIT_MSGQUEUE },
|
|
|
|
|
{ "Max nice priority", "", LINUX_RLIMIT_NICE },
|
|
|
|
|
{ "Max realtime priority", "", LINUX_RLIMIT_RTPRIO },
|
|
|
|
|
{ "Max realtime timeout", "us", LINUX_RLIMIT_RTTIME },
|
2016-02-21 09:56:05 -05:00
|
|
|
{ 0, 0, 0 }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doproclimits(PFS_FILL_ARGS)
|
|
|
|
|
{
|
2016-04-10 03:11:29 -04:00
|
|
|
const struct linux_rlimit_ident *li;
|
|
|
|
|
struct plimit *limp;
|
|
|
|
|
struct rlimit rl;
|
|
|
|
|
ssize_t size;
|
|
|
|
|
int res, error;
|
2016-02-21 09:56:05 -05:00
|
|
|
|
2016-04-19 21:03:06 -04:00
|
|
|
error = 0;
|
|
|
|
|
|
2016-04-10 03:11:29 -04:00
|
|
|
PROC_LOCK(p);
|
|
|
|
|
limp = lim_hold(p->p_limit);
|
|
|
|
|
PROC_UNLOCK(p);
|
|
|
|
|
size = sizeof(res);
|
|
|
|
|
sbuf_printf(sb, "%-26s%-21s%-21s%-21s\n", "Limit", "Soft Limit",
|
2016-02-21 09:56:05 -05:00
|
|
|
"Hard Limit", "Units");
|
2016-04-10 03:11:29 -04:00
|
|
|
for (li = linux_rlimits_ident; li->desc != NULL; ++li) {
|
|
|
|
|
switch (li->rlim_id)
|
|
|
|
|
{
|
|
|
|
|
case LINUX_RLIMIT_LOCKS:
|
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
case LINUX_RLIMIT_RTTIME:
|
|
|
|
|
rl.rlim_cur = RLIM_INFINITY;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_RLIMIT_SIGPENDING:
|
|
|
|
|
error = kernel_sysctlbyname(td,
|
|
|
|
|
"kern.sigqueue.max_pending_per_proc",
|
|
|
|
|
&res, &size, 0, 0, 0, 0);
|
|
|
|
|
if (error != 0)
|
2016-04-19 21:00:13 -04:00
|
|
|
goto out;
|
2016-04-10 03:11:29 -04:00
|
|
|
rl.rlim_cur = res;
|
|
|
|
|
rl.rlim_max = res;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_RLIMIT_MSGQUEUE:
|
|
|
|
|
error = kernel_sysctlbyname(td,
|
|
|
|
|
"kern.ipc.msgmnb", &res, &size, 0, 0, 0, 0);
|
|
|
|
|
if (error != 0)
|
2016-04-19 21:00:13 -04:00
|
|
|
goto out;
|
2016-04-10 03:11:29 -04:00
|
|
|
rl.rlim_cur = res;
|
|
|
|
|
rl.rlim_max = res;
|
|
|
|
|
break;
|
|
|
|
|
case LINUX_RLIMIT_NICE:
|
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
case LINUX_RLIMIT_RTPRIO:
|
|
|
|
|
rl.rlim_cur = 0;
|
|
|
|
|
rl.rlim_max = 0;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
rl = limp->pl_rlimit[li->rlim_id];
|
|
|
|
|
break;
|
2016-02-21 09:56:05 -05:00
|
|
|
}
|
2016-04-10 03:11:29 -04:00
|
|
|
if (rl.rlim_cur == RLIM_INFINITY)
|
2016-02-21 09:56:05 -05:00
|
|
|
sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n",
|
|
|
|
|
li->desc, "unlimited", "unlimited", li->unit);
|
|
|
|
|
else
|
2016-04-10 03:11:29 -04:00
|
|
|
sbuf_printf(sb, "%-26s%-21llu%-21llu%-10s\n",
|
|
|
|
|
li->desc, (unsigned long long)rl.rlim_cur,
|
|
|
|
|
(unsigned long long)rl.rlim_max, li->unit);
|
2016-02-21 09:56:05 -05:00
|
|
|
}
|
2016-04-19 21:00:13 -04:00
|
|
|
out:
|
2016-04-10 03:11:29 -04:00
|
|
|
lim_free(limp);
|
|
|
|
|
return (error);
|
2016-02-21 09:56:05 -05:00
|
|
|
}
|
|
|
|
|
|
2020-06-30 12:24:28 -04:00
|
|
|
/*
|
|
|
|
|
* The point of the following two functions is to work around
|
|
|
|
|
* an assertion in Chromium; see kern/240991 for details.
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_dotaskattr(PFS_ATTR_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
vap->va_nlink = 3;
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Filler function for proc/<pid>/task/.dummy
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_dotaskdummy(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-26 19:43:10 -05:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/sys/kernel/random/uuid
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_douuid(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
struct uuid uuid;
|
|
|
|
|
|
|
|
|
|
kern_uuidgen(&uuid, 1);
|
|
|
|
|
sbuf_printf_uuid(sb, &uuid);
|
|
|
|
|
sbuf_printf(sb, "\n");
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-24 13:46:04 -04:00
|
|
|
/*
|
|
|
|
|
* Filler function for proc/pid/auxv
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_doauxv(PFS_FILL_ARGS)
|
|
|
|
|
{
|
|
|
|
|
struct sbuf *asb;
|
|
|
|
|
off_t buflen, resid;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Mimic linux behavior and pass only processes with usermode
|
|
|
|
|
* address space as valid. Return zero silently otherwise.
|
|
|
|
|
*/
|
|
|
|
|
if (p->p_vmspace == &vmspace0)
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
|
|
if (uio->uio_resid == 0)
|
|
|
|
|
return (0);
|
|
|
|
|
if (uio->uio_offset < 0 || uio->uio_resid < 0)
|
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
|
|
asb = sbuf_new_auto();
|
|
|
|
|
if (asb == NULL)
|
|
|
|
|
return (ENOMEM);
|
|
|
|
|
error = proc_getauxv(td, p, asb);
|
|
|
|
|
if (error == 0)
|
|
|
|
|
error = sbuf_finish(asb);
|
|
|
|
|
|
|
|
|
|
resid = sbuf_len(asb) - uio->uio_offset;
|
|
|
|
|
if (resid > uio->uio_resid)
|
|
|
|
|
buflen = uio->uio_resid;
|
|
|
|
|
else
|
|
|
|
|
buflen = resid;
|
|
|
|
|
if (buflen > IOSIZE_MAX)
|
|
|
|
|
return (EINVAL);
|
|
|
|
|
if (buflen > MAXPHYS)
|
|
|
|
|
buflen = MAXPHYS;
|
|
|
|
|
if (resid <= 0)
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
|
|
if (error == 0)
|
|
|
|
|
error = uiomove(sbuf_data(asb) + uio->uio_offset, buflen, uio);
|
|
|
|
|
sbuf_delete(asb);
|
|
|
|
|
return (error);
|
|
|
|
|
}
|
2014-02-26 19:43:10 -05:00
|
|
|
|
2001-06-10 19:23:59 -04:00
|
|
|
/*
|
2001-10-18 21:45:03 -04:00
|
|
|
* Constructor
|
2001-06-10 19:23:59 -04:00
|
|
|
*/
|
2001-10-18 21:45:03 -04:00
|
|
|
static int
|
|
|
|
|
linprocfs_init(PFS_INIT_ARGS)
|
|
|
|
|
{
|
|
|
|
|
struct pfs_node *root;
|
|
|
|
|
struct pfs_node *dir;
|
2018-06-15 11:22:27 -04:00
|
|
|
struct pfs_node *sys;
|
2001-10-18 21:45:03 -04:00
|
|
|
|
|
|
|
|
root = pi->pi_root;
|
|
|
|
|
|
2003-09-09 15:22:55 -04:00
|
|
|
/* /proc/... */
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_file(root, "cmdline", &linprocfs_docmdline,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_file(root, "cpuinfo", &linprocfs_docpuinfo,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_file(root, "devices", &linprocfs_dodevices,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2010-03-23 17:49:33 -04:00
|
|
|
pfs_create_file(root, "filesystems", &linprocfs_dofilesystems,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_file(root, "loadavg", &linprocfs_doloadavg,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_file(root, "meminfo", &linprocfs_domeminfo,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_file(root, "modules", &linprocfs_domodules,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-05-05 12:10:45 -04:00
|
|
|
pfs_create_file(root, "mounts", &linprocfs_domtab,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_file(root, "mtab", &linprocfs_domtab,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2009-03-26 13:14:22 -04:00
|
|
|
pfs_create_file(root, "partitions", &linprocfs_dopartitions,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-12-08 19:38:59 -05:00
|
|
|
pfs_create_link(root, "self", &procfs_docurproc,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, 0);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_file(root, "stat", &linprocfs_dostat,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2011-08-01 15:12:15 -04:00
|
|
|
pfs_create_file(root, "swaps", &linprocfs_doswaps,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_file(root, "uptime", &linprocfs_douptime,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_file(root, "version", &linprocfs_doversion,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-10-18 21:45:03 -04:00
|
|
|
|
2020-07-04 07:22:35 -04:00
|
|
|
/* /proc/bus/... */
|
|
|
|
|
dir = pfs_create_dir(root, "bus", NULL, NULL, NULL, 0);
|
|
|
|
|
dir = pfs_create_dir(dir, "pci", NULL, NULL, NULL, 0);
|
|
|
|
|
dir = pfs_create_dir(dir, "devices", NULL, NULL, NULL, 0);
|
|
|
|
|
|
2003-09-09 15:22:55 -04:00
|
|
|
/* /proc/net/... */
|
2007-03-12 08:16:52 -04:00
|
|
|
dir = pfs_create_dir(root, "net", NULL, NULL, NULL, 0);
|
2001-10-18 21:45:03 -04:00
|
|
|
pfs_create_file(dir, "dev", &linprocfs_donetdev,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-10-18 21:45:03 -04:00
|
|
|
|
2003-09-09 15:22:55 -04:00
|
|
|
/* /proc/<pid>/... */
|
2007-03-12 08:16:52 -04:00
|
|
|
dir = pfs_create_dir(root, "pid", NULL, NULL, NULL, PFS_PROCDEP);
|
2001-10-18 21:45:03 -04:00
|
|
|
pfs_create_file(dir, "cmdline", &linprocfs_doproccmdline,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_link(dir, "cwd", &linprocfs_doproccwd,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, 0);
|
2003-06-10 17:29:12 -04:00
|
|
|
pfs_create_file(dir, "environ", &linprocfs_doprocenviron,
|
2015-05-24 13:53:48 -04:00
|
|
|
NULL, &procfs_candebug, NULL, PFS_RD);
|
2001-12-08 19:38:59 -05:00
|
|
|
pfs_create_link(dir, "exe", &procfs_doprocfile,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, &procfs_notsystem, NULL, 0);
|
2003-06-10 17:29:12 -04:00
|
|
|
pfs_create_file(dir, "maps", &linprocfs_doprocmaps,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-10-18 21:45:03 -04:00
|
|
|
pfs_create_file(dir, "mem", &procfs_doprocmem,
|
2018-04-24 10:49:09 -04:00
|
|
|
procfs_attr_rw, &procfs_candebug, NULL, PFS_RDWR | PFS_RAW);
|
2017-02-20 12:33:25 -05:00
|
|
|
pfs_create_file(dir, "mounts", &linprocfs_domtab,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_link(dir, "root", &linprocfs_doprocroot,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, 0);
|
2001-10-18 21:45:03 -04:00
|
|
|
pfs_create_file(dir, "stat", &linprocfs_doprocstat,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2003-09-09 04:19:06 -04:00
|
|
|
pfs_create_file(dir, "statm", &linprocfs_doprocstatm,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-10-18 21:45:03 -04:00
|
|
|
pfs_create_file(dir, "status", &linprocfs_doprocstatus,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2010-03-07 05:43:45 -05:00
|
|
|
pfs_create_link(dir, "fd", &linprocfs_dofdescfs,
|
|
|
|
|
NULL, NULL, NULL, 0);
|
2015-05-24 13:46:04 -04:00
|
|
|
pfs_create_file(dir, "auxv", &linprocfs_doauxv,
|
|
|
|
|
NULL, &procfs_candebug, NULL, PFS_RD|PFS_RAWRD);
|
2016-02-21 09:56:05 -05:00
|
|
|
pfs_create_file(dir, "limits", &linprocfs_doproclimits,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2001-06-10 19:23:59 -04:00
|
|
|
|
2020-06-30 12:24:28 -04:00
|
|
|
/* /proc/<pid>/task/... */
|
|
|
|
|
dir = pfs_create_dir(dir, "task", linprocfs_dotaskattr, NULL, NULL, 0);
|
|
|
|
|
pfs_create_file(dir, ".dummy", &linprocfs_dotaskdummy,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
|
|
|
|
|
2006-05-05 12:10:45 -04:00
|
|
|
/* /proc/scsi/... */
|
2007-03-12 08:16:52 -04:00
|
|
|
dir = pfs_create_dir(root, "scsi", NULL, NULL, NULL, 0);
|
2006-05-05 12:10:45 -04:00
|
|
|
pfs_create_file(dir, "device_info", &linprocfs_doscsidevinfo,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-05-05 12:10:45 -04:00
|
|
|
pfs_create_file(dir, "scsi", &linprocfs_doscsiscsi,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-10-08 12:55:27 -04:00
|
|
|
|
|
|
|
|
/* /proc/sys/... */
|
2018-06-15 11:22:27 -04:00
|
|
|
sys = pfs_create_dir(root, "sys", NULL, NULL, NULL, 0);
|
2020-07-18 06:56:04 -04:00
|
|
|
|
2006-10-08 12:55:27 -04:00
|
|
|
/* /proc/sys/kernel/... */
|
2018-06-15 11:22:27 -04:00
|
|
|
dir = pfs_create_dir(sys, "kernel", NULL, NULL, NULL, 0);
|
2007-03-01 20:10:26 -05:00
|
|
|
pfs_create_file(dir, "osrelease", &linprocfs_doosrelease,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2007-03-01 20:10:26 -05:00
|
|
|
pfs_create_file(dir, "ostype", &linprocfs_doostype,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2007-03-01 20:10:26 -05:00
|
|
|
pfs_create_file(dir, "version", &linprocfs_doosbuild,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2020-07-18 06:56:04 -04:00
|
|
|
pfs_create_file(dir, "msgmax", &linprocfs_domsgmax,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-11-27 16:10:55 -05:00
|
|
|
pfs_create_file(dir, "msgmni", &linprocfs_domsgmni,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2020-07-18 06:56:04 -04:00
|
|
|
pfs_create_file(dir, "msgmnb", &linprocfs_domsgmnb,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-10-08 12:55:27 -04:00
|
|
|
pfs_create_file(dir, "pid_max", &linprocfs_dopid_max,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-11-27 16:10:55 -05:00
|
|
|
pfs_create_file(dir, "sem", &linprocfs_dosem,
|
2007-03-12 08:16:52 -04:00
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2020-07-18 06:56:04 -04:00
|
|
|
pfs_create_file(dir, "shmall", &linprocfs_doshmall,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
|
|
|
|
pfs_create_file(dir, "shmmax", &linprocfs_doshmmax,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
|
|
|
|
pfs_create_file(dir, "shmmni", &linprocfs_doshmmni,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2020-07-04 07:26:03 -04:00
|
|
|
pfs_create_file(dir, "tainted", &linprocfs_dotainted,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
2006-10-08 12:55:27 -04:00
|
|
|
|
2014-02-26 19:43:10 -05:00
|
|
|
/* /proc/sys/kernel/random/... */
|
|
|
|
|
dir = pfs_create_dir(dir, "random", NULL, NULL, NULL, 0);
|
|
|
|
|
pfs_create_file(dir, "uuid", &linprocfs_douuid,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
|
|
|
|
|
2018-06-15 11:22:27 -04:00
|
|
|
/* /proc/sys/vm/.... */
|
|
|
|
|
dir = pfs_create_dir(sys, "vm", NULL, NULL, NULL, 0);
|
|
|
|
|
pfs_create_file(dir, "min_free_kbytes", &linprocfs_dominfree,
|
|
|
|
|
NULL, NULL, NULL, PFS_RD);
|
|
|
|
|
|
2001-10-18 21:45:03 -04:00
|
|
|
return (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
linprocfs_uninit(PFS_INIT_ARGS)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/* nothing to do, pseudofs will GC */
|
|
|
|
|
return (0);
|
|
|
|
|
}
|
2001-06-10 19:23:59 -04:00
|
|
|
|
2018-05-04 16:54:27 -04:00
|
|
|
PSEUDOFS(linprocfs, 1, VFCF_JAIL);
|
2018-06-15 09:53:37 -04:00
|
|
|
#if defined(__aarch64__) || defined(__amd64__)
|
2015-05-24 11:51:18 -04:00
|
|
|
MODULE_DEPEND(linprocfs, linux_common, 1, 1, 1);
|
|
|
|
|
#else
|
2001-06-10 19:23:59 -04:00
|
|
|
MODULE_DEPEND(linprocfs, linux, 1, 1, 1);
|
2015-05-24 11:51:18 -04:00
|
|
|
#endif
|
2001-06-10 19:23:59 -04:00
|
|
|
MODULE_DEPEND(linprocfs, procfs, 1, 1, 1);
|
2007-04-06 14:15:56 -04:00
|
|
|
MODULE_DEPEND(linprocfs, sysvmsg, 1, 1, 1);
|
|
|
|
|
MODULE_DEPEND(linprocfs, sysvsem, 1, 1, 1);
|
2020-07-18 06:56:04 -04:00
|
|
|
MODULE_DEPEND(linprocfs, sysvshm, 1, 1, 1);
|