History log of /freebsd-10.0-release/usr.bin/procstat/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
259128 09-Dec-2013 gjb

Remove svn:mergeinfo from the releng/10.0 branch.

After branch creation from stable/10, the stable/10 branch mergeinfo
was moved to the root of the branch.

Since there have not been any merges from stable/10 to releng/10.0
yet, we do not need to track any of the existing mergeinfo here.

Merges to releng/10.0 should now be done to the root of the branch.

For future branches during the release cycle, unless otherwise noted,
this change will be done as part of the stable/ and releng/ branch
creation.

Discussed with: peter
Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-10.0-release/MAINTAINERS
/freebsd-10.0-release/Makefile.inc1
/freebsd-10.0-release/ObsoleteFiles.inc
/freebsd-10.0-release/UPDATING
/freebsd-10.0-release/bin/df
/freebsd-10.0-release/bin/freebsd-version
/freebsd-10.0-release/cddl
/freebsd-10.0-release/cddl/contrib/opensolaris
/freebsd-10.0-release/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-10.0-release/cddl/contrib/opensolaris/cmd/zfs
/freebsd-10.0-release/cddl/contrib/opensolaris/lib/libzfs
/freebsd-10.0-release/contrib/apr
/freebsd-10.0-release/contrib/apr-util
/freebsd-10.0-release/contrib/atf
/freebsd-10.0-release/contrib/binutils
/freebsd-10.0-release/contrib/bmake
/freebsd-10.0-release/contrib/byacc
/freebsd-10.0-release/contrib/bzip2
/freebsd-10.0-release/contrib/com_err
/freebsd-10.0-release/contrib/compiler-rt
/freebsd-10.0-release/contrib/dialog
/freebsd-10.0-release/contrib/dtc
/freebsd-10.0-release/contrib/ee
/freebsd-10.0-release/contrib/expat
/freebsd-10.0-release/contrib/file
/freebsd-10.0-release/contrib/gcc
/freebsd-10.0-release/contrib/gdb
/freebsd-10.0-release/contrib/gdtoa
/freebsd-10.0-release/contrib/groff
/freebsd-10.0-release/contrib/ipfilter
/freebsd-10.0-release/contrib/ipfilter/ml_ipl.c
/freebsd-10.0-release/contrib/ipfilter/mlfk_ipl.c
/freebsd-10.0-release/contrib/ipfilter/mlh_rule.c
/freebsd-10.0-release/contrib/ipfilter/mli_ipl.c
/freebsd-10.0-release/contrib/ipfilter/mln_ipl.c
/freebsd-10.0-release/contrib/ipfilter/mls_ipl.c
/freebsd-10.0-release/contrib/ldns
/freebsd-10.0-release/contrib/less
/freebsd-10.0-release/contrib/libarchive
/freebsd-10.0-release/contrib/libarchive/cpio
/freebsd-10.0-release/contrib/libarchive/libarchive
/freebsd-10.0-release/contrib/libarchive/libarchive_fe
/freebsd-10.0-release/contrib/libarchive/tar
/freebsd-10.0-release/contrib/libc++
/freebsd-10.0-release/contrib/libc-vis
/freebsd-10.0-release/contrib/libcxxrt
/freebsd-10.0-release/contrib/libexecinfo
/freebsd-10.0-release/contrib/libpcap
/freebsd-10.0-release/contrib/libstdc++
/freebsd-10.0-release/contrib/llvm
/freebsd-10.0-release/contrib/llvm/tools/clang
/freebsd-10.0-release/contrib/mtree
/freebsd-10.0-release/contrib/ncurses
/freebsd-10.0-release/contrib/netcat
/freebsd-10.0-release/contrib/ntp
/freebsd-10.0-release/contrib/nvi
/freebsd-10.0-release/contrib/one-true-awk
/freebsd-10.0-release/contrib/openbsm
/freebsd-10.0-release/contrib/openpam
/freebsd-10.0-release/contrib/openresolv
/freebsd-10.0-release/contrib/pf
/freebsd-10.0-release/contrib/sendmail
/freebsd-10.0-release/contrib/serf
/freebsd-10.0-release/contrib/smbfs
/freebsd-10.0-release/contrib/subversion
/freebsd-10.0-release/contrib/tcpdump
/freebsd-10.0-release/contrib/tcsh
/freebsd-10.0-release/contrib/tnftp
/freebsd-10.0-release/contrib/top
/freebsd-10.0-release/contrib/top/install-sh
/freebsd-10.0-release/contrib/tzcode/stdtime
/freebsd-10.0-release/contrib/tzcode/zic
/freebsd-10.0-release/contrib/tzdata
/freebsd-10.0-release/contrib/unbound
/freebsd-10.0-release/contrib/wpa
/freebsd-10.0-release/contrib/xz
/freebsd-10.0-release/crypto/heimdal
/freebsd-10.0-release/crypto/openssh
/freebsd-10.0-release/crypto/openssl
/freebsd-10.0-release/etc
/freebsd-10.0-release/etc/rc.d
/freebsd-10.0-release/gnu/lib
/freebsd-10.0-release/gnu/usr.bin/binutils
/freebsd-10.0-release/gnu/usr.bin/cc/cc_tools
/freebsd-10.0-release/gnu/usr.bin/gdb
/freebsd-10.0-release/include
/freebsd-10.0-release/lib
/freebsd-10.0-release/lib/libc
/freebsd-10.0-release/lib/libc/stdtime
/freebsd-10.0-release/lib/libc_nonshared
/freebsd-10.0-release/lib/libfetch
/freebsd-10.0-release/lib/libiconv_modules
/freebsd-10.0-release/lib/libsmb
/freebsd-10.0-release/lib/libthr
/freebsd-10.0-release/lib/libutil
/freebsd-10.0-release/lib/libvmmapi
/freebsd-10.0-release/lib/libyaml
/freebsd-10.0-release/lib/libz
/freebsd-10.0-release/release
/freebsd-10.0-release/release/doc
/freebsd-10.0-release/sbin
/freebsd-10.0-release/sbin/camcontrol
/freebsd-10.0-release/sbin/dumpon
/freebsd-10.0-release/sbin/hastd
/freebsd-10.0-release/sbin/ifconfig
/freebsd-10.0-release/sbin/ipfw
/freebsd-10.0-release/sbin/nvmecontrol
/freebsd-10.0-release/share
/freebsd-10.0-release/share/examples/bhyve
/freebsd-10.0-release/share/i18n/csmapper/JIS
/freebsd-10.0-release/share/i18n/esdb/EUC
/freebsd-10.0-release/share/man
/freebsd-10.0-release/share/man/man4
/freebsd-10.0-release/share/man/man4/bhyve.4
/freebsd-10.0-release/share/man/man5
/freebsd-10.0-release/share/man/man7
/freebsd-10.0-release/share/man/man8
/freebsd-10.0-release/share/misc
/freebsd-10.0-release/share/mk
/freebsd-10.0-release/share/mk/bsd.arch.inc.mk
/freebsd-10.0-release/share/syscons
/freebsd-10.0-release/share/zoneinfo
/freebsd-10.0-release/sys
/freebsd-10.0-release/sys/amd64/include/vmm.h
/freebsd-10.0-release/sys/amd64/include/vmm_dev.h
/freebsd-10.0-release/sys/amd64/include/vmm_instruction_emul.h
/freebsd-10.0-release/sys/amd64/include/xen
/freebsd-10.0-release/sys/amd64/vmm
/freebsd-10.0-release/sys/boot
/freebsd-10.0-release/sys/boot/i386/efi
/freebsd-10.0-release/sys/boot/ia64/efi
/freebsd-10.0-release/sys/boot/ia64/ski
/freebsd-10.0-release/sys/boot/powerpc/boot1.chrp
/freebsd-10.0-release/sys/boot/powerpc/ofw
/freebsd-10.0-release/sys/cddl/contrib/opensolaris
/freebsd-10.0-release/sys/conf
/freebsd-10.0-release/sys/contrib/dev/acpica
/freebsd-10.0-release/sys/contrib/dev/acpica/changes.txt
/freebsd-10.0-release/sys/contrib/dev/acpica/common
/freebsd-10.0-release/sys/contrib/dev/acpica/compiler
/freebsd-10.0-release/sys/contrib/dev/acpica/components/debugger
/freebsd-10.0-release/sys/contrib/dev/acpica/components/disassembler
/freebsd-10.0-release/sys/contrib/dev/acpica/components/dispatcher
/freebsd-10.0-release/sys/contrib/dev/acpica/components/events
/freebsd-10.0-release/sys/contrib/dev/acpica/components/executer
/freebsd-10.0-release/sys/contrib/dev/acpica/components/hardware
/freebsd-10.0-release/sys/contrib/dev/acpica/components/namespace
/freebsd-10.0-release/sys/contrib/dev/acpica/components/parser
/freebsd-10.0-release/sys/contrib/dev/acpica/components/resources
/freebsd-10.0-release/sys/contrib/dev/acpica/components/tables
/freebsd-10.0-release/sys/contrib/dev/acpica/components/utilities
/freebsd-10.0-release/sys/contrib/dev/acpica/include
/freebsd-10.0-release/sys/contrib/dev/acpica/os_specific
/freebsd-10.0-release/sys/contrib/ipfilter
/freebsd-10.0-release/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
/freebsd-10.0-release/sys/contrib/ipfilter/netinet/ip_raudio_pxy.c
/freebsd-10.0-release/sys/contrib/libfdt
/freebsd-10.0-release/sys/contrib/octeon-sdk
/freebsd-10.0-release/sys/contrib/x86emu
/freebsd-10.0-release/sys/dev/bvm
/freebsd-10.0-release/sys/dev/fdt/fdt_ic_if.m
/freebsd-10.0-release/sys/dev/hyperv
/freebsd-10.0-release/sys/modules/hyperv
/freebsd-10.0-release/sys/modules/vmm
/freebsd-10.0-release/sys/x86/include/acpica_machdep.h
/freebsd-10.0-release/tools
/freebsd-10.0-release/tools/build
/freebsd-10.0-release/tools/build/options
/freebsd-10.0-release/tools/tools/atsectl
/freebsd-10.0-release/usr.bin/calendar
/freebsd-10.0-release/usr.bin/csup
/freebsd-10.0-release/usr.bin/iscsictl
/freebsd-10.0-release/usr.bin/procstat
/freebsd-10.0-release/usr.sbin
/freebsd-10.0-release/usr.sbin/bhyve
/freebsd-10.0-release/usr.sbin/bhyvectl
/freebsd-10.0-release/usr.sbin/bhyveload
/freebsd-10.0-release/usr.sbin/bsdconfig
/freebsd-10.0-release/usr.sbin/bsdinstall
/freebsd-10.0-release/usr.sbin/ctladm
/freebsd-10.0-release/usr.sbin/ctld
/freebsd-10.0-release/usr.sbin/freebsd-update
/freebsd-10.0-release/usr.sbin/jail
/freebsd-10.0-release/usr.sbin/mergemaster
/freebsd-10.0-release/usr.sbin/mount_smbfs
/freebsd-10.0-release/usr.sbin/ndiscvt
/freebsd-10.0-release/usr.sbin/pkg
/freebsd-10.0-release/usr.sbin/rtadvctl
/freebsd-10.0-release/usr.sbin/rtadvd
/freebsd-10.0-release/usr.sbin/rtsold
/freebsd-10.0-release/usr.sbin/zic
259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

