Commit graph

39 commits

Author SHA1 Message Date
Warner Losh 0b8224d1cc Remove copyright strings ifdef'd out
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
2023-11-26 22:23:58 -07:00
Warner Losh 51e16cb8fc sbin: Remove ancient SCCS tags.
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
2023-11-26 22:23:29 -07:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Gleb Smirnoff c999e3481d dmesg: detect wrapped msgbuf on the kernel side and if so, skip first line
Since 59f256ec35 dmesg(8) will always skip first line of the message
buffer, cause it might be incomplete.  The problem is that in most cases
it is complete, valid and contains the "---<<BOOT>>---" marker.  This
skip can be disabled with '-a', but that would also unhide all non-kernel
messages.  Move this functionality from dmesg(8) to kernel, since kernel
actually knows if wrap has happened or not.

The main motivation for the change is not actually the value of the
"---<<BOOT>>---" marker.  The problem breaks unit tests, that clear
message buffer, perform a test and then check the message buffer for
a result.  Example of such test is sys/kern/sonewconn_overflow.
2022-02-05 13:35:31 -08:00
Pedro F. Giffuni 8a16b7a18f General further adoption of SPDX licensing ID tags.
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.
2017-11-20 19:49:47 +00:00
Warner Losh fbbd9655e5 Renumber copyright clause 4
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
2017-02-28 23:42:47 +00:00
Eric van Gyzen f8ee95484e dmesg: accommodate message buffer growth between the sysctl calls
Allocate 12.5% extra space to avoid ENOMEM when the message buffer
is growing steadily.

