2000-12-13 19:53:37 +00:00
|
|
|
|
.\"-
|
|
|
|
|
.\" Copyright (c) 2000 Poul Henning Kamp and Dag-Erling Co<43>dan Sm<53>rgrav
|
|
|
|
|
.\" All rights reserved.
|
|
|
|
|
.\"
|
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
|
.\" are met:
|
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
|
.\"
|
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
|
.\"
|
|
|
|
|
.\" $FreeBSD$
|
|
|
|
|
.\"
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Dd January 28, 2001
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Dt sbuf 9
|
|
|
|
|
.Os FreeBSD
|
|
|
|
|
.Sh NAME
|
|
|
|
|
.Nm sbuf_new ,
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Nm sbuf_clear ,
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Nm sbuf_setpos ,
|
|
|
|
|
.Nm sbuf_cat ,
|
|
|
|
|
.Nm sbuf_cpy ,
|
|
|
|
|
.Nm sbuf_printf ,
|
|
|
|
|
.Nm sbuf_putc ,
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Nm sbuf_overflowed ,
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Nm sbuf_finish ,
|
|
|
|
|
.Nm sbuf_data ,
|
|
|
|
|
.Nm sbuf_len ,
|
|
|
|
|
.Nm sbuf_delete
|
|
|
|
|
.Nd safe string formatting
|
|
|
|
|
.Sh SYNOPSIS
|
2001-02-15 11:47:31 +00:00
|
|
|
|
.Fd #include <sys/types.h>
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Fd #include <sys/sbuf.h>
|
|
|
|
|
.Ft int
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Fn sbuf_new "struct sbuf *s" "char *buf" "int length" "int flags"
|
|
|
|
|
.Ft void
|
|
|
|
|
.Fn sbuf_clear "struct sbuf *s"
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Ft int
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Fn sbuf_setpos "struct sbuf *s" "int pos"
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Ft int
|
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
2001-03-27 05:45:52 +00:00
|
|
|
|
.Fn sbuf_cat "struct sbuf *s" "const char *str"
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Ft int
|
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
2001-03-27 05:45:52 +00:00
|
|
|
|
.Fn sbuf_cpy "struct sbuf *s" "const char *str"
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Ft int
|
|
|
|
|
.Fn sbuf_printf "struct sbuf *s" "char *fmt" "..."
|
|
|
|
|
.Ft int
|
|
|
|
|
.Fn sbuf_putc "struct sbuf *s" "int c"
|
|
|
|
|
.Ft int
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Fn sbuf_overflowed "struct sbuf *s"
|
|
|
|
|
.Ft void
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Fn sbuf_finish "struct sbuf *s"
|
|
|
|
|
.Ft char *
|
|
|
|
|
.Fn sbuf_data "struct sbuf *s"
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Ft int
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Fn sbuf_len "struct sbuf *s"
|
|
|
|
|
.Ft void
|
|
|
|
|
.Fn sbuf_delete "struct sbuf *s"
|
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
|
The
|
|
|
|
|
.Nm sbuf
|
2000-12-14 09:36:49 +00:00
|
|
|
|
family of functions allows one to safely allocate, construct and
|
2000-12-13 19:53:37 +00:00
|
|
|
|
release bounded null-terminated strings in kernel space.
|
|
|
|
|
Instead of arrays of characters, these functions operate on structures
|
|
|
|
|
called
|
|
|
|
|
.Fa sbufs ,
|
|
|
|
|
defined in
|
|
|
|
|
.Aq Pa sys/sbuf.h .
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fn sbuf_new
|
|
|
|
|
function initializes the
|
|
|
|
|
.Fa sbuf
|
|
|
|
|
pointed to by its first argument.
|
|
|
|
|
The
|
|
|
|
|
.Fa buf
|
|
|
|
|
argument is a pointer to a buffer in which to store the actual string;
|
|
|
|
|
if it is
|
|
|
|
|
.Dv NULL ,
|
|
|
|
|
.Fn sbuf_new
|
|
|
|
|
will allocate one using
|
|
|
|
|
.Xr malloc 9 .
|
|
|
|
|
The
|
|
|
|
|
.Fa length
|
|
|
|
|
is the intended size of the storage buffer.
|
|
|
|
|
The fourth argument,
|
|
|
|
|
.Fa flags ,
|
|
|
|
|
is currently unused and should always be set to zero.
|
|
|
|
|
.Pp
|
|
|
|
|
Note that if
|
|
|
|
|
.Fa buf
|
|
|
|
|
is not
|
|
|
|
|
.Dv NULL ,
|
|
|
|
|
it must point to an array of at least
|
|
|
|
|
.Fa length
|
|
|
|
|
characters.
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Fn sbuf_clear
|
|
|
|
|
function invalidates the contents of the
|
|
|
|
|
.Fa sbuf
|
|
|
|
|
and resets its position to zero.
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Fn sbuf_setpos
|
|
|
|
|
function sets the
|
|
|
|
|
.Fa sbuf Ns 's
|
|
|
|
|
current position to
|
|
|
|
|
.Fa pos ,
|
|
|
|
|
which is a value between zero and one less than the size of the
|
|
|
|
|
storage buffer.
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fn sbuf_cat
|
|
|
|
|
function appends the string
|
|
|
|
|
.Fa str
|
|
|
|
|
to the
|
|
|
|
|
.Fa sbuf
|
|
|
|
|
at the current position.
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fn sbuf_cpy
|
|
|
|
|
function replaces the contents of the
|
|
|
|
|
.Fa sbuf
|
|
|
|
|
with those of the string
|
|
|
|
|
.Fa str .
|
|
|
|
|
This is equivalent to calling
|
|
|
|
|
.Fn sbuf_cat
|
|
|
|
|
with a fresh
|
|
|
|
|
.Fa sbuf
|
|
|
|
|
or one which position has been reset to zero with
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Fn sbuf_clear
|
|
|
|
|
or
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Fn sbuf_setpos .
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fn sbuf_printf
|
|
|
|
|
function formats its arguments according to the format string pointed
|
|
|
|
|
to by
|
|
|
|
|
.Fa fmt
|
|
|
|
|
and appends the resulting string to the
|
|
|
|
|
.Fa sbuf
|
|
|
|
|
at the current position.
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fn sbuf_putc
|
|
|
|
|
function appends the character
|
|
|
|
|
.Fa c
|
|
|
|
|
to the
|
|
|
|
|
.Fa sbuf
|
|
|
|
|
at the current position.
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Fn sbuf_overflowed
|
|
|
|
|
function returns a non-zero value if the
|
|
|
|
|
.Fa sbuf
|
|
|
|
|
overflowed.
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Fn sbuf_finish
|
|
|
|
|
function null-terminates the
|
|
|
|
|
.Fa sbuf
|
|
|
|
|
and marks it as finished, which means that it may no longer be
|
|
|
|
|
modified using
|
|
|
|
|
.Fn sbuf_setpos ,
|
|
|
|
|
.Fn sbuf_cat ,
|
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
2001-03-27 05:45:52 +00:00
|
|
|
|
.Fn sbuf_cpy ,
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Fn sbuf_printf
|
|
|
|
|
or
|
|
|
|
|
.Fn sbuf_putc .
|
|
|
|
|
.Pp
|
|
|
|
|
The
|
|
|
|
|
.Fn sbuf_data
|
|
|
|
|
and
|
|
|
|
|
.Fn sbuf_len
|
2001-01-28 00:18:54 +00:00
|
|
|
|
functions return the actual string and its length, respectively;
|
|
|
|
|
.Fn sbuf_data
|
|
|
|
|
only works on a finished
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Fa sbuf .
|
|
|
|
|
.Pp
|
|
|
|
|
Finally, the
|
|
|
|
|
.Fn sbuf_delete
|
|
|
|
|
function clears the
|
|
|
|
|
.Fa sbuf
|
|
|
|
|
and frees its storage buffer if it was allocated by
|
|
|
|
|
.Fn sbuf_new .
|
|
|
|
|
.Sh NOTES
|
|
|
|
|
If an operation caused an
|
|
|
|
|
.Fa sbuf
|
2001-01-28 00:18:54 +00:00
|
|
|
|
to overflow, most subsequent operations on it will fail until the
|
|
|
|
|
.Fa sbuf
|
|
|
|
|
is finished using
|
|
|
|
|
.Fn sbuf_finish
|
|
|
|
|
or reset using
|
|
|
|
|
.Fn sbuf_clear ,
|
|
|
|
|
or its position is reset to a value between 0 and one less than the
|
|
|
|
|
size of its storage buffer using
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Fn sbuf_setpos ,
|
|
|
|
|
or it is reinitialized to a sufficiently short string using
|
|
|
|
|
.Fn sbuf_cpy .
|
|
|
|
|
.Sh RETURN VALUES
|
|
|
|
|
.Fn sbuf_new
|
|
|
|
|
returns \-1 if it failed to allocate a storage buffer, and zero
|
|
|
|
|
otherwise.
|
|
|
|
|
.Pp
|
|
|
|
|
.Fn sbuf_setpos
|
|
|
|
|
returns \-1 if
|
|
|
|
|
.Fa pos
|
|
|
|
|
was invalid, and zero otherwise.
|
|
|
|
|
.Pp
|
|
|
|
|
.Fn sbuf_cat ,
|
|
|
|
|
.Fn sbuf_cpy ,
|
|
|
|
|
.Fn sbuf_printf ,
|
|
|
|
|
and
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Fn sbuf_putc
|
2000-12-13 19:53:37 +00:00
|
|
|
|
all return \-1 if the buffer overflowed, and zero otherwise.
|
|
|
|
|
.Pp
|
2001-01-28 00:18:54 +00:00
|
|
|
|
.Fn sbuf_overflowed
|
|
|
|
|
returns a non-zero value if the buffer overflowed, and zero otherwise.
|
|
|
|
|
.Pp
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Fn sbuf_data
|
|
|
|
|
and
|
|
|
|
|
.Fn sbuf_len
|
|
|
|
|
return
|
|
|
|
|
.Dv NULL
|
2001-01-28 00:18:54 +00:00
|
|
|
|
and \-1, respectively, if the buffer overflowed.
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Sh SEE ALSO
|
|
|
|
|
.Xr printf 3 ,
|
|
|
|
|
.Xr strcat 3 ,
|
|
|
|
|
.Xr strcpy 3
|
|
|
|
|
.Sh HISTORY
|
|
|
|
|
The
|
|
|
|
|
.Nm sbuf
|
|
|
|
|
family of functions first appeared in
|
|
|
|
|
.Fx 4.3 .
|
|
|
|
|
.Sh AUTHORS
|
|
|
|
|
.An -nosplit
|
|
|
|
|
The
|
|
|
|
|
.Nm sbuf
|
|
|
|
|
family of functions was designed by
|
|
|
|
|
.An Poul-Henning Kamp Aq phk@FreeBSD.org
|
|
|
|
|
and implemented by
|
|
|
|
|
.An Dag-Erling Co\(:idan Sm\(/orgrav Aq des@FreeBSD.org .
|
2001-01-28 00:18:54 +00:00
|
|
|
|
Additional improvements were suggested by
|
|
|
|
|
.An Justin T. Gibbs Aq gibbs@FreeBSD.org .
|
2000-12-13 19:53:37 +00:00
|
|
|
|
.Pp
|
|
|
|
|
This manual page was written by
|
|
|
|
|
.An Dag-Erling Co\(:idan Sm\(/orgrav .
|