258324 18-Nov-2013 pjd

MFC r258148,r258149,r258150,r258152,r258153,r258154,r258181,r258182:

r258148:

Add a note that this file is compiled as part of the kernel and libc.

Requested by: kib

r258149:

Change cap_rights_merge(3) and cap_rights_remove(3) to return pointer
to the destination cap_rights_t structure.

This already matches manual page.

r258150:

Sync return value with actual implementation.

r258151:

Style.

r258152:

Precisely document capability rights here too (they are already documented
in rights(4)).

r258153:

The CAP_LINKAT, CAP_MKDIRAT, CAP_MKFIFOAT, CAP_MKNODAT, CAP_RENAMEAT,
CAP_SYMLINKAT and CAP_UNLINKAT capability rights make no sense without
the CAP_LOOKUP right, so include this rights.

r258154:

- Move CAP_EXTATTR_* and CAP_ACL_* rights to index 1 to have more room
in index 0 for the future.
- Move CAP_BINDAT and CAP_CONNECTAT rights to index 0 so we can include
CAP_LOOKUP right in them.
- Shuffle the bits around so there are no gaps. This is last chance to do
that as all moved rights are not used yet.

r258181:

Replace CAP_POLL_EVENT and CAP_POST_EVENT capability rights (which I had
a very hard time to fully understand) with much more intuitive rights:

CAP_EVENT - when set on descriptor, the descriptor can be monitored
with syscalls like select(2), poll(2), kevent(2).

CAP_KQUEUE_EVENT - When set on a kqueue descriptor, the kevent(2)
syscall can be called on this kqueue to with the eventlist
argument set to non-NULL value; in other words the given
kqueue descriptor can be used to monitor other descriptors.
CAP_KQUEUE_CHANGE - When set on a kqueue descriptor, the kevent(2)
syscall can be called on this kqueue to with the changelist
argument set to non-NULL value; in other words it allows to
modify events monitored with the given kqueue descriptor.

Add alias CAP_KQUEUE, which allows for both CAP_KQUEUE_EVENT and
CAP_KQUEUE_CHANGE.

Add backward compatibility define CAP_POLL_EVENT which is equal to CAP_EVENT.

r258182:

Correct right names.

Sponsored by: The FreeBSD Foundation
Approved by: re (kib)


257674 05-Nov-2013 markj

MFC r257234:
With r247602, the "c" flag is no longer printed as a file descriptor flag.

Approved by: re (gjb)


256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


255699 19-Sep-2013 bdrewery

cap_new(2) and cap_getrights2) were replaced with cap_rights_limit(2)
and cap_rights_get(2) in r247602

Reviewed by: pjd
Approved by: gjb
Approved by: re (rodrigc)


255219 05-Sep-2013 pjd

Change the cap_rights_t type from uint64_t to a structure that we can extend
in the future in a backward compatible (API and ABI) way.

The cap_rights_t represents capability rights. We used to use one bit to
represent one right, but we are running out of spare bits. Currently the new
structure provides place for 114 rights (so 50 more than the previous
cap_rights_t), but it is possible to grow the structure to hold at least 285
rights, although we can make it even larger if 285 rights won't be enough.

The structure definition looks like this:

struct cap_rights {
uint64_t cr_rights[CAP_RIGHTS_VERSION + 2];
};

The initial CAP_RIGHTS_VERSION is 0.

The top two bits in the first element of the cr_rights[] array contain total
number of elements in the array - 2. This means if those two bits are equal to
0, we have 2 array elements.

The top two bits in all remaining array elements should be 0.
The next five bits in all array elements contain array index. Only one bit is
used and bit position in this five-bits range defines array index. This means
there can be at most five array elements in the future.

To define new right the CAPRIGHT() macro must be used. The macro takes two
arguments - an array index and a bit to set, eg.

#define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL)

We still support aliases that combine few rights, but the rights have to belong
to the same array element, eg:

#define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL)
#define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL)

#define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP)

There is new API to manage the new cap_rights_t structure:

cap_rights_t *cap_rights_init(cap_rights_t *rights, ...);
void cap_rights_set(cap_rights_t *rights, ...);
void cap_rights_clear(cap_rights_t *rights, ...);
bool cap_rights_is_set(const cap_rights_t *rights, ...);

bool cap_rights_is_valid(const cap_rights_t *rights);
void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);

Capability rights to the cap_rights_init(), cap_rights_set(),
cap_rights_clear() and cap_rights_is_set() functions are provided by
separating them with commas, eg:

cap_rights_t rights;

cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT);

There is no need to terminate the list of rights, as those functions are
actually macros that take care of the termination, eg:

#define cap_rights_set(rights, ...) \
__cap_rights_set((rights), __VA_ARGS__, 0ULL)
void __cap_rights_set(cap_rights_t *rights, ...);

Thanks to using one bit as an array index we can assert in those functions that
there are no two rights belonging to different array elements provided
together. For example this is illegal and will be detected, because CAP_LOOKUP
belongs to element 0 and CAP_PDKILL to element 1:

cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL);

Providing several rights that belongs to the same array's element this way is
correct, but is not advised. It should only be used for aliases definition.

This commit also breaks compatibility with some existing Capsicum system calls,
but I see no other way to do that. This should be fine as Capsicum is still
experimental and this change is not going to 9.x.

Sponsored by: The FreeBSD Foundation


254485 18-Aug-2013 pjd

Make the "FD" column one character wider, so that "trace" can also align
properly.


249686 20-Apr-2013 trociny

Make use of newly added libprocstat(3) ability to extract procstat
info from a process core file.

So now one can run procstat(1) on a process core e.g. to get a list of
files opened by a process when it crashed:

root@lisa:/ # procstat -f /root/vi.core
PID COMM FD T V FLAGS REF OFFSET PRO NAME
658 vi text v r r-------- - - - /usr/bin/vi
658 vi ctty v c rw------- - - - /dev/pts/0
658 vi cwd v d r-------- - - - /root
658 vi root v d r-------- - - - /
658 vi 0 v c rw------- 11 3208 - /dev/pts/0
658 vi 1 v c rw------- 11 3208 - /dev/pts/0
658 vi 2 v c rw------- 11 3208 - /dev/pts/0
658 vi 3 v r r----n-l- 1 0 - /tmp/vi.0AYKz3Lps7
658 vi 4 v r rw------- 1 0 - /var/tmp/vi.recover/vi.GaGYsz
658 vi 5 v r rw------- 1 0 - -

PR: kern/173723
Suggested by: jhb
MFC after: 1 month


249685 20-Apr-2013 trociny

Use procstat_getkstack(3) for retrieving process kernel stacks
instead of direct sysctl calls.

MFC after: 1 month


249683 20-Apr-2013 trociny