Reported by:	Steve Wahl <steve_wahl@dell.com> (and tested)
Approved by:	kib (mentor)
Obtained from:	Dell Inc.
MFC after:	1 week
2015-04-20 20:07:39 +00:00
Ian Lepore 93c3ad10f1 Fix minor fallout from sysctl strings being nulterminated now. The dmesg
code can read the buffer via sysctl or from a core file.  In the core file
case there will be no nulterm, and the code copes with that, but now in the
sysctl case there is a nulterm (there didn't used to be).  The least
disruptive way to restore the old behavior (and eliminate a spurious '\000'
at the end of the output) is to remove the nulterm (by decrementing the
buffer length) in the sysctl case.
2015-03-16 21:09:11 +00:00
Florian Smeets e1de133c2e Move the check whether the clear flag is set. This has 2 advantages
- When operating on a core file (-M) and -c is specified we don't clear
  the message buffer of the running system.
- If we don't have permission to clear the buffer print the error message
  only. That's what Linux does in this case, where this feature was ported
  from, and it ensures that the error message doesn't get lost in the noise.

Discussed with:	antoine, cognet
Approved by:	cognet
2013-06-11 17:46:32 +00:00
Eitan Adler 11967f3ce1 Add support for 'dmesg -c' which clears the dmesg buffer after it has
been printed.  This provides compatibility with other *nix systems
(including Linux).

While here use stdbool booleans for 'all'.

PR:		bin/178295
Submitted by:	Levent Serinol <lserinol@gmail.com>
Reviewed by:	will
2013-05-10 03:42:48 +00:00
Ed Schouten 1efe3c6b58 Add missing static keywords for global variables to tools in sbin/.
These tools declare global variables without using the static keyword,
even though their use is limited to a single C-file, or without placing
an extern declaration of them in the proper header file.
2011-11-04 13:36:02 +00:00
David Malone 48697608f1 Avoid moving onto a new line while testing if there is a syslog priority
in the buffer. This isn't exactly the patch that Stephen submitted, but
is based on one of his suggestions.

PR:		93841
Submitted by:	Stephen Montgomery-Smith <stephen@math.missouri.edu>
MFC after:	2 weeks
2006-02-27 19:13:47 +00:00
Xin LI 57517b0931 WARNS=6 cleanup:
- signed/unsigned conform.
 - Better initialization of nlist[].  I think we should have
   something like NLIST_NULL instead of the current (ugly)
   form...
2005-01-17 13:56:46 +00:00
Jens Schweikhardt b8a2c7ca02 Print a usage message if a non-option is specified.
MFC after:	3 weeks
2004-10-13 20:33:18 +00:00
Stefan Farfeleder 4c86f66f52 Don't add integers to void pointers. 2004-10-03 15:48:32 +00:00
Mark Murray 4c723140a4 Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp
2004-04-09 19:58:40 +00:00
Ruslan Ermilov 46fb2e1dbc Not too much point specifying -N but not specifying -M. 2004-03-26 09:24:45 +00:00
Ian Dowse ccdb237094 Further simplify the code for printing the message buffer:
- Ensure that the buffer ends with "\n\0" to avoid special cases
   and allow the use of strtol().
 - Use strvisx() on each complete line instead of character by
   character.

Submitted by:	bde
MFC after:	1 week
2004-02-08 23:08:53 +00:00
Ian Dowse 59f256ec35 Don't print the oldest line in the message buffer if the buffer is
full, since that line is almost always incomplete. Make the parsing
of <%d> lines more strict.

Also simplify the logic a little:
 - Start off by making the buffer linear so that we don't have to
   deal with it wrapping around (suggested by bde).
 - Process line by line rather than byte at a time.
2004-02-05 21:07:50 +00:00
Ian Dowse 4784a46912 Replace the code for reading and writing the kernel message buffer
with a new implementation that has a mostly reentrant "addchar"
routine, supports multiple message buffers in the kernel, and hides
the implementation details from callers.

The new code uses a kind of sequence number to represend the current
read and write positions in the buffer. This approach (suggested
mainly by bde) permits the read and write pointers to be maintained
separately, which reduces the number of atomic operations that are
required. The "mostly reentrant" above refers to the way that while
it is now always safe to have any number of concurrent writers,
readers could see the message buffer after a writer has advanced
the pointers but before it has witten the new character.

Discussed on:	freebsd-arch
2003-06-22 02:18:31 +00:00
David E. O'Brien 560bb4f8b6 bufpos is used in size_t contexts, so make it one. 2003-05-02 07:08:52 +00:00
Bruce Evans 7309e024bf Include <nlist.h> for nlist interfaces instead of depending on namespace
pollution in <kvm.h>.
2002-08-18 17:57:08 +00:00
Warner Losh 1fa5ae8f93 o Remove __P
o Use ANSI function definitions
o mark usage() as __dead2
2002-03-19 13:29:39 +00:00
Bill Fumerola bcdb7cc8e4 add -a to usage()
Submitted by:	Ashley Penney <ashp@unloved.org>
MFC after:	3 days
2001-07-14 21:56:04 +00:00
Thomas Moestl 676adc045c Use the kern.msgbuf sysctl to get the message buffer on a running
kernel, and remove setgid kmem, which is not needed any more.
2001-07-03 19:49:31 +00:00
Ruslan Ermilov f806cd425e Backout -a restriction hack.
Requested by:	rwatson
2001-02-26 08:09:51 +00:00
Ruslan Ermilov b52c326cfc Restrict -a to root only.
PR:		bin/25337
2001-02-24 10:16:54 +00:00
Poul-Henning Kamp 9d1334552f Add a -a option to show the entire message buffer. 2000-12-17 19:05:17 +00:00
Peter Wemm 7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Tim Vanderhoek d6c37912c6 Use an error message that more clearly indites(sp?) an out-of-sync
kernel+userland when that is the case.

PR:		bin/7414
1998-07-27 18:53:45 +00:00
Philippe Charnier 970cd28246 Use .Pa for filenames. Use .Bl/.El in FILES section. Remove unused #includes. 1998-06-04 06:51:14 +00:00
Poul-Henning Kamp 58067a9909 Make the size of the msgbuf (dmesg) a "normal" option. 1998-05-19 08:58:53 +00:00
Warner Losh 8d64695c7c compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 03:33:12 +00:00
Peter Wemm c0ec1f37ef Revert $FreeBSD$ to $Id$ 1997-02-22 14:40:44 +00:00
Jordan K. Hubbard 1130b656e5 Make the long-awaited change from $Id$ to $FreeBSD$
This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore.  This update would have been
insane otherwise.
1997-01-14 07:20:47 +00:00
Bruce Evans 301e6a175a Who would have though that dmesg didn't understand message buffers?
Fixed the following bugs:
- the buffer was reprinted endlessly when msg.bufx == 0 and (for a
  different reason) when msg.bufx == 1.
- the last byte of the buffer wasn't printed except in the the infinite
  loop cases.
- the comment about walking the buffer didn't match the (correct) code.
- minor -Wall and style bugs.
Not fixed:
- excessive newline processing which hid the non-printing of the last
  byte of the buffer.
1996-09-21 08:11:22 +00:00
Alexander Langer b7a8c0221f Add #include <err.h>. 1996-06-19 01:49:01 +00:00
Andrey A. Chernov 8dcf55a40e Add setlocale LC_CTYPE 1995-10-23 23:36:55 +00:00
Rodney W. Grimes 8fae3551ec BSD 4.4 Lite sbin Sources
Note:  XNSrouted and routed NOT imported here, they shall be imported with
usr.sbin.
1994-05-26 06:35:07 +00:00