2 * SPDX-License-Identifier: BSD-4-Clause
4 * Copyright (c) 2000 Dag-Erling Coïdan Smørgrav
5 * Copyright (c) 1999 Pierre Beyssac
6 * Copyright (c) 1993 Jan-Simon Pendry
8 * The Regents of the University of California. All rights reserved.
10 * This code is derived from software contributed to Berkeley by
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by the University of
24 * California, Berkeley and its contributors.
25 * 4. Neither the name of the University nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
29 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * @(#)procfs_status.c 8.4 (Berkeley) 6/15/94
44 #include <sys/cdefs.h>
45 __FBSDID("$FreeBSD$");
47 #include <sys/param.h>
48 #include <sys/queue.h>
49 #include <sys/blist.h>
52 #include <sys/fcntl.h>
53 #include <sys/filedesc.h>
55 #include <sys/kernel.h>
56 #include <sys/limits.h>
57 #include <sys/linker.h>
59 #include <sys/malloc.h>
61 #include <sys/mutex.h>
62 #include <sys/namei.h>
64 #include <sys/ptrace.h>
65 #include <sys/resourcevar.h>
66 #include <sys/resource.h>
70 #include <sys/socket.h>
71 #include <sys/syscallsubr.h>
72 #include <sys/sysctl.h>
73 #include <sys/sysent.h>
74 #include <sys/systm.h>
79 #include <sys/vmmeter.h>
80 #include <sys/vnode.h>
84 #include <net/if_var.h>
85 #include <net/if_types.h>
88 #include <vm/vm_extern.h>
90 #include <vm/vm_map.h>
91 #include <vm/vm_param.h>
92 #include <vm/vm_object.h>
93 #include <vm/swap_pager.h>
95 #include <machine/clock.h>
97 #include <geom/geom.h>
98 #include <geom/geom_int.h>
100 #if defined(__i386__) || defined(__amd64__)
101 #include <machine/cputypes.h>
102 #include <machine/md_var.h>
103 #endif /* __i386__ || __amd64__ */
105 #include <compat/linux/linux.h>
106 #include <compat/linux/linux_mib.h>
107 #include <compat/linux/linux_misc.h>
108 #include <compat/linux/linux_util.h>
109 #include <fs/pseudofs/pseudofs.h>
110 #include <fs/procfs/procfs.h>
113 * Various conversion macros
115 #define T2J(x) ((long)(((x) * 100ULL) / (stathz ? stathz : hz))) /* ticks to jiffies */
116 #define T2CS(x) ((unsigned long)(((x) * 100ULL) / (stathz ? stathz : hz))) /* ticks to centiseconds */
117 #define T2S(x) ((x) / (stathz ? stathz : hz)) /* ticks to seconds */
118 #define B2K(x) ((x) >> 10) /* bytes to kbytes */
119 #define B2P(x) ((x) >> PAGE_SHIFT) /* bytes to pages */
120 #define P2B(x) ((x) << PAGE_SHIFT) /* pages to bytes */
121 #define P2K(x) ((x) << (PAGE_SHIFT - 10)) /* pages to kbytes */
122 #define TV2J(x) ((x)->tv_sec * 100UL + (x)->tv_usec / 10000)
125 * @brief Mapping of ki_stat in struct kinfo_proc to the linux state
127 * The linux procfs state field displays one of the characters RSDZTW to
128 * denote running, sleeping in an interruptible wait, waiting in an
129 * uninterruptible disk sleep, a zombie process, process is being traced
130 * or stopped, or process is paging respectively.
132 * Our struct kinfo_proc contains the variable ki_stat which contains a
133 * value out of SIDL, SRUN, SSLEEP, SSTOP, SZOMB, SWAIT and SLOCK.
135 * This character array is used with ki_stati-1 as an index and tries to
136 * map our states to suitable linux states.
138 static char linux_state[] = "RRSTZDD";
141 * Filler function for proc/meminfo
144 linprocfs_domeminfo(PFS_FILL_ARGS)
146 unsigned long memtotal; /* total memory in bytes */
147 unsigned long memused; /* used memory in bytes */
148 unsigned long memfree; /* free memory in bytes */
149 unsigned long buffers, cached; /* buffer / cache memory ??? */
150 unsigned long long swaptotal; /* total swap space in bytes */
151 unsigned long long swapused; /* used swap space in bytes */
152 unsigned long long swapfree; /* free swap space in bytes */
155 memtotal = physmem * PAGE_SIZE;
157 * The correct thing here would be:
159 memfree = vm_free_count() * PAGE_SIZE;
160 memused = memtotal - memfree;
162 * but it might mislead linux binaries into thinking there
163 * is very little memory left, so we cheat and tell them that
164 * all memory that isn't wired down is free.
166 memused = vm_cnt.v_wire_count * PAGE_SIZE;
167 memfree = memtotal - memused;
168 swap_pager_status(&i, &j);
169 swaptotal = (unsigned long long)i * PAGE_SIZE;
170 swapused = (unsigned long long)j * PAGE_SIZE;
171 swapfree = swaptotal - swapused;
173 * We'd love to be able to write:
177 * but bufspace is internal to vfs_bio.c and we don't feel
178 * like unstaticizing it just for linprocfs's sake.
181 cached = vm_inactive_count() * PAGE_SIZE;
184 "MemTotal: %9lu kB\n"
188 "SwapTotal:%9llu kB\n"
189 "SwapFree: %9llu kB\n",
190 B2K(memtotal), B2K(memfree), B2K(buffers),
191 B2K(cached), B2K(swaptotal), B2K(swapfree));
196 #if defined(__i386__) || defined(__amd64__)
198 * Filler function for proc/cpuinfo (i386 & amd64 version)
201 linprocfs_docpuinfo(PFS_FILL_ARGS)
212 * We default the flags to include all non-conflicting flags,
213 * and the Intel versions of conflicting flags.
215 static char *flags[] = {
216 "fpu", "vme", "de", "pse", "tsc",
217 "msr", "pae", "mce", "cx8", "apic",
218 "sep", "sep", "mtrr", "pge", "mca",
219 "cmov", "pat", "pse36", "pn", "b19",
220 "b20", "b21", "mmxext", "mmx", "fxsr",
221 "xmm", "sse2", "b27", "b28", "b29",
225 static char *power_flags[] = {
228 "100mhzsteps", "hwpstate", "",
229 "cpb", "eff_freq_ro", "proc_feedback",
233 hw_model[0] = CTL_HW;
234 hw_model[1] = HW_MODEL;
236 size = sizeof(model);
237 if (kernel_sysctl(td, hw_model, 2, &model, &size, 0, 0, 0, 0) != 0)
238 strcpy(model, "unknown");
240 switch (cpu_vendor_id) {
242 if (cpu_class < CPUCLASS_686)
245 case CPU_VENDOR_CYRIX:
250 if (cpu_exthigh >= 0x80000006)
251 do_cpuid(0x80000006, cache_size);
253 memset(cache_size, 0, sizeof(cache_size));
254 for (i = 0; i < mp_ncpus; ++i) {
257 freq = atomic_load_acq_64(&tsc_freq);
259 fqmhz = (freq + 4999) / 1000000;
260 fqkhz = ((freq + 4999) / 10000) % 100;
264 "vendor_id\t: %.20s\n"
269 "cpu MHz\t\t: %d.%02d\n"
270 "cache size\t: %d KB\n"
271 "physical id\t: %d\n"
276 "initial apicid\t: %d\n"
278 "fpu_exception\t: %s\n"
279 "cpuid level\t: %d\n"
281 i, cpu_vendor, CPUID_TO_FAMILY(cpu_id),
282 CPUID_TO_MODEL(cpu_id), model, cpu_id & CPUID_STEPPING,
284 (cache_size[2] >> 16), 0, mp_ncpus, i, mp_ncpus,
285 i, i, /*cpu_id & CPUID_LOCAL_APIC_ID ??*/
286 (cpu_feature & CPUID_FPU) ? "yes" : "no", "yes",
287 CPUID_TO_FAMILY(cpu_id), "yes");
288 sbuf_cat(sb, "flags\t\t:");
289 for (j = 0; j < nitems(flags); j++)
290 if (cpu_feature & (1 << j))
291 sbuf_printf(sb, " %s", flags[j]);
295 "bogomips\t: %d.%02d\n"
296 "clflush size\t: %d\n"
297 "cache_alignment\t: %d\n"
298 "address sizes\t: %d bits physical, %d bits virtual\n",
299 #if defined(I586_CPU) && !defined(NO_F00F_HACK)
300 (has_f00f_bug) ? "Intel F00F" : "",
305 cpu_clflush_line_size, cpu_clflush_line_size,
307 (cpu_maxphyaddr > 32) ? 48 : 0);
308 sbuf_cat(sb, "power management: ");
309 for (j = 0; j < nitems(power_flags); j++)
310 if (amd_pminfo & (1 << j))
311 sbuf_printf(sb, " %s", power_flags[j]);
312 sbuf_cat(sb, "\n\n");
314 /* XXX per-cpu vendor / class / model / id? */
320 #endif /* __i386__ || __amd64__ */
323 * Filler function for proc/mtab
325 * This file doesn't exist in Linux' procfs, but is included here so
326 * users can symlink /compat/linux/etc/mtab to /proc/mtab
329 linprocfs_domtab(PFS_FILL_ARGS)
333 char *dlep, *flep, *mntto, *mntfrom, *fstype;
336 struct statfs *buf, *sp;
339 /* resolve symlinks etc. in the emulation tree prefix */
340 NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path, td);
343 lep = linux_emul_path;
345 if (vn_fullpath(td, nd.ni_vp, &dlep, &flep) == 0)
349 lep_len = strlen(lep);
352 error = kern_getfsstat(td, &buf, SIZE_T_MAX, &count,
353 UIO_SYSSPACE, MNT_WAIT);
360 for (sp = buf; count > 0; sp++, count--) {
361 /* determine device name */
362 mntfrom = sp->f_mntfromname;
364 /* determine mount point */
365 mntto = sp->f_mntonname;
366 if (strncmp(mntto, lep, lep_len) == 0 && mntto[lep_len] == '/')
369 /* determine fs type */
370 fstype = sp->f_fstypename;
371 if (strcmp(fstype, pn->pn_info->pi_name) == 0)
372 mntfrom = fstype = "proc";
373 else if (strcmp(fstype, "procfs") == 0)
376 if (strcmp(fstype, "linsysfs") == 0) {
377 sbuf_printf(sb, "/sys %s sysfs %s", mntto,
378 sp->f_flags & MNT_RDONLY ? "ro" : "rw");
380 /* For Linux msdosfs is called vfat */
381 if (strcmp(fstype, "msdosfs") == 0)
383 sbuf_printf(sb, "%s %s %s %s", mntfrom, mntto, fstype,
384 sp->f_flags & MNT_RDONLY ? "ro" : "rw");
386 #define ADD_OPTION(opt, name) \
387 if (sp->f_flags & (opt)) sbuf_printf(sb, "," name);
388 ADD_OPTION(MNT_SYNCHRONOUS, "sync");
389 ADD_OPTION(MNT_NOEXEC, "noexec");
390 ADD_OPTION(MNT_NOSUID, "nosuid");
391 ADD_OPTION(MNT_UNION, "union");
392 ADD_OPTION(MNT_ASYNC, "async");
393 ADD_OPTION(MNT_SUIDDIR, "suiddir");
394 ADD_OPTION(MNT_NOSYMFOLLOW, "nosymfollow");
395 ADD_OPTION(MNT_NOATIME, "noatime");
397 /* a real Linux mtab will also show NFS options */
398 sbuf_printf(sb, " 0 0\n");
407 * Filler function for proc/partitions
410 linprocfs_dopartitions(PFS_FILL_ARGS)
414 struct g_provider *pp;
418 sbuf_printf(sb, "major minor #blocks name rio rmerge rsect "
419 "ruse wio wmerge wsect wuse running use aveq\n");
421 LIST_FOREACH(cp, &g_classes, class) {
422 if (strcmp(cp->name, "DISK") == 0 ||
423 strcmp(cp->name, "PART") == 0)
424 LIST_FOREACH(gp, &cp->geom, geom) {
425 LIST_FOREACH(pp, &gp->provider, provider) {
426 if (linux_driver_get_major_minor(
427 pp->name, &major, &minor) != 0) {
431 sbuf_printf(sb, "%d %d %lld %s "
433 "%d %d %d %d %d %d\n",
435 (long long)pp->mediasize, pp->name,
448 * Filler function for proc/stat
451 linprocfs_dostat(PFS_FILL_ARGS)
454 long cp_time[CPUSTATES];
456 struct timeval boottime;
459 read_cpu_time(cp_time);
460 getboottime(&boottime);
461 sbuf_printf(sb, "cpu %ld %ld %ld %ld\n",
462 T2J(cp_time[CP_USER]),
463 T2J(cp_time[CP_NICE]),
464 T2J(cp_time[CP_SYS] /*+ cp_time[CP_INTR]*/),
465 T2J(cp_time[CP_IDLE]));
468 cp = pcpu->pc_cp_time;
469 sbuf_printf(sb, "cpu%d %ld %ld %ld %ld\n", i,
472 T2J(cp[CP_SYS] /*+ cp[CP_INTR]*/),
482 (uintmax_t)VM_CNT_FETCH(v_vnodepgsin),
483 (uintmax_t)VM_CNT_FETCH(v_vnodepgsout),
484 (uintmax_t)VM_CNT_FETCH(v_swappgsin),
485 (uintmax_t)VM_CNT_FETCH(v_swappgsout),
486 (uintmax_t)VM_CNT_FETCH(v_intr),
487 (uintmax_t)VM_CNT_FETCH(v_swtch),
488 (long long)boottime.tv_sec);
493 linprocfs_doswaps(PFS_FILL_ARGS)
496 uintmax_t total, used;
498 char devname[SPECNAMELEN + 1];
500 sbuf_printf(sb, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
502 if (swap_dev_info(n, &xsw, devname, sizeof(devname)) != 0)
504 total = (uintmax_t)xsw.xsw_nblks * PAGE_SIZE / 1024;
505 used = (uintmax_t)xsw.xsw_used * PAGE_SIZE / 1024;
508 * The space and not tab after the device name is on
509 * purpose. Linux does so.
511 sbuf_printf(sb, "/dev/%-34s unknown\t\t%jd\t%jd\t-1\n",
512 devname, total, used);
518 * Filler function for proc/uptime
521 linprocfs_douptime(PFS_FILL_ARGS)
523 long cp_time[CPUSTATES];
527 read_cpu_time(cp_time);
528 sbuf_printf(sb, "%lld.%02ld %ld.%02lu\n",
529 (long long)tv.tv_sec, tv.tv_usec / 10000,
530 T2S(cp_time[CP_IDLE] / mp_ncpus),
531 T2CS(cp_time[CP_IDLE] / mp_ncpus) % 100);
539 linprocfs_osbuild(struct thread *td, struct sbuf *sb)
545 strncpy(osbuild, version, 256);
547 cp1 = strstr(osbuild, "\n");
548 cp2 = strstr(osbuild, ":");
551 cp1 = strstr(osbuild, "#");
555 sbuf_printf(sb, "%s%s", cp1, cp2 + 1);
558 sbuf_cat(sb, "#4 Sun Dec 18 04:30:00 CET 1977");
565 linprocfs_osbuilder(struct thread *td, struct sbuf *sb)
571 cp = strstr(version, "\n ");
573 strncpy(builder, cp + 5, 256);
575 cp = strstr(builder, ":");
580 sbuf_cat(sb, builder);
583 sbuf_cat(sb, "des@freebsd.org");
587 * Filler function for proc/version
590 linprocfs_doversion(PFS_FILL_ARGS)
592 char osname[LINUX_MAX_UTSNAME];
593 char osrelease[LINUX_MAX_UTSNAME];
595 linux_get_osname(td, osname);
596 linux_get_osrelease(td, osrelease);
597 sbuf_printf(sb, "%s version %s (", osname, osrelease);
598 linprocfs_osbuilder(td, sb);
599 sbuf_cat(sb, ") (gcc version " __VERSION__ ") ");
600 linprocfs_osbuild(td, sb);
607 * Filler function for proc/loadavg
610 linprocfs_doloadavg(PFS_FILL_ARGS)
614 "%d.%02d %d.%02d %d.%02d %d/%d %d\n",
615 (int)(averunnable.ldavg[0] / averunnable.fscale),
616 (int)(averunnable.ldavg[0] * 100 / averunnable.fscale % 100),
617 (int)(averunnable.ldavg[1] / averunnable.fscale),
618 (int)(averunnable.ldavg[1] * 100 / averunnable.fscale % 100),
619 (int)(averunnable.ldavg[2] / averunnable.fscale),
620 (int)(averunnable.ldavg[2] * 100 / averunnable.fscale % 100),
621 1, /* number of running tasks */
622 nprocs, /* number of tasks */
623 lastpid /* the last pid */
629 * Filler function for proc/pid/stat
632 linprocfs_doprocstat(PFS_FILL_ARGS)
634 struct kinfo_proc kp;
635 struct timeval boottime;
637 static int ratelimit = 0;
638 vm_offset_t startcode, startdata;
640 getboottime(&boottime);
641 sx_slock(&proctree_lock);
643 fill_kinfo_proc(p, &kp);
644 sx_sunlock(&proctree_lock);
646 startcode = (vm_offset_t)p->p_vmspace->vm_taddr;
647 startdata = (vm_offset_t)p->p_vmspace->vm_daddr;
652 sbuf_printf(sb, "%d", p->p_pid);
653 #define PS_ADD(name, fmt, arg) sbuf_printf(sb, " " fmt, arg)
654 PS_ADD("comm", "(%s)", p->p_comm);
655 if (kp.ki_stat > sizeof(linux_state)) {
658 if (ratelimit == 0) {
659 printf("linprocfs: don't know how to handle unknown FreeBSD state %d/%zd, mapping to R\n",
660 kp.ki_stat, sizeof(linux_state));
664 state = linux_state[kp.ki_stat - 1];
665 PS_ADD("state", "%c", state);
666 PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0);
667 PS_ADD("pgrp", "%d", p->p_pgid);
668 PS_ADD("session", "%d", p->p_session->s_sid);
670 PS_ADD("tty", "%ju", (uintmax_t)kp.ki_tdev);
671 PS_ADD("tpgid", "%d", kp.ki_tpgid);
672 PS_ADD("flags", "%u", 0); /* XXX */
673 PS_ADD("minflt", "%lu", kp.ki_rusage.ru_minflt);
674 PS_ADD("cminflt", "%lu", kp.ki_rusage_ch.ru_minflt);
675 PS_ADD("majflt", "%lu", kp.ki_rusage.ru_majflt);
676 PS_ADD("cmajflt", "%lu", kp.ki_rusage_ch.ru_majflt);
677 PS_ADD("utime", "%ld", TV2J(&kp.ki_rusage.ru_utime));
678 PS_ADD("stime", "%ld", TV2J(&kp.ki_rusage.ru_stime));
679 PS_ADD("cutime", "%ld", TV2J(&kp.ki_rusage_ch.ru_utime));
680 PS_ADD("cstime", "%ld", TV2J(&kp.ki_rusage_ch.ru_stime));
681 PS_ADD("priority", "%d", kp.ki_pri.pri_user);
682 PS_ADD("nice", "%d", kp.ki_nice); /* 19 (nicest) to -19 */
683 PS_ADD("0", "%d", 0); /* removed field */
684 PS_ADD("itrealvalue", "%d", 0); /* XXX */
685 PS_ADD("starttime", "%lu", TV2J(&kp.ki_start) - TV2J(&boottime));
686 PS_ADD("vsize", "%ju", P2K((uintmax_t)kp.ki_size));
687 PS_ADD("rss", "%ju", (uintmax_t)kp.ki_rssize);
688 PS_ADD("rlim", "%lu", kp.ki_rusage.ru_maxrss);
689 PS_ADD("startcode", "%ju", (uintmax_t)startcode);
690 PS_ADD("endcode", "%ju", (uintmax_t)startdata);
691 PS_ADD("startstack", "%u", 0); /* XXX */
692 PS_ADD("kstkesp", "%u", 0); /* XXX */
693 PS_ADD("kstkeip", "%u", 0); /* XXX */
694 PS_ADD("signal", "%u", 0); /* XXX */
695 PS_ADD("blocked", "%u", 0); /* XXX */
696 PS_ADD("sigignore", "%u", 0); /* XXX */
697 PS_ADD("sigcatch", "%u", 0); /* XXX */
698 PS_ADD("wchan", "%u", 0); /* XXX */
699 PS_ADD("nswap", "%lu", kp.ki_rusage.ru_nswap);
700 PS_ADD("cnswap", "%lu", kp.ki_rusage_ch.ru_nswap);
701 PS_ADD("exitsignal", "%d", 0); /* XXX */
702 PS_ADD("processor", "%u", kp.ki_lastcpu);
703 PS_ADD("rt_priority", "%u", 0); /* XXX */ /* >= 2.5.19 */
704 PS_ADD("policy", "%u", kp.ki_pri.pri_class); /* >= 2.5.19 */
712 * Filler function for proc/pid/statm
715 linprocfs_doprocstatm(PFS_FILL_ARGS)
717 struct kinfo_proc kp;
720 sx_slock(&proctree_lock);
722 fill_kinfo_proc(p, &kp);
724 sx_sunlock(&proctree_lock);
727 * See comments in linprocfs_doprocstatus() regarding the
728 * computation of lsize.
730 /* size resident share trs drs lrs dt */
731 sbuf_printf(sb, "%ju ", B2P((uintmax_t)kp.ki_size));
732 sbuf_printf(sb, "%ju ", (uintmax_t)kp.ki_rssize);
733 sbuf_printf(sb, "%ju ", (uintmax_t)0); /* XXX */
734 sbuf_printf(sb, "%ju ", (uintmax_t)kp.ki_tsize);
735 sbuf_printf(sb, "%ju ", (uintmax_t)(kp.ki_dsize + kp.ki_ssize));
736 lsize = B2P(kp.ki_size) - kp.ki_dsize -
737 kp.ki_ssize - kp.ki_tsize - 1;
738 sbuf_printf(sb, "%ju ", (uintmax_t)lsize);
739 sbuf_printf(sb, "%ju\n", (uintmax_t)0); /* XXX */
745 * Filler function for proc/pid/status
748 linprocfs_doprocstatus(PFS_FILL_ARGS)
750 struct kinfo_proc kp;
755 l_sigset_t siglist, sigignore, sigcatch;
758 sx_slock(&proctree_lock);
760 td2 = FIRST_THREAD_IN_PROC(p); /* XXXKSE pretend only one thread */
762 if (P_SHOULDSTOP(p)) {
763 state = "T (stopped)";
770 if (p->p_flag & P_WEXIT) {
771 state = "X (exiting)";
774 switch(td2->td_state) {
776 state = "S (sleeping)";
780 state = "R (running)";
783 state = "? (unknown)";
788 state = "Z (zombie)";
791 state = "? (unknown)";
796 fill_kinfo_proc(p, &kp);
797 sx_sunlock(&proctree_lock);
799 sbuf_printf(sb, "Name:\t%s\n", p->p_comm); /* XXX escape */
800 sbuf_printf(sb, "State:\t%s\n", state);
805 sbuf_printf(sb, "Pid:\t%d\n", p->p_pid);
806 sbuf_printf(sb, "PPid:\t%d\n", p->p_pptr ?
807 p->p_pptr->p_pid : 0);
808 sbuf_printf(sb, "Uid:\t%d %d %d %d\n", p->p_ucred->cr_ruid,
810 p->p_ucred->cr_svuid,
811 /* FreeBSD doesn't have fsuid */
813 sbuf_printf(sb, "Gid:\t%d %d %d %d\n", p->p_ucred->cr_rgid,
815 p->p_ucred->cr_svgid,
816 /* FreeBSD doesn't have fsgid */
818 sbuf_cat(sb, "Groups:\t");
819 for (i = 0; i < p->p_ucred->cr_ngroups; i++)
820 sbuf_printf(sb, "%d ", p->p_ucred->cr_groups[i]);
827 * While our approximation of VmLib may not be accurate (I
828 * don't know of a simple way to verify it, and I'm not sure
829 * it has much meaning anyway), I believe it's good enough.
831 * The same code that could (I think) accurately compute VmLib
832 * could also compute VmLck, but I don't really care enough to
833 * implement it. Submissions are welcome.
835 sbuf_printf(sb, "VmSize:\t%8ju kB\n", B2K((uintmax_t)kp.ki_size));
836 sbuf_printf(sb, "VmLck:\t%8u kB\n", P2K(0)); /* XXX */
837 sbuf_printf(sb, "VmRSS:\t%8ju kB\n", P2K((uintmax_t)kp.ki_rssize));
838 sbuf_printf(sb, "VmData:\t%8ju kB\n", P2K((uintmax_t)kp.ki_dsize));
839 sbuf_printf(sb, "VmStk:\t%8ju kB\n", P2K((uintmax_t)kp.ki_ssize));
840 sbuf_printf(sb, "VmExe:\t%8ju kB\n", P2K((uintmax_t)kp.ki_tsize));
841 lsize = B2P(kp.ki_size) - kp.ki_dsize -
842 kp.ki_ssize - kp.ki_tsize - 1;
843 sbuf_printf(sb, "VmLib:\t%8ju kB\n", P2K((uintmax_t)lsize));
849 bsd_to_linux_sigset(&p->p_siglist, &siglist);
851 mtx_lock(&ps->ps_mtx);
852 bsd_to_linux_sigset(&ps->ps_sigignore, &sigignore);
853 bsd_to_linux_sigset(&ps->ps_sigcatch, &sigcatch);
854 mtx_unlock(&ps->ps_mtx);
857 sbuf_printf(sb, "SigPnd:\t%016jx\n", siglist.__mask);
859 * XXX. SigBlk - target thread's signal mask, td_sigmask.
860 * To implement SigBlk pseudofs should support proc/tid dir entries.
862 sbuf_printf(sb, "SigBlk:\t%016x\n", 0);
863 sbuf_printf(sb, "SigIgn:\t%016jx\n", sigignore.__mask);
864 sbuf_printf(sb, "SigCgt:\t%016jx\n", sigcatch.__mask);
867 * Linux also prints the capability masks, but we don't have
868 * capabilities yet, and when we do get them they're likely to
869 * be meaningless to Linux programs, so we lie. XXX
871 sbuf_printf(sb, "CapInh:\t%016x\n", 0);
872 sbuf_printf(sb, "CapPrm:\t%016x\n", 0);
873 sbuf_printf(sb, "CapEff:\t%016x\n", 0);
880 * Filler function for proc/pid/cwd
883 linprocfs_doproccwd(PFS_FILL_ARGS)
885 struct filedesc *fdp;
887 char *fullpath = "unknown";
888 char *freepath = NULL;
895 FILEDESC_SUNLOCK(fdp);
896 vn_fullpath(td, vp, &fullpath, &freepath);
899 sbuf_printf(sb, "%s", fullpath);
901 free(freepath, M_TEMP);
906 * Filler function for proc/pid/root
909 linprocfs_doprocroot(PFS_FILL_ARGS)
911 struct filedesc *fdp;
913 char *fullpath = "unknown";
914 char *freepath = NULL;
918 vp = jailed(p->p_ucred) ? fdp->fd_jdir : fdp->fd_rdir;
921 FILEDESC_SUNLOCK(fdp);
922 vn_fullpath(td, vp, &fullpath, &freepath);
925 sbuf_printf(sb, "%s", fullpath);
927 free(freepath, M_TEMP);
932 * Filler function for proc/pid/cmdline
935 linprocfs_doproccmdline(PFS_FILL_ARGS)
940 if ((ret = p_cansee(td, p)) != 0) {
946 * Mimic linux behavior and pass only processes with usermode
947 * address space as valid. Return zero silently otherwize.
949 if (p->p_vmspace == &vmspace0) {
953 if (p->p_args != NULL) {
954 sbuf_bcpy(sb, p->p_args->ar_args, p->p_args->ar_length);
959 if ((p->p_flag & P_SYSTEM) != 0) {
966 ret = proc_getargv(td, p, sb);
971 * Filler function for proc/pid/environ
974 linprocfs_doprocenviron(PFS_FILL_ARGS)
978 * Mimic linux behavior and pass only processes with usermode
979 * address space as valid. Return zero silently otherwize.
981 if (p->p_vmspace == &vmspace0)
984 return (proc_getenvv(td, p, sb));
987 static char l32_map_str[] = "%08lx-%08lx %s%s%s%s %08lx %02x:%02x %lu%s%s\n";
988 static char l64_map_str[] = "%016lx-%016lx %s%s%s%s %08lx %02x:%02x %lu%s%s\n";
989 static char vdso_str[] = " [vdso]";
990 static char stack_str[] = " [stack]";
993 * Filler function for proc/pid/maps
996 linprocfs_doprocmaps(PFS_FILL_ARGS)
1000 vm_map_entry_t entry, tmp_entry;
1001 vm_object_t obj, tobj, lobj;
1002 vm_offset_t e_start, e_end;
1003 vm_ooffset_t off = 0;
1005 unsigned int last_timestamp;
1006 char *name = "", *freename = NULL;
1007 const char *l_map_str;
1009 int ref_count, shadow_count, flags;
1015 error = p_candebug(td, p);
1020 if (uio->uio_rw != UIO_READ)
1021 return (EOPNOTSUPP);
1024 vm = vmspace_acquire_ref(p);
1028 if (SV_CURPROC_FLAG(SV_LP64))
1029 l_map_str = l64_map_str;
1031 l_map_str = l32_map_str;
1033 vm_map_lock_read(map);
1034 for (entry = map->header.next; entry != &map->header;
1035 entry = entry->next) {
1038 if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
1040 e_prot = entry->protection;
1041 e_start = entry->start;
1043 obj = entry->object.vm_object;
1044 for (lobj = tobj = obj; tobj; tobj = tobj->backing_object) {
1045 VM_OBJECT_RLOCK(tobj);
1047 VM_OBJECT_RUNLOCK(lobj);
1050 last_timestamp = map->timestamp;
1051 vm_map_unlock_read(map);
1054 off = IDX_TO_OFF(lobj->size);
1055 vp = vm_object_vnode(lobj);
1059 VM_OBJECT_RUNLOCK(lobj);
1061 ref_count = obj->ref_count;
1062 shadow_count = obj->shadow_count;
1063 VM_OBJECT_RUNLOCK(obj);
1065 vn_fullpath(td, vp, &name, &freename);
1066 vn_lock(vp, LK_SHARED | LK_RETRY);
1067 VOP_GETATTR(vp, &vat, td->td_ucred);
1068 ino = vat.va_fileid;
1070 } else if (SV_PROC_ABI(p) == SV_ABI_LINUX) {
1071 if (e_start == p->p_sysent->sv_shared_page_base)
1073 if (e_end == p->p_sysent->sv_usrstack)
1084 * start, end, access, offset, major, minor, inode, name.
1086 error = sbuf_printf(sb, l_map_str,
1087 (u_long)e_start, (u_long)e_end,
1088 (e_prot & VM_PROT_READ)?"r":"-",
1089 (e_prot & VM_PROT_WRITE)?"w":"-",
1090 (e_prot & VM_PROT_EXECUTE)?"x":"-",
1100 free(freename, M_TEMP);
1101 vm_map_lock_read(map);
1106 if (last_timestamp != map->timestamp) {
1108 * Look again for the entry because the map was
1109 * modified while it was unlocked. Specifically,
1110 * the entry may have been clipped, merged, or deleted.
1112 vm_map_lookup_entry(map, e_end - 1, &tmp_entry);
1116 vm_map_unlock_read(map);
1123 * Criteria for interface name translation
1125 #define IFP_IS_ETH(ifp) (ifp->if_type == IFT_ETHER)
1128 linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen)
1130 struct ifnet *ifscan;
1133 IFNET_RLOCK_ASSERT();
1135 /* Short-circuit non ethernet interfaces */
1136 if (!IFP_IS_ETH(ifp))
1137 return (strlcpy(buffer, ifp->if_xname, buflen));
1139 /* Determine the (relative) unit number for ethernet interfaces */
1141 TAILQ_FOREACH(ifscan, &V_ifnet, if_link) {
1143 return (snprintf(buffer, buflen, "eth%d", ethno));
1144 if (IFP_IS_ETH(ifscan))
1152 * Filler function for proc/net/dev
1155 linprocfs_donetdev(PFS_FILL_ARGS)
1157 char ifname[16]; /* XXX LINUX_IFNAMSIZ */
1160 sbuf_printf(sb, "%6s|%58s|%s\n"
1162 "Inter-", " Receive", " Transmit",
1164 "bytes packets errs drop fifo frame compressed multicast",
1165 "bytes packets errs drop fifo colls carrier compressed");
1167 CURVNET_SET(TD_TO_VNET(curthread));
1169 TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
1170 linux_ifname(ifp, ifname, sizeof ifname);
1171 sbuf_printf(sb, "%6.6s: ", ifname);
1172 sbuf_printf(sb, "%7ju %7ju %4ju %4ju %4lu %5lu %10lu %9ju ",
1173 (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IBYTES),
1174 (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IPACKETS),
1175 (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IERRORS),
1176 (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IQDROPS),
1177 /* rx_missed_errors */
1178 0UL, /* rx_fifo_errors */
1179 0UL, /* rx_length_errors +
1182 * rx_frame_errors */
1183 0UL, /* rx_compressed */
1184 (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_IMCASTS));
1185 /* XXX-BZ rx only? */
1186 sbuf_printf(sb, "%8ju %7ju %4ju %4ju %4lu %5ju %7lu %10lu\n",
1187 (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OBYTES),
1188 (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OPACKETS),
1189 (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OERRORS),
1190 (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_OQDROPS),
1191 0UL, /* tx_fifo_errors */
1192 (uintmax_t )ifp->if_get_counter(ifp, IFCOUNTER_COLLISIONS),
1193 0UL, /* tx_carrier_errors +
1194 * tx_aborted_errors +
1195 * tx_window_errors +
1196 * tx_heartbeat_errors*/
1197 0UL); /* tx_compressed */
1206 * Filler function for proc/sys/kernel/osrelease
1209 linprocfs_doosrelease(PFS_FILL_ARGS)
1211 char osrelease[LINUX_MAX_UTSNAME];
1213 linux_get_osrelease(td, osrelease);
1214 sbuf_printf(sb, "%s\n", osrelease);
1220 * Filler function for proc/sys/kernel/ostype
1223 linprocfs_doostype(PFS_FILL_ARGS)
1225 char osname[LINUX_MAX_UTSNAME];
1227 linux_get_osname(td, osname);
1228 sbuf_printf(sb, "%s\n", osname);
1234 * Filler function for proc/sys/kernel/version
1237 linprocfs_doosbuild(PFS_FILL_ARGS)
1240 linprocfs_osbuild(td, sb);
1246 * Filler function for proc/sys/kernel/msgmni
1249 linprocfs_domsgmni(PFS_FILL_ARGS)
1252 sbuf_printf(sb, "%d\n", msginfo.msgmni);
1257 * Filler function for proc/sys/kernel/pid_max
1260 linprocfs_dopid_max(PFS_FILL_ARGS)
1263 sbuf_printf(sb, "%i\n", PID_MAX);
1268 * Filler function for proc/sys/kernel/sem
1271 linprocfs_dosem(PFS_FILL_ARGS)
1274 sbuf_printf(sb, "%d %d %d %d\n", seminfo.semmsl, seminfo.semmns,
1275 seminfo.semopm, seminfo.semmni);
1280 * Filler function for proc/scsi/device_info
1283 linprocfs_doscsidevinfo(PFS_FILL_ARGS)
1290 * Filler function for proc/scsi/scsi
1293 linprocfs_doscsiscsi(PFS_FILL_ARGS)
1300 * Filler function for proc/devices
1303 linprocfs_dodevices(PFS_FILL_ARGS)
1306 sbuf_printf(sb, "Character devices:\n");
1308 char_devices = linux_get_char_devices();
1309 sbuf_printf(sb, "%s", char_devices);
1310 linux_free_get_char_devices(char_devices);
1312 sbuf_printf(sb, "\nBlock devices:\n");
1318 * Filler function for proc/cmdline
1321 linprocfs_docmdline(PFS_FILL_ARGS)
1324 sbuf_printf(sb, "BOOT_IMAGE=%s", kernelname);
1325 sbuf_printf(sb, " ro root=302\n");
1330 * Filler function for proc/filesystems
1333 linprocfs_dofilesystems(PFS_FILL_ARGS)
1335 struct vfsconf *vfsp;
1338 TAILQ_FOREACH(vfsp, &vfsconf, vfc_list) {
1339 if (vfsp->vfc_flags & VFCF_SYNTHETIC)
1340 sbuf_printf(sb, "nodev");
1341 sbuf_printf(sb, "\t%s\n", vfsp->vfc_name);
1349 * Filler function for proc/modules
1352 linprocfs_domodules(PFS_FILL_ARGS)
1354 struct linker_file *lf;
1356 TAILQ_FOREACH(lf, &linker_files, link) {
1357 sbuf_printf(sb, "%-20s%8lu%4d\n", lf->filename,
1358 (unsigned long)lf->size, lf->refs);
1365 * Filler function for proc/pid/fd
1368 linprocfs_dofdescfs(PFS_FILL_ARGS)
1372 sbuf_printf(sb, "/dev/fd");
1374 sbuf_printf(sb, "unknown");
1379 * Filler function for proc/pid/limits
1381 static const struct linux_rlimit_ident {
1384 unsigned int rlim_id;
1385 } linux_rlimits_ident[] = {
1386 { "Max cpu time", "seconds", RLIMIT_CPU },
1387 { "Max file size", "bytes", RLIMIT_FSIZE },
1388 { "Max data size", "bytes", RLIMIT_DATA },
1389 { "Max stack size", "bytes", RLIMIT_STACK },
1390 { "Max core file size", "bytes", RLIMIT_CORE },
1391 { "Max resident set", "bytes", RLIMIT_RSS },
1392 { "Max processes", "processes", RLIMIT_NPROC },
1393 { "Max open files", "files", RLIMIT_NOFILE },
1394 { "Max locked memory", "bytes", RLIMIT_MEMLOCK },
1395 { "Max address space", "bytes", RLIMIT_AS },
1396 { "Max file locks", "locks", LINUX_RLIMIT_LOCKS },
1397 { "Max pending signals", "signals", LINUX_RLIMIT_SIGPENDING },
1398 { "Max msgqueue size", "bytes", LINUX_RLIMIT_MSGQUEUE },
1399 { "Max nice priority", "", LINUX_RLIMIT_NICE },
1400 { "Max realtime priority", "", LINUX_RLIMIT_RTPRIO },
1401 { "Max realtime timeout", "us", LINUX_RLIMIT_RTTIME },
1406 linprocfs_doproclimits(PFS_FILL_ARGS)
1408 const struct linux_rlimit_ident *li;
1409 struct plimit *limp;
1417 limp = lim_hold(p->p_limit);
1420 sbuf_printf(sb, "%-26s%-21s%-21s%-21s\n", "Limit", "Soft Limit",
1421 "Hard Limit", "Units");
1422 for (li = linux_rlimits_ident; li->desc != NULL; ++li) {
1423 switch (li->rlim_id)
1425 case LINUX_RLIMIT_LOCKS:
1427 case LINUX_RLIMIT_RTTIME:
1428 rl.rlim_cur = RLIM_INFINITY;
1430 case LINUX_RLIMIT_SIGPENDING:
1431 error = kernel_sysctlbyname(td,
1432 "kern.sigqueue.max_pending_per_proc",
1433 &res, &size, 0, 0, 0, 0);
1439 case LINUX_RLIMIT_MSGQUEUE:
1440 error = kernel_sysctlbyname(td,
1441 "kern.ipc.msgmnb", &res, &size, 0, 0, 0, 0);
1447 case LINUX_RLIMIT_NICE:
1449 case LINUX_RLIMIT_RTPRIO:
1454 rl = limp->pl_rlimit[li->rlim_id];
1457 if (rl.rlim_cur == RLIM_INFINITY)
1458 sbuf_printf(sb, "%-26s%-21s%-21s%-10s\n",
1459 li->desc, "unlimited", "unlimited", li->unit);
1461 sbuf_printf(sb, "%-26s%-21llu%-21llu%-10s\n",
1462 li->desc, (unsigned long long)rl.rlim_cur,
1463 (unsigned long long)rl.rlim_max, li->unit);
1471 * Filler function for proc/sys/kernel/random/uuid
1474 linprocfs_douuid(PFS_FILL_ARGS)
1478 kern_uuidgen(&uuid, 1);
1479 sbuf_printf_uuid(sb, &uuid);
1480 sbuf_printf(sb, "\n");
1485 * Filler function for proc/pid/auxv
1488 linprocfs_doauxv(PFS_FILL_ARGS)
1491 off_t buflen, resid;
1495 * Mimic linux behavior and pass only processes with usermode
1496 * address space as valid. Return zero silently otherwise.
1498 if (p->p_vmspace == &vmspace0)
1501 if (uio->uio_resid == 0)
1503 if (uio->uio_offset < 0 || uio->uio_resid < 0)
1506 asb = sbuf_new_auto();
1509 error = proc_getauxv(td, p, asb);
1511 error = sbuf_finish(asb);
1513 resid = sbuf_len(asb) - uio->uio_offset;
1514 if (resid > uio->uio_resid)
1515 buflen = uio->uio_resid;
1518 if (buflen > IOSIZE_MAX)
1520 if (buflen > MAXPHYS)
1526 error = uiomove(sbuf_data(asb) + uio->uio_offset, buflen, uio);
1535 linprocfs_init(PFS_INIT_ARGS)
1537 struct pfs_node *root;
1538 struct pfs_node *dir;
1543 pfs_create_file(root, "cmdline", &linprocfs_docmdline,
1544 NULL, NULL, NULL, PFS_RD);
1545 pfs_create_file(root, "cpuinfo", &linprocfs_docpuinfo,
1546 NULL, NULL, NULL, PFS_RD);
1547 pfs_create_file(root, "devices", &linprocfs_dodevices,
1548 NULL, NULL, NULL, PFS_RD);
1549 pfs_create_file(root, "filesystems", &linprocfs_dofilesystems,
1550 NULL, NULL, NULL, PFS_RD);
1551 pfs_create_file(root, "loadavg", &linprocfs_doloadavg,
1552 NULL, NULL, NULL, PFS_RD);
1553 pfs_create_file(root, "meminfo", &linprocfs_domeminfo,
1554 NULL, NULL, NULL, PFS_RD);
1556 pfs_create_file(root, "modules", &linprocfs_domodules,
1557 NULL, NULL, NULL, PFS_RD);
1559 pfs_create_file(root, "mounts", &linprocfs_domtab,
1560 NULL, NULL, NULL, PFS_RD);
1561 pfs_create_file(root, "mtab", &linprocfs_domtab,
1562 NULL, NULL, NULL, PFS_RD);
1563 pfs_create_file(root, "partitions", &linprocfs_dopartitions,
1564 NULL, NULL, NULL, PFS_RD);
1565 pfs_create_link(root, "self", &procfs_docurproc,
1566 NULL, NULL, NULL, 0);
1567 pfs_create_file(root, "stat", &linprocfs_dostat,
1568 NULL, NULL, NULL, PFS_RD);
1569 pfs_create_file(root, "swaps", &linprocfs_doswaps,
1570 NULL, NULL, NULL, PFS_RD);
1571 pfs_create_file(root, "uptime", &linprocfs_douptime,
1572 NULL, NULL, NULL, PFS_RD);
1573 pfs_create_file(root, "version", &linprocfs_doversion,
1574 NULL, NULL, NULL, PFS_RD);
1577 dir = pfs_create_dir(root, "net", NULL, NULL, NULL, 0);
1578 pfs_create_file(dir, "dev", &linprocfs_donetdev,
1579 NULL, NULL, NULL, PFS_RD);
1581 /* /proc/<pid>/... */
1582 dir = pfs_create_dir(root, "pid", NULL, NULL, NULL, PFS_PROCDEP);
1583 pfs_create_file(dir, "cmdline", &linprocfs_doproccmdline,
1584 NULL, NULL, NULL, PFS_RD);
1585 pfs_create_link(dir, "cwd", &linprocfs_doproccwd,
1586 NULL, NULL, NULL, 0);
1587 pfs_create_file(dir, "environ", &linprocfs_doprocenviron,
1588 NULL, &procfs_candebug, NULL, PFS_RD);
1589 pfs_create_link(dir, "exe", &procfs_doprocfile,
1590 NULL, &procfs_notsystem, NULL, 0);
1591 pfs_create_file(dir, "maps", &linprocfs_doprocmaps,
1592 NULL, NULL, NULL, PFS_RD);
1593 pfs_create_file(dir, "mem", &procfs_doprocmem,
1594 &procfs_attr, &procfs_candebug, NULL, PFS_RDWR|PFS_RAW);
1595 pfs_create_file(dir, "mounts", &linprocfs_domtab,
1596 NULL, NULL, NULL, PFS_RD);
1597 pfs_create_link(dir, "root", &linprocfs_doprocroot,
1598 NULL, NULL, NULL, 0);
1599 pfs_create_file(dir, "stat", &linprocfs_doprocstat,
1600 NULL, NULL, NULL, PFS_RD);
1601 pfs_create_file(dir, "statm", &linprocfs_doprocstatm,
1602 NULL, NULL, NULL, PFS_RD);
1603 pfs_create_file(dir, "status", &linprocfs_doprocstatus,
1604 NULL, NULL, NULL, PFS_RD);
1605 pfs_create_link(dir, "fd", &linprocfs_dofdescfs,
1606 NULL, NULL, NULL, 0);
1607 pfs_create_file(dir, "auxv", &linprocfs_doauxv,
1608 NULL, &procfs_candebug, NULL, PFS_RD|PFS_RAWRD);
1609 pfs_create_file(dir, "limits", &linprocfs_doproclimits,
1610 NULL, NULL, NULL, PFS_RD);
1612 /* /proc/scsi/... */
1613 dir = pfs_create_dir(root, "scsi", NULL, NULL, NULL, 0);
1614 pfs_create_file(dir, "device_info", &linprocfs_doscsidevinfo,
1615 NULL, NULL, NULL, PFS_RD);
1616 pfs_create_file(dir, "scsi", &linprocfs_doscsiscsi,
1617 NULL, NULL, NULL, PFS_RD);
1620 dir = pfs_create_dir(root, "sys", NULL, NULL, NULL, 0);
1621 /* /proc/sys/kernel/... */
1622 dir = pfs_create_dir(dir, "kernel", NULL, NULL, NULL, 0);
1623 pfs_create_file(dir, "osrelease", &linprocfs_doosrelease,
1624 NULL, NULL, NULL, PFS_RD);
1625 pfs_create_file(dir, "ostype", &linprocfs_doostype,
1626 NULL, NULL, NULL, PFS_RD);
1627 pfs_create_file(dir, "version", &linprocfs_doosbuild,
1628 NULL, NULL, NULL, PFS_RD);
1629 pfs_create_file(dir, "msgmni", &linprocfs_domsgmni,
1630 NULL, NULL, NULL, PFS_RD);
1631 pfs_create_file(dir, "pid_max", &linprocfs_dopid_max,
1632 NULL, NULL, NULL, PFS_RD);
1633 pfs_create_file(dir, "sem", &linprocfs_dosem,
1634 NULL, NULL, NULL, PFS_RD);
1636 /* /proc/sys/kernel/random/... */
1637 dir = pfs_create_dir(dir, "random", NULL, NULL, NULL, 0);
1638 pfs_create_file(dir, "uuid", &linprocfs_douuid,
1639 NULL, NULL, NULL, PFS_RD);
1648 linprocfs_uninit(PFS_INIT_ARGS)
1651 /* nothing to do, pseudofs will GC */
1655 PSEUDOFS(linprocfs, 1, PR_ALLOW_MOUNT_LINPROCFS);
1656 #if defined(__amd64__)
1657 MODULE_DEPEND(linprocfs, linux_common, 1, 1, 1);
1659 MODULE_DEPEND(linprocfs, linux, 1, 1, 1);
1661 MODULE_DEPEND(linprocfs, procfs, 1, 1, 1);
1662 MODULE_DEPEND(linprocfs, sysvmsg, 1, 1, 1);
1663 MODULE_DEPEND(linprocfs, sysvsem, 1, 1, 1);