Use libprocstat(3) to retrieve ELF auxiliary vector.

MFC after: 1 month


249680 20-Apr-2013 trociny

Use libprocstat(3) to retrieve process command line arguments and
environment variables.

MFC after: 1 month


249678 20-Apr-2013 trociny

Use libprocstat(3) when retrieving binary information for a process.

MFC after: 1 month


249675 20-Apr-2013 trociny

Use procstat_getrlimit(3) for retrieving rlimit information instead of
direct sysctl calls.

MFC after: 1 month


249673 20-Apr-2013 trociny

Use procstat_getumask(3) for retrieving umaks information instead of
direct sysctl.

MFC after: 1 month


249671 20-Apr-2013 trociny

Use procstat_getgroups(3) for retrieving groups information instead of
direct sysctl.

MFC after: 1 month


249669 20-Apr-2013 trociny

Use more generic procstat_getvmmap(3) for retrieving VM layout of a process.

MFC after: 1 month


249668 20-Apr-2013 trociny

Use procstat_getprocs(3) for retrieving thread information instead of
direct sysctl calls.

MFC after: 1 month


247667 02-Mar-2013 pjd

- Implement two new system calls:

int bindat(int fd, int s, const struct sockaddr *addr, socklen_t addrlen);
int connectat(int fd, int s, const struct sockaddr *name, socklen_t namelen);

which allow to bind and connect respectively to a UNIX domain socket with a
path relative to the directory associated with the given file descriptor 'fd'.

- Add manual pages for the new syscalls.

- Make the new syscalls available for processes in capability mode sandbox.

- Add capability rights CAP_BINDAT and CAP_CONNECTAT that has to be present on
the directory descriptor for the syscalls to work.

- Update audit(4) to support those two new syscalls and to handle path
in sockaddr_un structure relative to the given directory descriptor.

- Update procstat(1) to recognize the new capability rights.

- Document the new capability rights in cap_rights_limit(2).

Sponsored by: The FreeBSD Foundation
Discussed with: rwatson, jilles, kib, des


247602 02-Mar-2013 pjd

Merge Capsicum overhaul:

- Capability is no longer separate descriptor type. Now every descriptor
has set of its own capability rights.

- The cap_new(2) system call is left, but it is no longer documented and
should not be used in new code.

- The new syscall cap_rights_limit(2) should be used instead of
cap_new(2), which limits capability rights of the given descriptor
without creating a new one.

- The cap_getrights(2) syscall is renamed to cap_rights_get(2).

- If CAP_IOCTL capability right is present we can further reduce allowed
ioctls list with the new cap_ioctls_limit(2) syscall. List of allowed
ioctls can be retrived with cap_ioctls_get(2) syscall.

- If CAP_FCNTL capability right is present we can further reduce fcntls
that can be used with the new cap_fcntls_limit(2) syscall and retrive
them with cap_fcntls_get(2).

- To support ioctl and fcntl white-listing the filedesc structure was
heavly modified.

- The audit subsystem, kdump and procstat tools were updated to
recognize new syscalls.

- Capability rights were revised and eventhough I tried hard to provide
backward API and ABI compatibility there are some incompatible changes
that are described in detail below:

CAP_CREATE old behaviour:
- Allow for openat(2)+O_CREAT.
- Allow for linkat(2).
- Allow for symlinkat(2).
CAP_CREATE new behaviour:
- Allow for openat(2)+O_CREAT.

Added CAP_LINKAT:
- Allow for linkat(2). ABI: Reuses CAP_RMDIR bit.
- Allow to be target for renameat(2).

Added CAP_SYMLINKAT:
- Allow for symlinkat(2).

Removed CAP_DELETE. Old behaviour:
- Allow for unlinkat(2) when removing non-directory object.
- Allow to be source for renameat(2).

Removed CAP_RMDIR. Old behaviour:
- Allow for unlinkat(2) when removing directory.

Added CAP_RENAMEAT:
- Required for source directory for the renameat(2) syscall.

Added CAP_UNLINKAT (effectively it replaces CAP_DELETE and CAP_RMDIR):
- Allow for unlinkat(2) on any object.
- Required if target of renameat(2) exists and will be removed by this
call.

Removed CAP_MAPEXEC.

CAP_MMAP old behaviour:
- Allow for mmap(2) with any combination of PROT_NONE, PROT_READ and
PROT_WRITE.
CAP_MMAP new behaviour:
- Allow for mmap(2)+PROT_NONE.

Added CAP_MMAP_R:
- Allow for mmap(PROT_READ).
Added CAP_MMAP_W:
- Allow for mmap(PROT_WRITE).
Added CAP_MMAP_X:
- Allow for mmap(PROT_EXEC).
Added CAP_MMAP_RW:
- Allow for mmap(PROT_READ | PROT_WRITE).
Added CAP_MMAP_RX:
- Allow for mmap(PROT_READ | PROT_EXEC).
Added CAP_MMAP_WX:
- Allow for mmap(PROT_WRITE | PROT_EXEC).
Added CAP_MMAP_RWX:
- Allow for mmap(PROT_READ | PROT_WRITE | PROT_EXEC).

Renamed CAP_MKDIR to CAP_MKDIRAT.
Renamed CAP_MKFIFO to CAP_MKFIFOAT.
Renamed CAP_MKNODE to CAP_MKNODEAT.

CAP_READ old behaviour:
- Allow pread(2).
- Disallow read(2), readv(2) (if there is no CAP_SEEK).
CAP_READ new behaviour:
- Allow read(2), readv(2).
- Disallow pread(2) (CAP_SEEK was also required).

CAP_WRITE old behaviour:
- Allow pwrite(2).
- Disallow write(2), writev(2) (if there is no CAP_SEEK).
CAP_WRITE new behaviour:
- Allow write(2), writev(2).
- Disallow pwrite(2) (CAP_SEEK was also required).

Added convinient defines:

