aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_prf.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Correct an incorrect comment from the dawn of time: neither tprintf()Robert Watson2005-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 Notes: svn path=/head/; revision=150370
* Add GIANT_REQUIRED and WITNESS sleep warnings to uprintf() and tprintf(),Robert Watson2005-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 Notes: svn path=/head/; revision=150335
* When padding with zero, do pad after prefixes rather than paddingXin LI2005-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 Notes: svn path=/head/; revision=149784
* If we ignore an unknown % sequence, we must stop interpreting thePoul-Henning Kamp2005-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 Notes: svn path=/head/; revision=149756
* Make "show msgbuf" use the pager instead of blasting the whole thing out.Doug White2005-06-061-2/+5
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=147064
* Constify hexdump() harder.Poul-Henning Kamp2005-04-061-2/+2
| | | | Notes: svn path=/head/; revision=144706
* In stange circumstances we may end up being the last reference to aPoul-Henning Kamp2005-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) Notes: svn path=/head/; revision=143740
* Update for the KDB framework:Marcel Moolenaar2004-07-101-3/+2
| | | | | | | o Check kdb_active instead of db_active and do so unconditionally. Notes: svn path=/head/; revision=131931
* Clean up and wash struct iovec and struct uio handling.Poul-Henning Kamp2004-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. Notes: svn path=/head/; revision=131897
* Add a sysctl/tunable, "kern.always_console_output", that lets you setBrian Feldman2004-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. Notes: svn path=/head/; revision=130700
* Remove advertising clause from University of California Regent's license,Warner Losh2004-04-051-4/+0
| | | | | | | | | per letter dated July 22, 1999. Approved by: core Notes: svn path=/head/; revision=127911
* Add support for 'h' and 'hh' modifiers for printf(9).Nate Lawson2004-02-191-2/+21
| | | | | | | | Submitted by: Bruno Ducrot <ducrot AT poupinou.org> Reviewed by: bde Notes: svn path=/head/; revision=125985
* Re-arrange and consolidate some random debugging stuffScott Long2003-12-071-0/+53
| | | | Notes: svn path=/head/; revision=123215
* Revert stuff which accidentally ended up in the previous commit.Poul-Henning Kamp2003-07-221-20/+0
| | | | Notes: svn path=/head/; revision=117879
* Don't attempt to inline large functions mb_alloc() and mb_free(),Poul-Henning Kamp2003-07-221-0/+20
| | | | | | | | | it more than doubles the text size of this file. GCC has wisely ignored us on this previously Notes: svn path=/head/; revision=117878
* When DDB is active, always send printf() output directly to theIan Dowse2003-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. Notes: svn path=/head/; revision=116664
* Use a new message buffer `consmsgbuf' to forward messages to aIan Dowse2003-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 Notes: svn path=/head/; revision=116663
* Replace the code for reading and writing the kernel message bufferIan Dowse2003-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 Notes: svn path=/head/; revision=116660
* Use __FBSDID().David E. O'Brien2003-06-111-1/+3
| | | | Notes: svn path=/head/; revision=116182
* Remove unused variable(s).Poul-Henning Kamp2003-05-311-5/+2
| | | | | | | | | Remove break after goto Found by: FlexeLint Notes: svn path=/head/; revision=115538
* Don't assume that p_session hasn't changed out from under us after unlockingJohn Baldwin2003-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. Notes: svn path=/head/; revision=113634
* Add a checksum to the kernel message buffer, and update it everyIan Dowse2003-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 Notes: svn path=/head/; revision=112732
* Including <sys/stdint.h> is (almost?) universally only to be able to usePoul-Henning Kamp2003-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. Notes: svn path=/head/; revision=112367
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-2/+2
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Add vsnrprintf() which is just like vsnprintf() but takes a "radix"Poul-Henning Kamp2003-02-041-0/+17
| | | | | | | argument for the kernel-special %r format. Notes: svn path=/head/; revision=110316
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-2/+2
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Cast the integer read as the first argument for %b to an unsigned integerJohn Baldwin2003-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 Notes: svn path=/head/; revision=108890
* Move #include of ddb/ddb.h up with the rest.Poul-Henning Kamp2003-01-041-2/+6
| | | | Notes: svn path=/head/; revision=108678
* Make the msg_size, msg_bufx and msg_bufr memebers of struct msgbufThomas Moestl2002-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) Notes: svn path=/head/; revision=106917
* Add support for the C99 %t format modifier.Maxime Henrion2002-11-131-2/+11
| | | | Notes: svn path=/head/; revision=106855
* - Rename the DDB specific %z printf format to %y.Maxime Henrion2002-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 Notes: svn path=/head/; revision=105954
* Fix %z to always print values as signed like it is supposed to.John Baldwin2002-10-111-2/+2
| | | | | | | | Reviewed by: bde Tested on: i386 in ddb Notes: svn path=/head/; revision=104924
* Change a return to a break so the local buffers get properly freeed.Poul-Henning Kamp2002-09-281-1/+1
| | | | | | | | | Spotte by: FlexeLint Reviewed by: rwatson Notes: svn path=/head/; revision=104114
* Make kern.log_console_output a tuneable aswell as a sysctl.David Malone2002-08-111-0/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=101693
* dd %i as an alias for %d for greater compatibility with our *BSD bretherenWarner Losh2002-07-051-0/+1
| | | | | | | | Obtained from: NetBSD Reviewed by: jake, rwatson, bosko Notes: svn path=/head/; revision=99459
* More caddr_t removal.Alfred Perlstein2002-06-291-1/+1
| | | | | | | Change struct knote's kn_hook from caddr_t to void *. Notes: svn path=/head/; revision=98998
* ANSIfy the one remaining K&R function.Dag-Erling Smørgrav2002-06-021-4/+1
| | | | Notes: svn path=/head/; revision=97751
* Whitespace nits.Dag-Erling Smørgrav2002-06-021-2/+2
| | | | Notes: svn path=/head/; revision=97750
* Add support for 'j' flag. Simplify the size modifier code and reduce codeDag-Erling Smørgrav2002-06-021-100/+71
| | | | | | | | | duplication. Also add support for 'n' specifier. Reviewed by: bde Notes: svn path=/head/; revision=97749
* Add a sysctl which disables the logging of console output.David Malone2002-04-291-0/+7
| | | | | | | | Approved by: phk MFC after: 2 weeks Notes: svn path=/head/; revision=95713
* Change the suser() API to take advantage of td_ucred as well as do aJohn Baldwin2002-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@ Notes: svn path=/head/; revision=93593
* Remove __P.Alfred Perlstein2002-03-191-4/+4
| | | | Notes: svn path=/head/; revision=92723
* Stop abusing the pgrpsess_lock.Seigo Tanimura2002-03-111-4/+2
| | | | Notes: svn path=/head/; revision=92069
* Lock struct pgrp, session and sigio.Seigo 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) Notes: svn path=/head/; revision=91140
* Style(9) nits.Poul-Henning Kamp2002-02-101-9/+9
| | | | | | | Obtained from: ~bde/sys.dif.gz Notes: svn path=/head/; revision=90490
* - Attempt to help declutter kern. sysctl by moving security out fromAndrew R. Reiter2002-01-161-2/+2
| | | | | | | | | beneath it. Reviewed by: rwatson Notes: svn path=/head/; revision=89414
* o Introduce kern.security.bsd.unprivileged_read_msgbuf, which allowsRobert Watson2001-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 Notes: svn path=/head/; revision=87150
* Properly sanity-check the old msgbuf structure before we accept itIan Dowse2001-11-091-3/+6
| | | | | | | | | | | | | | | | as being valid. Previously only the magic number and the virtual address were checked, but it makes little sense to require that the virtual address is the same (the message buffer is located at the end of physical memory), and checks on the msg_bufx and msg_bufr indices were missing. Submitted by: Bodo Rueskamp <br@clabsms.de> Tripped over during a kernel debugging tutorial given by: grog Reviewed by: grog, dwmalone MFC after: 1 week Notes: svn path=/head/; revision=86238
* KSE Milestone 2Julian Elischer2001-09-121-2/+3
| | | | | | | | | | | | | | | | | Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process. Sorry john! (your next MFC will be a doosie!) Reviewed by: peter@freebsd.org, dillon@freebsd.org X-MFC after: ha ha ha ha Notes: svn path=/head/; revision=83366
* Make the code to read the kernel message buffer via sysctl machine-Thomas Moestl2001-07-031-0/+45
| | | | | | | | independent and rename the corresponding sysctls from machdep.msgbuf and machdep.msgbuf_clear (i386 only) to kern.msgbuf and kern.msgbuf_clear. Notes: svn path=/head/; revision=79153