summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_prf.c
Commit message (Collapse)AuthorAgeFilesLines
* Implement printf 'X' conversion for both libstand and kernel.jkim2006-03-091-10/+13
|
* Always print a newline char at the end of the line.scottl2006-02-251-1/+2
|
* Acquire Giant in uprintf() and tprintf() rather than asserting it. Inrwatson2005-09-261-6/+11
| | | | | | | | | | | the vast majority of cases, these functions are called without mutexes held, meaning that in all but two cases, there will be no ordering issues with doing this, and it will eliminate the need for changes in the caller. In two cases, mutexes are held, so Giant must be acquired before those mutexes such that uprintf() and tprintf() recurse Giant rather than generating a lock order reversal. Suggested by: bde
* Correct an incorrect comment from the dawn of time: neither tprintf()rwatson2005-09-201-10/+2
| | | | | | | | | | nor uprintf() is believed to perform tsleep() or msleep() as written, as ttycheckoutq() is called with '0' as its sleep argument. Remove recently added WITNESS warnings for sleep as the comment was incorrect. This should silence a warning from the nfs_timer() code. Discussed with: bde
* Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(),rwatson2005-09-191-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | as they both interact with the tty code (!MPSAFE) and may sleep if the tty buffer is full (per comment). Modify all consumers of uprintf() and tprintf() to hold Giant around calls into these functions. In most cases, this means adding an acquisition of Giant immediately around the function. In some cases (nfs_timer()), it means acquiring Giant higher up in the callout. With these changes, UFS no longer panics on SMP when either blocks are exhausted or inodes are exhausted under load due to races in the tty code when running without Giant. NB: Some reduction in calls to uprintf() in the svr4 code is probably desirable. NB: In the case of nfs_timer(), calling uprintf() while holding a mutex, or even in a callout at all, is a bad idea, and will generate warnings and potential upset. This needs to be fixed, but was a problem before this change. NB: uprintf()/tprintf() sleeping is generally a bad ideas, as is having non-MPSAFE tty code. MFC after: 1 week
* When padding with zero, do pad after prefixes rather than paddingdelphij2005-09-041-1/+5
| | | | | | | | | | | | before prefixes. Use cases: printf("%05d", -42); --> "00-42" (should be "-0042") printf("%#05x", 12); --> "000xc" (should be "0x00c") Submitted by: Oliver Fromme PR: kern/85520 MFC After: 1 week
* If we ignore an unknown % sequence, we must stop interpreting thephk2005-09-031-2/+9
| | | | | | | | remaining % arguments because the varargs are now out of sync and there is a risk that we might for instance dereference an integer in a %s argument. Sponsored by: Napatech.com
* Make "show msgbuf" use the pager instead of blasting the whole thing out.dwhite2005-06-061-2/+5
| | | | MFC after: 3 days
* Constify hexdump() harder.phk2005-04-061-2/+2
|
* In stange circumstances we may end up being the last reference to aphk2005-03-171-4/+1
| | | | | | | | | | | session in tprintf(). SESSRELE() needs to properly dispose of the sessions mutex. Add sessrele() which does the proper cleanup and have SESSRELE() call it. Use SESSRELE also in pgdelete(). Found by: Coverity (ID:526)
* Update for the KDB framework:marcel2004-07-101-3/+2
| | | | o Check kdb_active instead of db_active and do so unconditionally.
* Clean up and wash struct iovec and struct uio handling.phk2004-07-101-12/+5
| | | | | | | | | | | | Add copyiniov() which copies a struct iovec array in from userland into a malloc'ed struct iovec. Caller frees. Change uiofromiov() to malloc the uio (caller frees) and name it copyinuio() which is more appropriate. Add cloneuio() which returns a malloc'ed copy. Caller frees. Use them throughout.
* Add a sysctl/tunable, "kern.always_console_output", that lets you setgreen2004-06-181-3/+12
| | | | | | | output to permanently (not ephemerally) go to the console. It is also sent to any other console specified by TIOCCONS as normal. While I'm here, document the kern.log_console_output sysctl.
* Remove advertising clause from University of California Regent's license,imp2004-04-051-4/+0
| | | | | | per letter dated July 22, 1999. Approved by: core
* Add support for 'h' and 'hh' modifiers for printf(9).njl2004-02-191-2/+21
| | | | | Submitted by: Bruno Ducrot <ducrot AT poupinou.org> Reviewed by: bde
* Re-arrange and consolidate some random debugging stuffscottl2003-12-071-0/+53
|
* Revert stuff which accidentally ended up in the previous commit.phk2003-07-221-20/+0
|
* Don't attempt to inline large functions mb_alloc() and mb_free(),phk2003-07-221-0/+20
| | | | | | it more than doubles the text size of this file. GCC has wisely ignored us on this previously
* When DDB is active, always send printf() output directly to theiedowse2003-06-221-1/+5
| | | | | | console, even if there is a TIOCCONS console tty. We were already doing this after a panic, but it's also useful when entering DDB for some other reason too.
* Use a new message buffer `consmsgbuf' to forward messages to aiedowse2003-06-221-13/+13
| | | | | | | | | | | | | | | TIOCCONS console (e.g. xconsole) via a timeout routine instead of calling into the tty code directly from printf(). This fixes a number of cases where calling printf() at the wrong time (such as with locks held) would cause a panic if xconsole is running. The TIOCCONS message buffer is 8k in size by default, but this can be changed with the kern.consmsgbuf_size sysctl. By default, messages are checked for 5 times per second. The timer runs and the buffer memory remains allocated only at times when a TIOCCONS console is active. Discussed on: freebsd-arch
* Replace the code for reading and writing the kernel message bufferiedowse2003-06-221-94/+26
| | | | | | | | | | | | | | | | | 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
* Use __FBSDID().obrien2003-06-111-1/+3
|
* Remove unused variable(s).phk2003-05-311-5/+2
| | | | | | Remove break after goto Found by: FlexeLint
* Don't assume that p_session hasn't changed out from under us after unlockingjhb2003-04-171-12/+11
| | | | | | the process and session. Instead, cache a true reference to the session when we do the hold and release our reference on that session. This avoids the need for the proc lock when dropping the reference.
* Add a checksum to the kernel message buffer, and update it everyiedowse2003-03-281-4/+24
| | | | | | | | | | | | time a character is written. Use this at boot time to reject the existing buffer contents if they are corrupt. This fixes a problem seen on some hardware (especially laptops) where the message buffer gets partially corrupted during a short power cycle or reset, but the msgbuf structure is left intact so it gets reused, resulting in random junk and control characters appearing in dmesg and /var/log/messages. PR: kern/28497
* Including <sys/stdint.h> is (almost?) universally only to be able to usephk2003-03-181-1/+0
| | | | | %j in printfs, so put a newsted include in <sys/systm.h> where the printf prototype lives and save everybody else the trouble.
* Back out M_* changes, per decision of the TRB.imp2003-02-191-2/+2
| | | | Approved by: trb
* Add vsnrprintf() which is just like vsnprintf() but takes a "radix"phk2003-02-041-0/+17
| | | | argument for the kernel-special %r format.
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-2/+2
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Cast the integer read as the first argument for %b to an unsigned integerjhb2003-01-071-1/+1
| | | | | | | | | so it's value is not sign extended when assigned to the uintmax_t variable used internally by printf. For example, if bit 31 is set in the cpuid feature word, then %b would print out the initial value as a 16 character hexadecimal value. Now it only prints out an 8 character value. Reviewed by: bde
* Move #include of ddb/ddb.h up with the rest.phk2003-01-041-2/+6
|
* Make the msg_size, msg_bufx and msg_bufr memebers of struct msgbuftmm2002-11-141-2/+3
| | | | | | | | | | | signed, since they describe a ring buffer and signed arithmetic is performed on them. This avoids some evilish casts. Since this changes all but two members of this structure, style(9) those remaining ones, too. Requested by: bde Reviewed by: bde (earlier version)
* Add support for the C99 %t format modifier.mux2002-11-131-2/+11
|
* - Rename the DDB specific %z printf format to %y.mux2002-10-251-3/+12
| | | | | | | | | | - Make DDB use %y instead of %z. - Teach GCC about %y. - Implement support for the C99 %z format modifier. Approved by: re@ Reviewed by: peter Tested on: i386, sparc64
* Fix %z to always print values as signed like it is supposed to.jhb2002-10-111-2/+2
| | | | | Reviewed by: bde Tested on: i386 in ddb
* Change a return to a break so the local buffers get properly freeed.phk2002-09-281-1/+1
| | | | | | Spotte by: FlexeLint Reviewed by: rwatson
* Make kern.log_console_output a tuneable aswell as a sysctl.dwmalone2002-08-111-0/+1
| | | | MFC after: 1 week
* dd %i as an alias for %d for greater compatibility with our *BSD bretherenimp2002-07-051-0/+1
| | | | | Obtained from: NetBSD Reviewed by: jake, rwatson, bosko
* More caddr_t removal.alfred2002-06-291-1/+1
| | | | Change struct knote's kn_hook from caddr_t to void *.
* ANSIfy the one remaining K&R function.des2002-06-021-4/+1
|
* Whitespace nits.des2002-06-021-2/+2
|
* Add support for 'j' flag. Simplify the size modifier code and reduce codedes2002-06-021-100/+71
| | | | | | duplication. Also add support for 'n' specifier. Reviewed by: bde
* Add a sysctl which disables the logging of console output.dwmalone2002-04-291-0/+7
| | | | | Approved by: phk MFC after: 2 weeks
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-04-011-1/+1
| | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
* Remove __P.alfred2002-03-191-4/+4
|
* Stop abusing the pgrpsess_lock.tanimura2002-03-111-4/+2
|
* Lock struct pgrp, session and sigio.tanimura2002-02-231-15/+45
| | | | | | | | | | | | | | | | | | | | | | | | | New locks are: - pgrpsess_lock which locks the whole pgrps and sessions, - pg_mtx which protects the pgrp members, and - s_mtx which protects the session members. Please refer to sys/proc.h for the coverage of these locks. Changes on the pgrp/session interface: - pgfind() needs the pgrpsess_lock held. - The caller of enterpgrp() is responsible to allocate a new pgrp and session. - Call enterthispgrp() in order to enter an existing pgrp. - pgsignal() requires a pgrp lock held. Reviewed by: jhb, alfred Tested on: cvsup.jp.FreeBSD.org (which is a quad-CPU machine running -current)
* Style(9) nits.phk2002-02-101-9/+9
| | | | Obtained from: ~bde/sys.dif.gz
* - Attempt to help declutter kern. sysctl by moving security out fromarr2002-01-161-2/+2
| | | | | | beneath it. Reviewed by: rwatson
* o Introduce kern.security.bsd.unprivileged_read_msgbuf, which allowsrwatson2001-11-301-0/+13
| | | | | | | | | | | the administrator to restrict access to the kernel message buffer. It defaults to '1', which permits access, but if set to '0', requires that the process making the sysctl() have appropriate privilege. o Note that for this to be effective, access to this data via system logs derived from /dev/klog must also be limited. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
OpenPOWER on IntegriCloud