#define CAP_PREAD (CAP_SEEK | CAP_READ)
#define CAP_PWRITE (CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_R (CAP_MMAP | CAP_SEEK | CAP_READ)
#define CAP_MMAP_W (CAP_MMAP | CAP_SEEK | CAP_WRITE)
#define CAP_MMAP_X (CAP_MMAP | CAP_SEEK | 0x0000000000000008ULL)
#define CAP_MMAP_RW (CAP_MMAP_R | CAP_MMAP_W)
#define CAP_MMAP_RX (CAP_MMAP_R | CAP_MMAP_X)
#define CAP_MMAP_WX (CAP_MMAP_W | CAP_MMAP_X)
#define CAP_MMAP_RWX (CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X)
#define CAP_RECV CAP_READ
#define CAP_SEND CAP_WRITE

#define CAP_SOCK_CLIENT \
(CAP_CONNECT | CAP_GETPEERNAME | CAP_GETSOCKNAME | CAP_GETSOCKOPT | \
CAP_PEELOFF | CAP_RECV | CAP_SEND | CAP_SETSOCKOPT | CAP_SHUTDOWN)
#define CAP_SOCK_SERVER \
(CAP_ACCEPT | CAP_BIND | CAP_GETPEERNAME | CAP_GETSOCKNAME | \
CAP_GETSOCKOPT | CAP_LISTEN | CAP_PEELOFF | CAP_RECV | CAP_SEND | \
CAP_SETSOCKOPT | CAP_SHUTDOWN)

Added defines for backward API compatibility:

#define CAP_MAPEXEC CAP_MMAP_X
#define CAP_DELETE CAP_UNLINKAT
#define CAP_MKDIR CAP_MKDIRAT
#define CAP_RMDIR CAP_UNLINKAT
#define CAP_MKFIFO CAP_MKFIFOAT
#define CAP_MKNOD CAP_MKNODAT
#define CAP_SOCK_ALL (CAP_SOCK_CLIENT | CAP_SOCK_SERVER)

Sponsored by: The FreeBSD Foundation
Reviewed by: Christoph Mallon <christoph.mallon@gmx.de>
Many aspects discussed with: rwatson, benl, jonathan
ABI compatibility discussed with: kib


246644 11-Feb-2013 pjd

Capability rights for process management via process descriptors do exist
already, so uncomment them.

Sponsored by: The FreeBSD Foundation


246643 11-Feb-2013 pjd

Add CAP_MKNOD right.

Sponsored by: The FreeBSD Foundation


245345 12-Jan-2013 mjg

procstat: only one mode flag can be specified, but required check for 'i'
and 'j' modes was missing. Fix that.

MFC after: 3 days


241117 02-Oct-2012 eadler

add SG state type

PR: bin/171664
Submitted by: Jan Beich jbeich@tormail.org
Approved by: cperciva
MFC after: 1 week


240546 16-Sep-2012 kib

Handle AT_TIMEKEEP in procstat(1) -x [1]. Remove the AT_COUNT switch
case, since AT_COUNT is not an aux vector, it is the counter of total
number of defined vectors.

PR: bin/171662 [1]
MFC after: 1 week


240081 04-Sep-2012 trociny

Free memory allocated by procstat_getfiles(), which may make difference
when procstat(1) is run with -a option.

Submitted by: Daniel Dettlaff <dmilith gmail com>
MFC after: 1 week


238753 24-Jul-2012 trociny

Align the header with output.

MFC after: 3 days


238527 16-Jul-2012 pgj

- Add support for displaying process stack memory regions.

Approved by: rwatson
MFC after: 3 days


238086 03-Jul-2012 trociny

Fix style.

MFC after: 3 days


235642 19-May-2012 marcel

Bring DPADD in sync with LDADD.


233760 01-Apr-2012 jhb

Export some more useful info about shared memory objects to userland
via procstat(1) and fstat(1):
- Change shm file descriptors to track the pathname they are associated
with and add a shm_path() method to copy the path out to a caller-supplied
buffer.
- Use the fo_stat() method of shared memory objects and shm_path() to
export the path, mode, and size of a shared memory object via
struct kinfo_file.
- Add a struct shmstat to the libprocstat(3) interface along with a
procstat_get_shm_info() to export the mode and size of a shared memory
object.
- Change procstat to always print out the path for a given object if it
is valid.
- Teach fstat about shared memory objects and to display their path,
mode, and size.

MFC after: 2 weeks


233648 29-Mar-2012 eadler

Remove trailing whitespace per mdoc lint warning

Disussed with: gavin
No objection from: doc
Approved by: joel
MFC after: 3 days


233390 23-Mar-2012 trociny

When displaying binary information show also osreldate.

Suggested by: kib
MFC after: 2 weeks


232300 29-Feb-2012 pluknet

Update the description for -s flag after r232182.
When displaying security credential information show also process umask.

X-MFC-with: r232182


232182 26-Feb-2012 trociny

When displaying security credential information show also process umask.

Submitted by: Dmitry Banschikov <me ubique spb ru>
Discussed with: rwatson
MFC after: 2 weeks


230753 29-Jan-2012 trociny

Always return 0 if the sysctl failed.

This fixes the bug: when procstat -xa was run and the sysctl for a
process returned ESRCH or EPERM, for this process procstat output the
result collected for the previous successful process.


230548 25-Jan-2012 trociny

After the recent changes there is no need in rlimit array any more.

Submitted by: Andrey Zonov <andrey at zonov.org>
MFC after: 1 week


230471 22-Jan-2012 trociny

Make procstat -l to work with the new version of kern.proc.rlimit.

Submitted by: Andrey Zonov <andrey at zonov.org>
MFC after: 2 weeks


228447 12-Dec-2011 trociny

Make 64-bit procstat output ELF auxiliary vectors for 32-bit processes.

Reviewed by: kib
MFC after: 1 week


228446 12-Dec-2011 trociny

Make procstat -l output similar to the output of limits(1).

Suggested by: jhb
MFC after: 1 week


228289 05-Dec-2011 trociny

Don't output a warning if kern.proc.auxv sysctl has returned EPERM.
After r228288 this is rather a normal situation.

MFC after: 1 week


228090 28-Nov-2011 trociny

Update SYNOPSIS to include the flags added recently.

Spotted by: jhb


228049 28-Nov-2011 trociny

Cast a_val on printing. This fixes build on mips.


