aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pstat/pstat.c
Commit message (Collapse)AuthorAgeFilesLines
* pstat: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])Elyes Haouas2024-04-291-1/+1
| | | | | Pull Request: https://github.com/freebsd/freebsd-src/pull/888 Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-9/+0
| | | | | | | | | | | We've ifdef'd out the copyright strings for some time now. Go ahead and remove the ifdefs. Plus whatever other detritis was left over from other recent removals. These copyright strings are present in the comments and are largely from CSRG's attempt at adding their copyright to every binary file (which modern interpretations of the license doesn't require). Sponsored by: Netflix
* usr.sbin: Remove ancient SCCS tags.Warner Losh2023-11-271-3/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* pstat(8): improve the Size header width after r358181Piotr Pawel Stefaniak2020-06-231-1/+1
| | | | | | | | All size values use fields of width 8. Also, all other headers use fields of width 8. Make the Size header added in r358181 use 8 characters as well. Notes: svn path=/head/; revision=362547
* - Implement -h (human readable) for the size of the underlying block disk.Christian S.J. Peron2020-02-201-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the size of the swap device is unconditionally reported using blocks, even if -h has been used. - While here, switch to CONVERT_BLOCKS() instead of CONVERT() which will avoid overflowing size counters (in human readable form see: r196244) - Update the column headers to reflect that a size is being reported instead of the block size units being used Before: $ swapinfo Device 1K-blocks Used Avail Capacity /dev/gpt/swapfs 1048576 0 1048576 0% $ After: $ swapinfo -h Device Size Used Avail Capacity /dev/gpt/swapfs 1.0G 0B 1.0G 0% $ Differential Revision: https://reviews.freebsd.org/D23758 Reviewed by: kevans MFC after: 3 weeks Notes: svn path=/head/; revision=358181
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* Commit the 64-bit inode project.Konstantin Belousov2017-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify struct dirent layout to add d_off, increase the size of d_fileno to 64-bits, increase the size of d_namlen to 16-bits, and change the required alignment. Increase struct statfs f_mntfromname[] and f_mntonname[] array length MNAMELEN to 1024. ABI breakage is mitigated by providing compatibility using versioned symbols, ingenious use of the existing padding in structures, and by employing other tricks. Unfortunately, not everything can be fixed, especially outside the base system. For instance, third-party APIs which pass struct stat around are broken in backward and forward incompatible ways. Kinfo sysctl MIBs ABI is changed in backward-compatible way, but there is no general mechanism to handle other sysctl MIBS which return structures where the layout has changed. It was considered that the breakage is either in the management interfaces, where we usually allow ABI slip, or is not important. Struct xvnode changed layout, no compat shims are provided. For struct xtty, dev_t tty device member was reduced to uint32_t. It was decided that keeping ABI compat in this case is more useful than reporting 64-bit dev_t, for the sake of pstat. Update note: strictly follow the instructions in UPDATING. Build and install the new kernel with COMPAT_FREEBSD11 option enabled, then reboot, and only then install new world. Credits: The 64-bit inode project, also known as ino64, started life many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick (mckusick) then picked up and updated the patch, and acted as a flag-waver. Feedback, suggestions, and discussions were carried by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles), and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial ports investigation followed by an exp-run by Antoine Brodin (antoine). Essential and all-embracing testing was done by Peter Holm (pho). The heavy lifting of coordinating all these efforts and bringing the project to completion were done by Konstantin Belousov (kib). Sponsored by: The FreeBSD Foundation (emaste, kib) Differential revision: https://reviews.freebsd.org/D10439 Notes: svn path=/head/; revision=318736
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* - pstat(8) does not accept any arguments other than getopt() args,Xin LI2016-12-261-3/+1
| | | | | | | | | | so don't bother to adjust argc/argv after getopt() loop. - Make a string pointer constant. MFC after: 2 weeks Notes: svn path=/head/; revision=310611
* Get rid of major/minor number distinction.Ed Schouten2011-09-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | As of FreeBSD 6, devices can only be opened through devfs. These device nodes don't have major and minor numbers anymore. The st_rdev field in struct stat is simply based a copy of st_ino. Simply display device numbers as hexadecimal, using "%#jx". This is allowed by POSIX, since it explicitly states things like the following (example taken from ls(1)): "If the file is a character special or block special file, the size of the file may be replaced with implementation-defined information associated with the device in question." This makes the output of these commands more compact. For example, ls(1) now uses approximately four columns less. While there, simplify the column length calculation from ls(1) by calling snprintf() with a NULL buffer. Don't be afraid; if needed one can still obtain individual major/minor numbers using stat(1). Notes: svn path=/head/; revision=225847
* - Avoid overflowing the swap size counters in human-readable modeStanislav Sedov2009-08-151-2/+3
| | | | | | | | | | | | | by introducing the new CONVERT_BLOCKS macro which operates on sizes already converted to number of blocks. With this macro it is not longer needed to perform needless multiplication by blocksize just to divide on it later in CONVERT macro. Approved by: re (kib) MFC after: 1 week Notes: svn path=/head/; revision=196244
* - Make pstat(8) WARNS=6 safe.Stanislav Sedov2009-06-111-21/+32
| | | | | | | | | | - While here, eliminate the check for len > 0 in ttymode_sysctl as the code is able to handle this case well. Reviewed by: ed (initial version) Notes: svn path=/head/; revision=194014
* Correct my previous commit to pstat(8).Ed Schouten2009-06-111-1/+1
| | | | | | | | | | Not only mark the strings inside the array as const, but do the same for the elements of the array itself. Submitted by: Christoph Mallon Notes: svn path=/head/; revision=193982
* Make most of pstat(8) build with WARNS=6.Ed Schouten2009-06-111-6/+7
| | | | | | | | There is still an issue with the nlists, which I'm not quite sure how to solve, so I'm leaving WARNS set to 3 right now. Notes: svn path=/head/; revision=193978
* Serialize write() calls on TTYs.Ed Schouten2009-02-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | Just like the old TTY layer, the current MPSAFE TTY layer does not make any attempt to serialize calls of write(). Data is copied into the kernel in 256 (TTY_STACKBUF) byte chunks. If a write() call occurs at the same time, the data may interleave. This is especially likely when the TTY starts blocking, because the output queue reaches the high watermark. I've implemented this by adding a new flag, TTY_BUSY_OUT, which is used to mark a TTY as having a thread stuck in write(). Because I don't want non-blocking processes to be possibly blocked by a sleeping thread, I'm still allowing it to bypass the protection. According to this message, the Linux kernel returns EAGAIN in such cases, but I think that's a little too restrictive: http://kerneltrap.org/index.php?q=mailarchive/linux-kernel/2007/5/2/85418/thread PR: kern/118287 Notes: svn path=/head/; revision=188487
* Don't leave the console TTY constantly open.Ed Schouten2009-02-051-19/+20
| | | | | | | | | | | | | | | | | | | | When we leave the console TTY constantly open, we never reset the termios attributes. This causes output processing, echoing, etc. not to be reset to the proper values when going into single user mode after the system has booted. It also causes nl-to-crnl-conversion not to take place during shutdown, which causes a `staircase effect'. This patch adds a new TTY flag, TF_OPENED_CONS, which is set when the TTY is opened through /dev/console. Because the flags are only used by the kernel and the pstat(8) utility, I've decided to renumber the TTY flags. This shouldn't be an issue, because the TTY layer is not yet part of a stable release. Reported by: Mark Atkinson <atkin901 yahoo com> Tested by: sepotvin Notes: svn path=/head/; revision=188147
* Clamp the values of t_column to 5 digits in `pstat -t' and `show all ttys'.Ed Schouten2008-11-011-1/+1
| | | | | | | | | | | We often run into these very high column numbers when we run curses applications, because they don't print any newlines. This messes up the table output of `pstat -t'. If these numbers get really high, they aren't of any use to the reader anyway. Convert them to `99999' when they run out of bounds. Notes: svn path=/head/; revision=184522
* Introduce a hooks layer for the MPSAFE TTY layer.Ed Schouten2008-09-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | One of the features that prevented us from fixing some of the TTY consumers to work once again, was an interface that allowed consumers to do the following: - `Sniff' incoming data, which is used by the snp(4) driver. - Take direct control of the input and output paths of a TTY, which is used by ng_tty(4), ppp(4), sl(4), etc. There's no practical advantage in committing a hooks layer without having any consumers. In P4 there is a preliminary port of snp(4) and thompsa@ is busy porting ng_tty(4) to this interface. I already want to have it in the tree, because this may stimulate others to work on the remaining modules. Discussed with: thompsa Obtained from: //depot/projects/mpsafetty/... Notes: svn path=/head/; revision=183276
* Integrate the new MPSAFE TTY layer to the FreeBSD operating system.Ed Schouten2008-08-201-87/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=181905
* Remove OTTYDISC, NETLDISC and NTTYDISC definitions.Ed Schouten2008-07-161-4/+0
| | | | | | | | | | | | | | | | | | | When I ported most applications away from <sgtty.h>, I noticed none of them were actually using these definitions. I kept them in place, because I didn't want to touch tools like pstat(8) and stty(1). In preparation for the MPSAFE TTY layer, remove these definitions. This doesn't have any impact with respect to binary compatibility (see tty_conf.c). We couldn now add an #error to <sys/ioctl_compat.h> when included outside the kernel. Unfortunately, kdump's mkioctls includes this file unconditionally. Approved by: philip (mentor) Notes: svn path=/head/; revision=180559
* Fix pstat behaviour when using coredumps. The reference to tp wasRemko Lodder2008-05-141-1/+1
| | | | | | | | | | | | | incorrect and should have been poining to &tty, tp is a virtual address from the coredump, while we should obtain the address through the tty struct. Approved by: imp (mentor, implicit trivial changes) MFC after: 1 week Submitted by: Ed Schouten (ed at 80836 dot nl) Notes: svn path=/head/; revision=178987
* Significantly reduce the memory leak as noted in BUGS section forSean Farley2007-07-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | setenv(3) by tracking the size of the memory allocated instead of using strlen() on the current value. Convert all calls to POSIX from historic BSD API: - unsetenv returns an int. - putenv takes a char * instead of const char *. - putenv no longer makes a copy of the input string. - errno is set appropriately for POSIX. Exceptions involve bad environ variable and internal initialization code. These both set errno to EFAULT. Several patches to base utilities to handle the POSIX changes from Andrey Chernov's previous commit. A few I re-wrote to use setenv() instead of putenv(). New regression module for tools/regression/environ to test these functions. It also can be used to test the performance. Bump __FreeBSD_version to 700050 due to API change. PR: kern/99826 Approved by: wes Approved by: re (kensmith) Notes: svn path=/head/; revision=171195
* Back out all POSIXified *env() changes.Andrey A. Chernov2007-05-011-3/+3
| | | | | | | | | | | | Not because I admit they are technically wrong and not because of bug reports (I receive nothing). But because I surprisingly meets so strong opposition and resistance so lost any desire to continue that. Anyone who interested in POSIX can dig out what changes and how through cvs diffs. Notes: svn path=/head/; revision=169177
* Preparing for upcoming POSIXed putenv() rewrite:Andrey A. Chernov2007-04-301-3/+3
| | | | | | | don't allow const as putenv() arg, dup it Notes: svn path=/head/; revision=169134
* - Recognize -g and -m in pstat(8) too.Ruslan Ermilov2007-04-031-2/+2
| | | | | | | | | - Document -g and -m support in swapinfo(8). Reviewed by: markm Notes: svn path=/head/; revision=168292
* Add -m (megabytes) and -g (gigabytes) options. I'm tired of being toldMark Murray2007-04-011-2/+8
| | | | | | | | | I can't do this. MFC: 1 month Notes: svn path=/head/; revision=168227
* Another crashdump fix: nfiles was renamed to openfiles in 5.x.John Baldwin2007-02-141-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=166696
* Print (total - used) as the amount of available swap for a swap deviceRobert Watson2005-11-171-1/+1
| | | | | | | | | | | when printing swapinfo output, rather than (total), as that is (strictly speaking) more accurate. Pointed out by: Rob <spamrefuse at yahoo dot com> MFC after: 3 days Notes: svn path=/head/; revision=152558
* Remove unused variables.Stefan Farfeleder2005-04-091-2/+0
| | | | Notes: svn path=/head/; revision=144841
* Use a designator for initializing only one member of the nlistGiorgos Keramidas2005-03-211-5/+5
| | | | | | | | | | | structs, making pstat WARNS=3 clean on i386, sparc64 and amd64. Bump WARNS level to 3. Approved by: sam, pjd Notes: svn path=/head/; revision=143936
* - Add a -h flag to pstat to print swap sizes in "human readable"Giorgos Keramidas2005-03-211-19/+40
| | | | | | | | | | | | | | | | | | | | | | format, with humanize_number(3). - Move the common parts of the code that prints the sizes for a single swap device and the total to a single function to avoid repeating the humanize_number() stuff all over the place. - Change the type of CONVERT() from intmax_t to int64_t, since this makes calling humanize_number() easier but cast the values to intmax_t before printing them, to make use of the %jd format that printf() supports. - Document the new -h flag in the manpage and bump its date. Approved by: pjd Useful tips: brooks MFC after: 2 weeks Notes: svn path=/head/; revision=143929
* Don't include sys/user.h merely for its side-effect of recursivelyDavid Schultz2004-11-271-1/+2
| | | | | | | including other headers. Notes: svn path=/head/; revision=138129
* Per letter dated July 22, 1999 remove 3rd clause of Berkeley derived softwareWarner Losh2004-08-071-4/+0
| | | | | | | (with permission of addtional copyright holders where appropriate) Notes: svn path=/head/; revision=133249
* Update kvm mode to match kernel changes.Poul-Henning Kamp2004-06-091-3/+3
| | | | Notes: svn path=/head/; revision=130267
* -N without -M is pointless.Ruslan Ermilov2004-03-261-2/+2
| | | | Notes: svn path=/head/; revision=127449
* Make NULL a (void*)0 whereever possible, and fix the warnings(-Werror)Mark Murray2004-03-051-1/+1
| | | | | | | | | | | | | | | | | | that this provokes. "Wherever possible" means "In the kernel OR NOT C++" (implying C). There are places where (void *) pointers are not valid, such as for function pointers, but in the special case of (void *)0, agreement settles on it being OK. Most of the fixes were NULL where an integer zero was needed; many of the fixes were NULL where ascii <nul> ('\0') was needed, and a few were just "other". Tested on: i386 sparc64 Notes: svn path=/head/; revision=126643
* Remove options processing for dumping swapdevice radix map.Poul-Henning Kamp2003-07-311-1/+1
| | | | Notes: svn path=/head/; revision=118278
* When dumping swap information, drop the "Type" field which displaysPoul-Henning Kamp2003-07-311-7/+4
| | | | | | | | | | a constant string of little information these days. This removes the need to #include <vm/swap_pager.h> which is due to become a kernel only include file. Notes: svn path=/head/; revision=118275
* Report NODEV devices as <NFSfile>Poul-Henning Kamp2003-06-051-2/+6
| | | | Notes: svn path=/head/; revision=115882
* Use __FBSDID over rcsid[]. Protect copyright[] where needed.David E. O'Brien2003-05-031-4/+4
| | | | Notes: svn path=/head/; revision=114601
* - Modernize the format of the open file showing mode output:Robert Drehmel2003-01-311-10/+23
| | | | | | | | | | | | | | | | | | | | | . Print the column headers centered (except for the left-aligned TYPE header) using a different header for architectures where sizeof(uintptr_t) is not four. . Consistently do not print a '0x' prefix for hexadecimal values. . Separate columns by a single space character. . Pad the columns presenting an address or offset enough to hold their respective largest value. . Do not restrict the output to unknown file types, inodes and sockets; allow displaying of pipes, fifos, kqueues and crypto file descriptors too. - Shorten an overly long line by removing a cast of printf's return value to void. PR: alpha/45240 Tested on: i386, sparc64, alpha Notes: svn path=/head/; revision=110148
* Bow to the whining masses and change a union back into void *. RetainMatthew Dillon2003-01-131-1/+1
| | | | | | | | removal of unnecessary casts and throw in some minor cleanups to see if anyone complains, just for the hell of it. Notes: svn path=/head/; revision=109153
* Change struct file f_data to un_data, a union of the correct structMatthew Dillon2003-01-121-1/+1
| | | | | | | | | | | | | pointer types, and remove a huge number of casts from code using it. Change struct xfile xf_data to xun_data (ABI is still compatible). If we need to add a #define for f_data and xf_data we can, but I don't think it will be necessary. There are no operational changes in this commit. Notes: svn path=/head/; revision=109123
* Make struct swblock kernel only, to make vm/swap_pager.h userland includable.Poul-Henning Kamp2003-01-031-1/+1
| | | | | | | | Move struct swdevt from sys/conf.h to the more appropriate vm/swap_pager.h. Adjust #include use in libkvm and pstat(8) to match. Notes: svn path=/head/; revision=108602
* Back out rev 1.78; getbsize(3)'s original interface has been restored.Mike Barcroft2002-12-301-8/+6
| | | | | | | Approved by: markm Notes: svn path=/head/; revision=108457
* Adjust argument passed to getbsize().Mark Murray2002-10-231-6/+8
| | | | Notes: svn path=/head/; revision=105811
* Use struct xfile, not struct file.Dag-Erling Smørgrav2002-07-311-26/+15
| | | | Notes: svn path=/head/; revision=101044
* If unable to retrive maxfiles / openfiles, fail rather than print garbage.Dag-Erling Smørgrav2002-05-281-33/+21
| | | | | | | | | | | Gratuitously rename a couple of variables. Remove unused macros. Add NAI copyright. Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=97378
* Remove the code that was disabled in a recent commit; it is of very limitedDag-Erling Smørgrav2002-05-281-101/+55
| | | | | | | | | | | | use and has been broken in -CURRENT for a long time. Clean up unneeded entries in the nlist array. Implement kvm-backed ttymode (which we never had before). Incomplete as we do not (yet?) print the correct device, sid or pgid. Sponsored by: DARPA, NAI Labs Notes: svn path=/head/; revision=97375