#
fdafd315 |
|
24-Nov-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Automated cleanup of cdefs and other formatting Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
|
#
e738085b |
|
17-Aug-2023 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Remove my middle name.
|
#
685dc743 |
|
16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: one-line .c pattern Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
|
#
4d846d26 |
|
10-May-2023 |
Warner Losh <imp@FreeBSD.org> |
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
|
#
7835b2cb |
|
05-Oct-2021 |
Alexander Motin <mav@FreeBSD.org> |
sbuf(9): Microoptimize sbuf_put_byte() This function is actively used by sbuf_vprintf(), so this simple inlining in half reduces time of kern.geom.confxml generation. MFC after: 2 weeks Sponsored by: iXsystem, Inc.
|
#
116f26f9 |
|
13-Apr-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
sbuf_uionew(): sbuf_new() takes int as length and length should be not less than SBUF_MINSIZE Reported and tested by: pho Noted and reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29752
|
#
cad4fd03 |
|
02-Apr-2021 |
Richard Scheffenegger <rscheff@FreeBSD.org> |
Make sbuf_drain safe for external use While sbuf_drain was an internal function, two KASSERTS checked the sanity of it being called. However, an external caller may be ignorant if there is any data to drain, or if an error has already accumulated. Be nice and return immediately with the accumulated error. MFC after: 2 weeks Reviewed By: tuexen, #transport Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D29544
|
#
c804c8f2 |
|
31-Mar-2021 |
Richard Scheffenegger <rscheff@FreeBSD.org> |
Export sbuf_drain to orchestrate lock and drain action While exporting large amounts of data to a sysctl request, datastructures may need to be locked. Exporting the sbuf_drain function allows the coordination between drain events and held locks, to avoid stalls. PR: 254333 Reviewed By: jhb MFC after: 2 weeks Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D29481
|
#
3ff65f71 |
|
30-Jan-2020 |
Mateusz Guzik <mjg@FreeBSD.org> |
Remove duplicated empty lines from kern/*.c No functional changes.
|
#
76cb1112 |
|
07-Aug-2019 |
Conrad Meyer <cem@FreeBSD.org> |
sbuf(9): Add sbuf_nl_terminate() API The API is used to gracefully terminate text line(s) with a single \n. If the formatted buffer was empty or already ended in \n, it is unmodified. Otherwise, a newline character is appended to it. The API, like other sbuf-modifying routines, is only valid while the sbuf is not FINISHED. Reviewed by: rlibby Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D21030
|
#
d23813cd |
|
07-Aug-2019 |
Conrad Meyer <cem@FreeBSD.org> |
sbuf(9): Refactor sbuf_newbuf into sbuf_new Code flow was somewhat difficult to read due to the combination of multiple return sites and the 4x possible dynamic constructions of an sbuf. (Future consideration: do we need all 4?) Refactored slightly to improve legibility. No functional change. Sponsored by: Dell EMC Isilon
|
#
71db411e |
|
07-Aug-2019 |
Conrad Meyer <cem@FreeBSD.org> |
sbuf(9): Add NOWAIT dynamic buffer extension mode The goal is to avoid some kinds of low-memory deadlock when formatting heap-allocated buffers. Reviewed by: vangyzen Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D21015
|
#
eeea0fcf |
|
19-Jun-2019 |
Alexander Motin <mav@FreeBSD.org> |
Fix typo in r349178. Reported by: ae MFC after: 1 week
|
#
5c32e9fc |
|
18-Jun-2019 |
Alexander Motin <mav@FreeBSD.org> |
Optimize kern.geom.conf* sysctls. On large systems those sysctls may generate megabytes of output. Before this change sbuf(9) code was resizing buffer by 4KB each time many times, generating tons of TLB shootdowns. Unfortunately in this case existing sbuf_new_for_sysctl() mechanism, supposed to help with this issue, is not applicable, since all the sbuf writes are done in different kernel thread. This change improves situation in two ways: - on first sysctl call, not providing any output buffer, it sets special sbuf drain function, just counting the data and so not needing big buffer; - on second sysctl call it uses as initial buffer size value saved on previous call, so that in most cases there will be no reallocation, unless GEOM topology changed significantly. MFC after: 1 week Sponsored by: iXsystems, Inc.
|
#
8a36da99 |
|
27-Nov-2017 |
Pedro F. Giffuni <pfg@FreeBSD.org> |
sys/kern: adoption of SPDX licensing ID tags. Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. 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.
|
#
9a61faf6 |
|
17-Aug-2017 |
Lawrence Stewart <lstewart@FreeBSD.org> |
An off-by-one error exists in sbuf_vprintf()'s use of SBUF_HASROOM() when an sbuf is filled to capacity by vsnprintf(), the loop exits without error, and the sbuf is not marked as auto-extendable. SBUF_HASROOM() evaluates true if there is room for one or more non-NULL characters, but in the case that the sbuf was filled exactly to capacity, SBUF_HASROOM() evaluates false. Consequently, sbuf_vprintf() incorrectly assigns an ENOMEM error to the sbuf when in fact everything is fine, in turn poisoning the buffer for all subsequent operations. Correct by moving the ENOMEM assignment into the loop where it can be made unambiguously. As a related safety net change, explicitly check for the zero bytes drained case in sbuf_drain() and set EDEADLK as the error. This avoids an infinite loop in sbuf_vprintf() if a drain function were to inadvertently return a value of zero to sbuf_drain(). Reviewed by: cem, jtl, gallatin MFC after: 2 weeks Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D8535
|
#
a8ec96af |
|
17-Aug-2017 |
Lawrence Stewart <lstewart@FreeBSD.org> |
Implement simple record boundary tracking in sbuf(9) to avoid record splitting during drain operations. When an sbuf is configured to use this feature by way of the SBUF_DRAINTOEOR sbuf_new() flag, top-level sections started with sbuf_start_section() create a record boundary marker that is used to avoid flushing partial records. Reviewed by: cem,imp,wblock MFC after: 2 weeks Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D8536
|
#
d700db78 |
|
18-Jul-2017 |
Enji Cooper <ngie@FreeBSD.org> |
Fix whitespace regression accidentally checked in via ^/head@r280149 MFC after: now
|
#
d58b610f |
|
02-Oct-2015 |
Poul-Henning Kamp <phk@FreeBSD.org> |
Fail the sbuf if vsnprintf(3) fails.
|
#
2f1c4e0e |
|
25-Sep-2015 |
Conrad Meyer <cem@FreeBSD.org> |
sbuf: Process more than one char at a time Revamp sbuf_put_byte() to sbuf_put_bytes() in the obvious fashion and fixup callers. Add a thin shim around sbuf_put_bytes() with the old ABI to avoid ugly changes to some callers. Reviewed by: jhb, markj Obtained from: Dan Sledz Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3717
|
#
612d9391 |
|
17-Mar-2015 |
Ian Lepore <ian@FreeBSD.org> |
The minimum sbuf buffer size is 2 bytes (a byte plus a nulterm), assert that. Values smaller than two lead to strange asserts that have nothing to do with the actual problem (in the case of size=0), or to writing beyond the end of the allocated buffer in sbuf_finish() (in the case of size=1).
|
#
8d5628fd |
|
16-Mar-2015 |
Ian Lepore <ian@FreeBSD.org> |
Update an sbuf assertion to allow for the new SBUF_INCLUDENUL flag. If INCLUDENUL is set and sbuf_finish() has been called, the length has been incremented to count the nulterm byte, and in that case current length is allowed to be equal to buffer size, otherwise it must be less than. Add a predicate macro to test for SBUF_INCLUDENUL, and use it in tests, to be consistant with the style in the rest of this file.
|
#
f4d28142 |
|
14-Mar-2015 |
Ian Lepore <ian@FreeBSD.org> |
Add a new flag, SBUF_INCLUDENUL, and new get/set/clear functions for flags. The SBUF_INCLUDENUL flag causes the nulterm byte at the end of the string to be counted in the length of the data. If copying the data using the sbuf_data() and sbuf_len() functions, or if writing it automatically with a drain function, the net effect is that the nulterm byte is copied along with the rest of the data.
|
#
adecd05b |
|
28-Jul-2014 |
Pietro Cerutti <gahr@FreeBSD.org> |
Unbreak the ABI by reverting r268494 until the compat shims are provided
|
#
7150b86b |
|
10-Jul-2014 |
Pietro Cerutti <gahr@FreeBSD.org> |
Implement Short/Small String Optimization in SBUF(9) and change lengths and positions in the API from ssize_t and int to size_t. CR: D388 Approved by: des, bapt
|
#
0f7bc112 |
|
22-Sep-2013 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Always request zeroed memory, in case we're dumb enough to leak it later. Approved by: re (gjb)
|
#
c532f8c4 |
|
16-May-2013 |
Jaakko Heinonen <jh@FreeBSD.org> |
A library function shall not set errno to 0. Reviewed by: mdf
|
#
ddb9b612 |
|
11-Apr-2013 |
Mikolaj Golub <trociny@FreeBSD.org> |
Add sbuf_start_section() and sbuf_end_section() functions, which can be used for automatic section alignment. Discussed with: kib Reviewed by: kib MFC after: 1 month
|
#
311fa10b |
|
19-Aug-2011 |
Robert Watson <rwatson@FreeBSD.org> |
r222015 introduced a new assertion that the size of a fixed-length sbuf buffer is greater than 1. This triggered panics in at least one spot in the kernel (the MAC Framework) which passes non-negative, rather than >1 buffer sizes based on the size of a user buffer passed into a system call. While 0-size buffers aren't particularly useful, they also aren't strictly incorrect, so loosen the assertion. Discussed with: phk (fears I might be EDOOFUS but willing to go along) Spotted by: pho + stress2 Approved by: re (kib)
|
#
384bf94c |
|
17-May-2011 |
Poul-Henning Kamp <phk@FreeBSD.org> |
Use memset() instead of bzero() and memcpy() instead of bcopy(), there is no relevant difference for sbufs, and it increases portability of the source code. Split the actual initialization of the sbuf into a separate local function, so that certain static code checkers can understand what sbuf_new() does, thus eliminating on silly annoyance of MISRA compliance testing. Contributed by: An anonymous company in the last business I expected sbufs to invade.
|
#
eb05ee7a |
|
17-May-2011 |
Poul-Henning Kamp <phk@FreeBSD.org> |
Don't expect PAGE_SIZE to exist on all platforms (It is a pretty arbitrary choice of default size in the first place) Reverse the order of arguments to the internal static sbuf_put_byte() function to match everything else in this file. Move sbuf_putc_func() inside the kernel version of sbuf_vprintf where it belongs. sbuf_putc() incorrectly used sbuf_putc_func() which supress NUL characters, it should use sbuf_put_byte(). Make sbuf_finish() return -1 on error. Minor stylistic nits fixed.
|
#
71c2bc5c |
|
16-May-2011 |
Poul-Henning Kamp <phk@FreeBSD.org> |
Change the length quantities of sbufs to be ssize_t rather than int. Constify a couple of arguments.
|
#
a7d5f7eb |
|
19-Oct-2010 |
Jamie Gritton <jamie@FreeBSD.org> |
A new jail(8) with a configuration file, to replace the work currently done by /etc/rc.d/jail.
|
#
4e657159 |
|
16-Sep-2010 |
Matthew D Fleming <mdf@FreeBSD.org> |
Re-add r212370 now that the LOR in powerpc64 has been resolved: Add a drain function for struct sysctl_req, and use it for a variety of handlers, some of which had to do awkward things to get a large enough SBUF_FIXEDLEN buffer. Note that some sysctl handlers were explicitly outputting a trailing NUL byte. This behaviour was preserved, though it should not be necessary. Reviewed by: phk (original patch)
|
#
404a593e |
|
13-Sep-2010 |
Matthew D Fleming <mdf@FreeBSD.org> |
Revert r212370, as it causes a LOR on powerpc. powerpc does a few unexpected things in copyout(9) and so wiring the user buffer is not sufficient to perform a copyout(9) while holding a random mutex. Requested by: nwhitehorn
|
#
eb262be3 |
|
11-Sep-2010 |
Alexander Kabaev <kan@FreeBSD.org> |
Add missing pointer increment to sbuf_cat.
|
#
4d369413 |
|
10-Sep-2010 |
Matthew D Fleming <mdf@FreeBSD.org> |
Replace sbuf_overflowed() with sbuf_error(), which returns any error code associated with overflow or with the drain function. While this function is not expected to be used often, it produces more information in the form of an errno that sbuf_overflowed() did.
|
#
dd67e210 |
|
09-Sep-2010 |
Matthew D Fleming <mdf@FreeBSD.org> |
Add a drain function for struct sysctl_req, and use it for a variety of handlers, some of which had to do awkward things to get a large enough FIXEDLEN buffer. Note that some sysctl handlers were explicitly outputting a trailing NUL byte. This behaviour was preserved, though it should not be necessary. Reviewed by: phk
|
#
4351ba27 |
|
09-Sep-2010 |
Matthew D Fleming <mdf@FreeBSD.org> |
Add drain functionality to sbufs. The drain is a function that is called when the sbuf internal buffer is filled. For kernel sbufs with a drain, the internal buffer will never be expanded. For userland sbufs with a drain, the internal buffer may still be expanded by sbuf_[v]printf(3). Sbufs now have three basic uses: 1) static string manipulation. Overflow is marked. 2) dynamic string manipulation. Overflow triggers string growth. 3) drained string manipulation. Overflow triggers draining. In all cases the manipulation is 'safe' in that overflow is detected and managed. Reviewed by: phk (the previous version)
|
#
01f6f5fc |
|
09-Sep-2010 |
Matthew D Fleming <mdf@FreeBSD.org> |
Refactor sbuf code so that most uses of sbuf_extend() are in a new sbuf_put_byte(). This makes it easier to add drain functionality when a buffer would overflow as there are fewer code points. Reviewed by: phk
|
#
181ff3d5 |
|
03-Sep-2010 |
Matthew D Fleming <mdf@FreeBSD.org> |
Use a better #if guard. Suggested by pluknet <pluknet at gmail dot com>.
|
#
c05dbe7a |
|
03-Sep-2010 |
Matthew D Fleming <mdf@FreeBSD.org> |
Style(9) fixes and eliminate the use of min().
|
#
969292fb |
|
03-Sep-2010 |
Matthew D Fleming <mdf@FreeBSD.org> |
Fix user-space libsbuf build. Why isn't CTASSERT available to user-space?
|
#
f5a5dc5d |
|
03-Sep-2010 |
Matthew D Fleming <mdf@FreeBSD.org> |
Fix brain fart when converting an if statement into a KASSERT.
|
#
f4bafab8 |
|
03-Sep-2010 |
Matthew D Fleming <mdf@FreeBSD.org> |
Use math rather than iteration when the desired sbuf size is larger than SBUF_MAXEXTENDSIZE.
|
#
d7f03759 |
|
19-Oct-2008 |
Ulf Lilleengen <lulf@FreeBSD.org> |
- Import the HEAD csup code which is the basis for the cvsmode work.
|
#
546d7890 |
|
09-Aug-2008 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Switch to simplified BSD license (with phk's approval), plus whitespace and style(9) cleanup.
|
#
49091c48 |
|
23-Dec-2005 |
Poul-Henning Kamp <phk@FreeBSD.org> |
Make sbuf_copyin() return the number of bytes copied on success. Submitted by: "Wojciech A. Koszek" <dunstan@freebsd.czest.pl>
|
#
c711aea6 |
|
09-Feb-2005 |
Poul-Henning Kamp <phk@FreeBSD.org> |
Make a bunch of malloc types static. Found by: src/tools/tools/kernxref
|
#
520df276 |
|
09-Jul-2004 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Cosmetic adjustment to previous commit: name the second argument to sbuf_bcat() and sbuf_bcpy() "buf" rather than "data".
|
#
d751f0a9 |
|
09-Jul-2004 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Have sbuf_bcat() and sbuf_bcpy() take a const void * instead of a const char *, since callers are likely to pass in pointers to all kinds of structs and whatnot.
|
#
963385cf |
|
17-Feb-2004 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Mechanical whistespace cleanup.
|
#
677b542e |
|
10-Jun-2003 |
David E. O'Brien <obrien@FreeBSD.org> |
Use __FBSDID().
|
#
a9a0bbad |
|
25-May-2003 |
Peter Wemm <peter@FreeBSD.org> |
Copy the va_list in sbuf_vprintf() before passing it to vsnprintf(), because we could fail due to a small buffer and loop and rerun. If this happens, then the vsnprintf() will have already taken the arguments off the va_list. For i386 and others, this doesn't matter because the va_list type is a passed as a copy. But on powerpc and amd64, this is fatal because the va_list is a reference to an external structure that keeps the vararg state due to the more complicated argument passing system. On amd64, arguments can be passed as follows: First 6 int/pointer type arguments go in registers, the rest go on the memory stack. Float and double are similar, except using SSE registers. long double (80 bit precision) are similar except using the x87 stack. Where the 'next argument' comes from depends on how many have been processed so far and what type it is. For amd64, gcc keeps this state somewhere that is referenced by the va_list. I found a description that showed the va_copy was required here: http://mirrors.ccs.neu.edu/cgi-bin/unixhelp/man-cgi?va_end+9 The single unix spec doesn't mention va_copy() at all. Anyway, the problem was that the sysctl kern.geom.conf* nodes would panic due to walking off the end of the va_arg lists in vsnprintf. A better fix would be to have sbuf_vprintf() use a single pass and call kvprintf() with a callback function that stored the results and grew the buffer as needed. Approved by: re (scottl)
|
#
a163d034 |
|
18-Feb-2003 |
Warner Losh <imp@FreeBSD.org> |
Back out M_* changes, per decision of the TRB. Approved by: trb
|
#
44956c98 |
|
21-Jan-2003 |
Alfred Perlstein <alfred@FreeBSD.org> |
Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0. Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
|
#
c5f9218b |
|
04-Oct-2002 |
Poul-Henning Kamp <phk@FreeBSD.org> |
Add the new function "sbuf_done()" which returns non-zero if the sbuf is finished. This allows sbufs to be used for request/response scenarioes without needing additional communication flags. Sponsored by: DARPA & NAI Labs.
|
#
7b088102 |
|
16-Sep-2002 |
Poul-Henning Kamp <phk@FreeBSD.org> |
Add a cast to make this file compile in userland on sparc64 without warnings.
|
#
a5e7c7da |
|
19-Mar-2002 |
Peter Wemm <peter@FreeBSD.org> |
Fix warnings on gcc-3.1+ where __func__ is a const char * instead of a string.
|
#
9118ec5a |
|
24-Jan-2002 |
Poul-Henning Kamp <phk@FreeBSD.org> |
Yet a bug with extensible sbufs being marked as OVERFLOWED. This time because of a signed/unsigned problem. Approved by: DES
|
#
1a25c86b |
|
22-Jan-2002 |
Poul-Henning Kamp <phk@FreeBSD.org> |
In certain cases sbuf_printf() and sbuf_vprintf() could mistakely make extendable sbufs as overflowed. Approved by: des
|
#
2bbe1e9d |
|
09-Jan-2002 |
Kelly Yancey <kbyanc@FreeBSD.org> |
Replace spaces after #defines with tabs; this makes all #defines consistent in their adherence with style(9).
|
#
7195eb40 |
|
06-Jan-2002 |
Kelly Yancey <kbyanc@FreeBSD.org> |
* Implement SBUF_AUTOEXTEND flag; sbufs created with this flag are automatically extended to prevent overflow. * Added sbuf_vprintf(); sbuf_printf() is now just a wrapper around sbuf_vprintf(). * Include <stdio.h> and <string.h> when building libsbuf to silence WARNS=4 warnings. Reviewed by: des
|
#
a57094a0 |
|
19-Dec-2001 |
Matthew Dillon <dillon@FreeBSD.org> |
Calculate whether the sbuf is dynamic *before* bzero()ing the structure. This fixes a serious memory leak in the sbuf code. MFC after: 3 days
|
#
a48740b6 |
|
09-Dec-2001 |
David E. O'Brien <obrien@FreeBSD.org> |
Update to C99, s/__FUNCTION__/__func__/.
|
#
5b6db477 |
|
28-Sep-2001 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Add a couple of API functions I need for my pseudofs WIP. Documentation will follow when I've decided whether to keep this API or ditch it in favor of something slightly more subtle.
|
#
2687c874 |
|
03-Jul-2001 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Constify the format string. Submitted by: Mike Barcroft <mike@q9media.com>
|
#
9fa416ca |
|
16-Jun-2001 |
Jonathan Lemon <jlemon@FreeBSD.org> |
Fix warnings: 112: warning: cast to pointer from integer of different size 125: warning: cast to pointer from integer of different size
|
#
fe463496 |
|
11-Jun-2001 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Blah, I cut out a tad too much in the previous commit. (thanks again, Jake!)
|
#
e3b37322 |
|
11-Jun-2001 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
copyin(9) doesn't return ENAMETOOLONG. (thanks, Jake!)
|
#
b0def2b5 |
|
11-Jun-2001 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Add sbuf_copyin(). Also add 'b' variants of sbuf_{cat,copyin,cpy}() which ignore NUL bytes in the source string.
|
#
d6479358 |
|
10-Jun-2001 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
sbuf_new(9) now returns a struct sbuf * instead of an int. If the caller does not provide a struct sbuf, sbuf_new(9) will allocate one and return a pointer to it.
|
#
3393f8da |
|
26-Mar-2001 |
Kenneth D. Merry <ken@FreeBSD.org> |
Rewrite of the CAM error recovery code. Some of the major changes include: - The SCSI error handling portion of cam_periph_error() has been broken out into a number of subfunctions to better modularize the code that handles the hierarchy of SCSI errors. As a result, the code is now much easier to read. - String handling and error printing has been significantly revamped. We now use sbufs to do string formatting instead of using printfs (for the kernel) and snprintf/strncat (for userland) as before. There is a new catchall error printing routine, cam_error_print() and its string-based counterpart, cam_error_string() that allow the kernel and userland applications to pass in a CCB and have errors printed out properly, whether or not they're SCSI errors. Among other things, this helped eliminate a fair amount of duplicate code in camcontrol. We now print out more information than before, including the CAM status and SCSI status and the error recovery action taken to remedy the problem. - sbufs are now available in userland, via libsbuf. This change was necessary since most of the error printing code is shared between libcam and the kernel. - A new transfer settings interface is included in this checkin. This code is #ifdef'ed out, and is primarily intended to aid discussion with HBA driver authors on the final form the interface should take. There is example code in the ahc(4) driver that implements the HBA driver side of the new interface. The new transfer settings code won't be enabled until we're ready to switch all HBA drivers over to the new interface. src/Makefile.inc1, lib/Makefile: Add libsbuf. It must be built before libcam, since libcam uses sbuf routines. libcam/Makefile: libcam now depends on libsbuf. libsbuf/Makefile: Add a makefile for libsbuf. This pulls in the sbuf sources from sys/kern. bsd.libnames.mk: Add LIBSBUF. camcontrol/Makefile: Add -lsbuf. Since camcontrol is statically linked, we can't depend on the dynamic linker to pull in libsbuf. camcontrol.c: Use cam_error_print() instead of checking for CAM_SCSI_STATUS_ERROR on every failed CCB. sbuf.9: Change the prototypes for sbuf_cat() and sbuf_cpy() so that the source string is now a const char *. This is more in line wth the standard system string functions, and helps eliminate warnings when dealing with a const source buffer. Fix a typo. cam.c: Add description strings for the various CAM error status values, as well as routines to look up those strings. Add new cam_error_string() and cam_error_print() routines for userland and the kernel. cam.h: Add a new CAM flag, CAM_RETRY_SELTO. Add enumerated types for the various options available with cam_error_print() and cam_error_string(). cam_ccb.h: Add new transfer negotiation structures/types. Change inq_len in the ccb_getdev structure to be "reserved". This field has never been filled in, and will be removed when we next bump the CAM version. cam_debug.h: Fix typo. cam_periph.c: Modularize cam_periph_error(). The SCSI error handling part of cam_periph_error() is now in camperiphscsistatuserror() and camperiphscsisenseerror(). In cam_periph_lock(), increase the reference count on the periph while we wait for our lock attempt to succeed so that the periph won't go away while we're sleeping. cam_xpt.c: Add new transfer negotiation code. (ifdefed out) Add a new function, xpt_path_string(). This is a string/sbuf analog to xpt_print_path(). scsi_all.c: Revamp string handing and error printing code. We now use sbufs for much of the string formatting code. More of that code is shared between userland the kernel. scsi_all.h: Get rid of SS_TURSTART, it wasn't terribly useful in the first place. Add a new error action, SS_REQSENSE. (Send a request sense and then retry the command.) This is useful when the controller hasn't performed autosense for some reason. Change the default actions around a bit. scsi_cd.c, scsi_da.c, scsi_pt.c, scsi_ses.c: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Selection timeouts shouldn't be covered by a sense flag. scsi_pass.[ch]: SF_RETRY_SELTO -> CAM_RETRY_SELTO. Get rid of the last vestiges of a read/write interface. libkern/bsearch.c, sys/libkern.h, conf/files: Add bsearch.c, which is needed for some of the new table lookup routines. aic7xxx_freebsd.c: Define AHC_NEW_TRAN_SETTINGS if CAM_NEW_TRAN_CODE is defined. sbuf.h, subr_sbuf.c: Add the appropriate #ifdefs so sbufs can compile and run in userland. Change sbuf_printf() to use vsnprintf() instead of kvprintf(), which is only available in the kernel. Change the source string for sbuf_cpy() and sbuf_cat() to be a const char *. Add __BEGIN_DECLS and __END_DECLS around function prototypes since they're now exported to userland. kdump/mkioctls: Include stdio.h before cam.h since cam.h now includes a function with a FILE * argument. Submitted by: gibbs (mostly) Reviewed by: jdp, marcel (libsbuf makefile changes) Reviewed by: des (sbuf changes) Reviewed by: ken
|
#
cab5b963 |
|
06-Mar-2001 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Make the KASSERTs report the correct function names. Fix two off-by-one errors that would sometimes cause the final length of the sbuf to include the trailing zero.
|
#
9fa2ef3d |
|
27-Jan-2001 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Remove an assertion I forgot to remove in the previous commit: sbuf_len() may now be called with an unfinished sbuf. For consistency, copy the related comment from sbuf_delete() to sbuf_clear() and sbuf_len().
|
#
4dc14139 |
|
27-Jan-2001 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
Add sbuf_clear() and sbuf_overflowed(). Move the helper macros from sbuf.h to sbuf.c Use ints instead of size_ts. Relax the requirements for sbuf_finish(): it is now possible to finish an overflowed buffer. Make sbuf_len() return -1 instead of 0 if the sbuf overflowed. Requested by: gibbs
|
#
60ec4130 |
|
13-Dec-2000 |
Dag-Erling Smørgrav <des@FreeBSD.org> |
String buffer API
|