228025 27-Nov-2011 trociny

Make proctstat -x output more readable.

This also fixes the issue, spotted by mdf, with values that were
printed as decimal and had hex prefixes.

Discussed with: kib, rwatson
MFC after: 2 weeks


227956 24-Nov-2011 trociny

usr.bin/procstat

Add -l flag to display resource limits.

PR: bin/161257
Reviewed by: kib
MFC after: 2 weeks


227873 23-Nov-2011 trociny

Fix build, hopefully.

Reviewed by: kib


227838 22-Nov-2011 trociny

Add new options, -e and -x, to display process environment variables
and ELF auxiliary vectors.

MFC after: 2 weeks


227355 08-Nov-2011 trociny

Bumb date after r227317.

Reminded by: pluknet


227317 07-Nov-2011 trociny

When displaying process virtual memory mappings print superpage
mapping flag.

Submitted by: Mel Flynn <mel.flynn+fbsd.hackers@mailing.thruhere.net>
Reviewed by: alc, rwatson


224859 14-Aug-2011 rwatson

Updates to libprocstat(3) and procstat(1) to allow monitoring Capsicum
capability mode and capabilities.

Right now no attempt is made to unwrap capabilities when operating on
a crashdump, so further refinement is required.

Approved by: re (bz)
Sponsored by: Google Inc


224199 18-Jul-2011 bz

Rename ki_ocomm to ki_tdname and OCOMMLEN to TDNAMLEN.
Provide backward compatibility defines under BURN_BRIDGES.

Suggested by: jhb
Reviewed by: emaste
Sponsored by: Sandvine Incorporated
Approved by: re (kib)


223758 04-Jul-2011 attilio

With retirement of cpumask_t and usage of cpuset_t for representing a
mask of CPUs, pc_other_cpus and pc_cpumask become highly inefficient.

Remove them and replace their usage with custom pc_cpuid magic (as,
atm, pc_cpumask can be easilly represented by (1 << pc_cpuid) and
pc_other_cpus by (all_cpus & ~(1 << pc_cpuid))).

This change is not targeted for MFC because of struct pcpu members
removal and dependency by cpumask_t retirement.

MD review by: marcel, marius, alc
Tested by: pluknet
MD testing by: marcel, marius, gonzo, andreast


222813 07-Jun-2011 attilio

etire the cpumask_t type and replace it with cpuset_t usage.

This is intended to fix the bug where cpu mask objects are
capped to 32. MAXCPU, then, can now arbitrarely bumped to whatever
value. Anyway, as long as several structures in the kernel are
statically allocated and sized as MAXCPU, it is suggested to keep it
as low as possible for the time being.

Technical notes on this commit itself:
- More functions to handle with cpuset_t objects are introduced.
The most notable are cpusetobj_ffs() (which calculates a ffs(3)
for a cpuset_t object), cpusetobj_strprint() (which prepares a string
representing a cpuset_t object) and cpusetobj_strscan() (which
creates a valid cpuset_t starting from a string representation).
- pc_cpumask and pc_other_cpus are target to be removed soon.
With the moving from cpumask_t to cpuset_t they are now inefficient
and not really useful. Anyway, for the time being, please note that
access to pcpu datas is protected by sched_pin() in order to avoid
migrating the CPU while reading more than one (possible) word
- Please note that size of cpuset_t objects may differ between kernel
and userland. While this is not directly related to the patch itself,
it is good to understand that concept and possibly use the patch
as a reference on how to deal with cpuset_t objects in userland, when
accessing kernland members.
- KTR_CPUMASK is changed and now is represented through a string, to be
set as the example reported in NOTES.

Please additively note that no MAXCPU is bumped in this patch, but
private testing has been done until to MAXCPU=128 on a real 8x8x2(htt)
machine (amd64).

Please note that the FreeBSD version is not yet bumped because of
the upcoming pcpu changes. However, note that this patch is not
targeted for MFC.

People to thank for the time spent on this patch:
- sbruno, pluknet and Nicholas Esborn (nick AT desert DOT net) tested
several revision of the patches and really helped in improving
stability of this work.
- marius fixed several bugs in the sparc64 implementation and reviewed
patches related to ktr.
- jeff and jhb discussed the basic approach followed.
- kib and marcel made targeted review on some specific part of the
patch.
- marius, art, nwhitehorn and andreast reviewed MD specific part of
the patch.
- marius, andreast, gonzo, nwhitehorn and jceel tested MD specific
implementations of the patch.
- Other people have made contributions on other patches that have been
already committed and have been listed separately.

Companies that should be mentioned for having participated at several
degrees:
- Yahoo! for having offered the machines used for testing on big
count of CPUs.
- The FreeBSD Foundation for having sponsored my devsummit attendance,
which has been instrumental.
- Sandvine for having offered offices and infrastructure during
development.

(I really hope I didn't forget anyone, if it happened I apologize in
advance).


221807 12-May-2011 stas

- Commit work from libprocstat project. These patches add support for runtime
file and processes information retrieval from the running kernel via sysctl
in the form of new library, libprocstat. The library also supports KVM backend
for analyzing memory crash dumps. Both procstat(1) and fstat(1) utilities have
been modified to take advantage of the library (as the bonus point the fstat(1)
utility no longer need superuser privileges to operate), and the procstat(1)
utility is now able to display information from memory dumps as well.

The newly introduced fuser(1) utility also uses this library and able to operate
via sysctl and kvm backends.

The library is by no means complete (e.g. KVM backend is missing vnode name
resolution routines, and there're no manpages for the library itself) so I
plan to improve it further. I'm commiting it so it will get wider exposure
and review.

We won't be able to MFC this work as it relies on changes in HEAD, which
was introduced some time ago, that break kernel ABI. OTOH we may be able
to merge the library with KVM backend if we really need it there.

Discussed with: rwatson


207736 07-May-2010 mckusick

Merger of the quota64 project into head.

This joint work of Dag-Erling Smørgrav and myself updates the
FFS quota system to support both traditional 32-bit and new 64-bit
quotas (for those of you who want to put 2+Tb quotas on your users).

By default quotas are not compiled into the kernel. To include them
in your kernel configuration you need to specify:

options QUOTA # Enable FFS quotas

If you are already running with the current 32-bit quotas, they
should continue to work just as they have in the past. If you
wish to convert to using 64-bit quotas, use `quotacheck -c 64';
if you wish to revert from 64-bit quotas back to 32-bit quotas,
use `quotacheck -c 32'.

There is a new library of functions to simplify the use of the
quota system, do `man quotafile' for details. If your application
is currently using the quotactl(2), it is highly recommended that
you convert your application to use the quotafile interface.
Note that existing binaries will continue to work.

Special thanks to John Kozubik of rsync.net for getting me
interested in pursuing 64-bit quota support and for funding
part of my development time on this project.


204880 08-Mar-2010 kib

Add file forgotten in r204879.


204879 08-Mar-2010 kib

Teach procstat(1) to display some information about signal disposition
and pending/blocked status for signals.

Reviewed by: rwatson
MFC after: 2 weeks


203541 06-Feb-2010 antoine

Document one more file descriptor type and two more vnode types.

MFC after: 2 weeks


201386 02-Jan-2010 ed

Build usr.bin/ with WARNS=6 by default.

Also add some missing $FreeBSD$ to keep svn happy.


200462 13-Dec-2009 delphij

Revert most part of 200420 as requested, as more review and polish is
needed.


200420 11-Dec-2009 delphij

Remove unneeded header includes from usr.bin/ except contributed code.

Tested with: make universe


196120 12-Aug-2009 rwatson

Update procstat(1) for the fact that devfs paths are no longer unsupported.

Approved by: re (kib)


195853 24-Jul-2009 brooks

Introduce a new sysctl process mib, kern.proc.groups which adds the
ability to retrieve the group list of each process.

Modify procstat's -s option to query this mib when the kinfo_proc
reports that the field has been truncated. If the mib does not exist,
fall back to the truncated list.

Reviewed by: rwatson
Approved by: re (kib)
MFC after: 2 weeks


195840 24-Jul-2009 jhb

Add a new type of VM object: OBJT_SG. An OBJT_SG object is very similar to
a device pager (OBJT_DEVICE) object in that it uses fictitious pages to
provide aliases to other memory addresses. The primary difference is that
it uses an sglist(9) to determine the physical addresses for a given offset
into the object instead of invoking the d_mmap() method in a device driver.

Reviewed by: alc
Approved by: re (kensmith)
MFC after: 2 weeks


186567 29-Dec-2008 rwatson

Include param.h instead of types.h before user.h so that the nested
include of param.h can be removed from audit.h.

MFC after: 3 weeks


186330 19-Dec-2008 wxs

Fix a typo.

Approved by: rwatson


186315 19-Dec-2008 marcus

Do not segfault when procstat -f or procstat -v is called on a process not
owned by the current user. If kinfo_getfile() or kinfo_getvmmap() return
NULL, simply exit, and do not try and derefernce the memory.

Reviewed by: peter
Approved by: peter


185563 02-Dec-2008 peter

Update format string for kve_start/end.


185548 02-Dec-2008 peter

Merge user/peter/kinfo branch as of r185547 into head.

This changes struct kinfo_filedesc and kinfo_vmentry such that they are
same on both 32 and 64 bit platforms like i386/amd64 and won't require
sysctl wrapping.

Two new OIDs are assigned. The old ones are available under
COMPAT_FREEBSD7 - but it isn't that simple. The superceded interface
was never actually released on 7.x.

The other main change is to pack the data passed to userland via the
sysctl. kf_structsize and kve_structsize are reduced for the copyout.
If you have a process with 100,000+ sockets open, the unpacked records
require a 132MB+ copyout. With packing, it is "only" ~35MB. (Still
seriously unpleasant, but not quite as devastating). A similar problem
exists for the vmentry structure - have lots and lots of shared libraries
and small mmaps and its copyout gets expensive too.

My immediate problem is valgrind. It traditionally achieves this
functionality by parsing procfs output, in a packed format. Secondly, when
tracing 32 bit binaries on amd64 under valgrind, it uses a cross compiled
32 bit binary which ran directly into the differing data structures in 32
vs 64 bit mode. (valgrind uses this to track file descriptor operations
and this therefore affected every single 32 bit binary)

I've added two utility functions to libutil to unpack the structures into
a fixed record length and to make it a little more convenient to use.


181905 20-Aug-2008 ed

Integrate the new MPSAFE TTY layer to the FreeBSD operating system.

The last half year I've been working on a replacement TTY layer for the
FreeBSD kernel. The new TTY layer was designed to improve the following:

- Improved driver model:

The old TTY layer has a driver model that is not abstract enough to
make it friendly to use. A good example is the output path, where the
device drivers directly access the output buffers. This means that an
in-kernel PPP implementation must always convert network buffers into
TTY buffers.

If a PPP implementation would be built on top of the new TTY layer
(still needs a hooks layer, though), it would allow the PPP
implementation to directly hand the data to the TTY driver.

- Improved hotplugging:

With the old TTY layer, it isn't entirely safe to destroy TTY's from
the system. This implementation has a two-step destructing design,
where the driver first abandons the TTY. After all threads have left
the TTY, the TTY layer calls a routine in the driver, which can be
used to free resources (unit numbers, etc).

The pts(4) driver also implements this feature, which means
posix_openpt() will now return PTY's that are created on the fly.

- Improved performance:

One of the major improvements is the per-TTY mutex, which is expected
to improve scalability when compared to the old Giant locking.
Another change is the unbuffered copying to userspace, which is both
used on TTY device nodes and PTY masters.

Upgrading should be quite straightforward. Unlike previous versions,
existing kernel configuration files do not need to be changed, except
when they reference device drivers that are listed in UPDATING.

Obtained from: //depot/projects/mpsafetty/...
Approved by: philip (ex-mentor)
Discussed: on the lists, at BSDCan, at the DevSummit
Sponsored by: Snow B.V., the Netherlands
dcons(4) fixed by: kan


180875 28-Jul-2008 ed

Fix a small typo in the procstat(1) manpage: messsage queue.

Approved by: philip (mentor)
MFC after: 3 days


180059 27-Jun-2008 jhb

Rework the lifetime management of the kernel implementation of POSIX
semaphores. Specifically, semaphores are now represented as new file
descriptor type that is set to close on exec. This removes the need for
all of the manual process reference counting (and fork, exec, and exit
event handlers) as the normal file descriptor operations handle all of
that for us nicely. It is also suggested as one possible implementation
in the spec and at least one other OS (OS X) uses this approach.

Some bugs that were fixed as a result include:
- References to a named semaphore whose name is removed still work after
the sem_unlink() operation. Prior to this patch, if a semaphore's name
was removed, valid handles from sem_open() would get EINVAL errors from
sem_getvalue(), sem_post(), etc. This fixes that.
- Unnamed semaphores created with sem_init() were not cleaned up when a
process exited or exec'd. They were only cleaned up if the process
did an explicit sem_destroy(). This could result in a leak of semaphore
objects that could never be cleaned up.
- On the other hand, if another process guessed the id (kernel pointer to
'struct ksem' of an unnamed semaphore (created via sem_init)) and had
write access to the semaphore based on UID/GID checks, then that other
process could manipulate the semaphore via sem_destroy(), sem_post(),
sem_wait(), etc.
- As part of the permission check (UID/GID), the umask of the proces
creating the semaphore was not honored. Thus if your umask denied group
read/write access but the explicit mode in the sem_init() call allowed
it, the semaphore would be readable/writable by other users in the
same group, for example. This includes access via the previous bug.
- If the module refused to unload because there were active semaphores,
then it might have deregistered one or more of the semaphore system
calls before it noticed that there was a problem. I'm not sure if
this actually happened as the order that modules are discovered by the
kernel linker depends on how the actual .ko file is linked. One can
make the order deterministic by using a single module with a mod_event
handler that explicitly registers syscalls (and deregisters during
unload after any checks). This also fixes a race where even if the
sem_module unloaded first it would have destroyed locks that the
syscalls might be trying to access if they are still executing when
they are unloaded.

XXX: By the way, deregistering system calls doesn't do any blocking
to drain any threads from the calls.
- Some minor fixes to errno values on error. For example, sem_init()
isn't documented to return ENFILE or EMFILE if we run out of semaphores
the way that sem_open() can. Instead, it should return ENOSPC in that
case.

Other changes:
- Kernel semaphores now use a hash table to manage the namespace of
named semaphores nearly in a similar fashion to the POSIX shared memory
object file descriptors. Kernel semaphores can now also have names
longer than 14 chars (up to MAXPATHLEN) and can include subdirectories
in their pathname.
- The UID/GID permission checks for access to a named semaphore are now
done via vaccess() rather than a home-rolled set of checks.
- Now that kernel semaphores have an associated file object, the various
MAC checks for POSIX semaphores accept both a file credential and an
active credential. There is also a new posixsem_check_stat() since it
is possible to fstat() a semaphore file descriptor.
- A small set of regression tests (using the ksem API directly) is present
in src/tools/regression/posixsem.

Reported by: kris (1)
Tested by: kris
Reviewed by: rwatson (lightly)
MFC after: 1 month


178379 21-Apr-2008 rwatson

Use ddb(4), not DDB(4) for man page cross-references.

MFC after: 3 days
Reported by: novel


178317 19-Apr-2008 rwatson

Provide more detailed information about each procstat(1) display mode,
including a key to fields in each mode and flag abbreviations.

MFC after: 3 days
X-MFC-note: POSIX shared memory memory objects aren't in 7-STABLE yet


178316 19-Apr-2008 rwatson

It is a bug that procstat(8) works only on live kernels and not crashdumps;
document in case anyone wants to work on fixing this.

MFC after: 3 days


176124 09-Feb-2008 marcus

Add support for displaying a process' current working directory, root
directory, and jail directory within procstat. While this functionality
is available already in fstat, encapsulating it in the kern.proc.filedesc
sysctl makes it accessible without using kvm and thus without needing
elevated permissions.

The new procstat output looks like:

PID COMM FD T V FLAGS REF OFFSET PRO NAME
76792 tcsh cwd v d -------- - - - /usr/src
76792 tcsh root v d -------- - - - /
76792 tcsh 15 v c rw------ 16 9130 - -
76792 tcsh 16 v c rw------ 16 9130 - -
76792 tcsh 17 v c rw------ 16 9130 - -
76792 tcsh 18 v c rw------ 16 9130 - -
76792 tcsh 19 v c rw------ 16 9130 - -

I am also bumping __FreeBSD_version for this as this new feature will be
used in at least one port.

Reviewed by: rwatson
Approved by: rwatson


176107 08-Feb-2008 dwmalone

WARNS fixes: mainly constness and avoid comparing signed with
unsigned by making array indicies unsigned. Also note one or two
unused parameters.


175515 20-Jan-2008 rwatson

When printing process file descriptor lists, show a type of 'h' for
POSIX shared memory descriptors.


174530 10-Dec-2007 rwatson

Add 'COMM' column to a few more output modes of procstat(1). The only
one it's missing from is the VM display, where there's really not room,
and the file output display is looking quite cramped.


174230 03-Dec-2007 rwatson

Display per-thread command line in TDNAME field for -k and -t; if
no per-thread name is available or the name is identical to the
process name, display "-" instead. Very slightly shrink the COMM
entry to make a bit more room, although this doesn't help with
stack traces much.

Suggested by: thompsa


174199 02-Dec-2007 rwatson

Add procstat(1), a process inspection utility. This provides both some
of the missing functionality from procfs(4) and new functionality for
monitoring and debugging specific processes. procstat(1) operates in
the following modes:

-b Display binary information for the process.
-c Display command line arguments for the process.
-f Display file descriptor information for the process.
-k Display the stacks of kernel threads in the process.
-s Display security credential information for the process.
-t Display thread information for the process.
-v Display virtual memory mappings for the process.

Further revision and modes are expected.

Testing, ideas, etc: cognet, sam, Skip Ford <skip at menantico dot com>
Wesley Shields <wxs at atarininja dot org>