diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/sesd/Makefile | 41 | ||||
-rw-r--r-- | usr.sbin/sesd/Makefile.inc | 50 | ||||
-rw-r--r-- | usr.sbin/sesd/getencstat/Makefile | 40 | ||||
-rw-r--r-- | usr.sbin/sesd/getencstat/getencstat.8 | 80 | ||||
-rw-r--r-- | usr.sbin/sesd/sesd/Makefile | 40 | ||||
-rw-r--r-- | usr.sbin/sesd/sesd/sesd.8 | 86 | ||||
-rw-r--r-- | usr.sbin/sesd/setencstat/Makefile | 40 | ||||
-rw-r--r-- | usr.sbin/sesd/setencstat/setencstat.8 | 74 | ||||
-rw-r--r-- | usr.sbin/sesd/setobjstat/Makefile | 40 | ||||
-rw-r--r-- | usr.sbin/sesd/setobjstat/setobjstat.8 | 69 | ||||
-rw-r--r-- | usr.sbin/sesd/srcs/chpmon.c | 129 | ||||
-rw-r--r-- | usr.sbin/sesd/srcs/eltsub.c | 169 | ||||
-rw-r--r-- | usr.sbin/sesd/srcs/getencstat.c | 157 | ||||
-rw-r--r-- | usr.sbin/sesd/srcs/getnobj.c | 68 | ||||
-rw-r--r-- | usr.sbin/sesd/srcs/getobjmap.c | 89 | ||||
-rw-r--r-- | usr.sbin/sesd/srcs/getobjstat.c | 78 | ||||
-rw-r--r-- | usr.sbin/sesd/srcs/inienc.c | 63 | ||||
-rw-r--r-- | usr.sbin/sesd/srcs/sesd.c | 167 | ||||
-rw-r--r-- | usr.sbin/sesd/srcs/setencstat.c | 70 | ||||
-rw-r--r-- | usr.sbin/sesd/srcs/setobjstat.c | 85 |
20 files changed, 1635 insertions, 0 deletions
diff --git a/usr.sbin/sesd/Makefile b/usr.sbin/sesd/Makefile new file mode 100644 index 00000000000..130eaa71734 --- /dev/null +++ b/usr.sbin/sesd/Makefile @@ -0,0 +1,41 @@ +# $NetBSD: $ +# $OpenBSD: Makefile,v 1.1 2000/02/21 08:45:14 mjacob Exp $ +# $FreeBSD: $ +# +# Copyright (c) 2000 by Matthew Jacob +# 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, +# without modification, immediately at the beginning of the file. +# 2. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# Alternatively, this software may be distributed under the terms of the +# the GNU Public License ("GPL"). +# +# 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. +# +# Matthew Jacob +# Feral Software +# mjacob@feral.com +# + +UNUSED = getobjmap getnobj getobjstat +SUBDIR = getencstat setencstat setobjstat sesd + +.include <bsd.own.mk> +.include <bsd.subdir.mk> diff --git a/usr.sbin/sesd/Makefile.inc b/usr.sbin/sesd/Makefile.inc new file mode 100644 index 00000000000..197b0d5706a --- /dev/null +++ b/usr.sbin/sesd/Makefile.inc @@ -0,0 +1,50 @@ +# $NetBSD: Makefile.inc,v 1.1 2000/02/21 08:10:21 mjacob Exp $ +# $OpenBSD: Makefile.inc,v 1.1 2000/02/21 08:45:14 mjacob Exp $ +# $FreeBSD: $ +# +# Copyright (c) 2000 by Matthew Jacob +# 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, +# without modification, immediately at the beginning of the file. +# 2. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# Alternatively, this software may be distributed under the terms of the +# the GNU Public License ("GPL"). +# +# 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. +# +# Matthew Jacob +# Feral Software +# mjacob@feral.com +# + +SYS != uname -s + +.if ${SYS} == OpenBSD +COPTS += -I/usr/include/scsi -DSESINC="<ses.h>" +.elif ${SYS} == NetBSD +COPTS += -I/usr/include/dev/scsipi -DSESINC="<ses.h>" +.else +COPTS += -I/usr/include/cam/scsi -DSESINC="<scsi_ses.h>" +.endif +# Inherit BINDIR from one level up. +.include "../Makefile.inc" +BINDIR ?= ${DESTDIR}/usr/sbin + +.PATH: ${.CURDIR}/../srcs diff --git a/usr.sbin/sesd/getencstat/Makefile b/usr.sbin/sesd/getencstat/Makefile new file mode 100644 index 00000000000..8baa8255378 --- /dev/null +++ b/usr.sbin/sesd/getencstat/Makefile @@ -0,0 +1,40 @@ +# $NetBSD: $ +# $FreeBSD: src/share/examples/ses/Makefile,v 1.1 2000/01/15 22:47:15 mjacob Exp $ +# +# Copyright (c) 2000 by Matthew Jacob +# 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, +# without modification, immediately at the beginning of the file. +# 2. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# Alternatively, this software may be distributed under the terms of the +# the GNU Public License ("GPL"). +# +# 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. +# +# Matthew Jacob +# Feral Software +# mjacob@feral.com +# + +MAN = getencstat.8 +SRCS = getencstat.c eltsub.c +PROG = getencstat + +.include <bsd.prog.mk> diff --git a/usr.sbin/sesd/getencstat/getencstat.8 b/usr.sbin/sesd/getencstat/getencstat.8 new file mode 100644 index 00000000000..82d993e9e58 --- /dev/null +++ b/usr.sbin/sesd/getencstat/getencstat.8 @@ -0,0 +1,80 @@ +.\" $NetBSD: $ +.\" $OpenBSD: getencstat.8,v 1.1 2000/02/21 08:45:14 mjacob Exp $ +.\" $FreeBSD: $ +.\" +.\" Copyright (c) 2000 Matthew Jacob +.\" 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, +.\" without modification, immediately at the beginning of the file. +.\" 2. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" Alternatively, this software may be distributed under the terms of the +.\" the GNU Public License ("GPL"). +.\" +.\" 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. +.\" +.\" Matthew Jacob +.\" Feral Software +.\" mjacob@feral.com +.Dd February 21, 2000 +.Dt GETENCSTAT 8 +.Os +.Sh NAME +.Nm getencstat +.Nd get SCSI Environmental Services Device enclosure status +.Sh SYNOPSIS +.Nm +.Op Fl v +.Ar device +.Op Ar device ... +.Sh DESCRIPTION +.Nm +gets summary and detailed SCSI Environmental Services (or SAF-TE) device +enclosure status. The overall status is printed out. If the overall status +is considered okay, nothing else is printed out (unless the the +.Fl v +option is used). +.Pp +A SCSI Environmental Services device enclosure may be either in the state +of being \fBOK\fR, or in one or more of the states of \fBINFORMATIONAL\fR, +\fBNON-CRITICAL\fR, \fBCRITICAL\fB or \fBUNRECOVERABLE\fR states. These +overall states reflect a summary of the states of each object within +such a device (such as power supplies or disk drives). +.Pp +With the +.Fl v +option, the status of all objects within the device is printed, whether +\fBOK\fR or not. Along with the status of each object is the object identifier. +.Pp +The user may then use +.Xr setencstat 8 +to try and clear overall device status, or may use +.Xr setobjstat 8 +to set specific object status. +.Sh FILES +.Bl -tag -width /dev/sesN -compact +.It Pa /dev/ses\fIN\fR +SCSI Environmental Services Devices +.El +.Sh SEE ALSO +.Xr ses 4 , +.Xr sesd 8 , +.Xr setencstat 8 , +.Xr setobjstat 8 +.Sh BUGS diff --git a/usr.sbin/sesd/sesd/Makefile b/usr.sbin/sesd/sesd/Makefile new file mode 100644 index 00000000000..1f2150fdbbb --- /dev/null +++ b/usr.sbin/sesd/sesd/Makefile @@ -0,0 +1,40 @@ +# $NetBSD: $ +# $FreeBSD: src/share/examples/ses/Makefile,v 1.1 2000/01/15 22:47:15 mjacob Exp $ +# +# Copyright (c) 2000 by Matthew Jacob +# 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, +# without modification, immediately at the beginning of the file. +# 2. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# Alternatively, this software may be distributed under the terms of the +# the GNU Public License ("GPL"). +# +# 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. +# +# Matthew Jacob +# Feral Software +# mjacob@feral.com +# + +MAN = sesd.8 +SRCS = sesd.c eltsub.c +PROG = sesd + +.include <bsd.prog.mk> diff --git a/usr.sbin/sesd/sesd/sesd.8 b/usr.sbin/sesd/sesd/sesd.8 new file mode 100644 index 00000000000..56d5bd4b872 --- /dev/null +++ b/usr.sbin/sesd/sesd/sesd.8 @@ -0,0 +1,86 @@ +.\" $NetBSD: $ +.\" $OpenBSD: sesd.8,v 1.1 2000/02/21 08:45:15 mjacob Exp $ +.\" $FreeBSD: $ +.\" +.\" Copyright (c) 2000 Matthew Jacob +.\" 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, +.\" without modification, immediately at the beginning of the file. +.\" 2. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" Alternatively, this software may be distributed under the terms of the +.\" the GNU Public License ("GPL"). +.\" +.\" 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. +.\" +.\" Matthew Jacob +.\" Feral Software +.\" mjacob@feral.com +.Dd February 21, 2000 +.Dt SESD 8 +.Os +.Sh NAME +.Nm sesd +.Nd monitor SCSI Environmental Services Devices +.Sh SYNOPSIS +.Nm +.Op Fl d +.Op Fl t Ar poll-interval +.Ar device +.Op Ar device ... +.Sh DESCRIPTION +.Nm +monitors SCSI Environmental Services (or SAF-TE) devices for changes +in state and logs such changes changes to the system error logger +(see +.Xr syslogd 8 ) . +At least one device must be specified. +When no other options are supplied, +.Nm +detached becomes a daemon, by default waking up every 30 seconds to +poll each device for a change in state. +.Pp +The following options may be used: +.Bl -tag -width Ds +.It Fl p Ar poll-interval +Change the interval of polling from the default 30 seconds to the number +of seconds specified. +.It Fl d +Instead of detaching and becoming a daemon, stay attached to the +controlling terminal and log changes there as well as via the system +logger. +.El +.Pp +The user may then use +.Xr getencstat 8 +to get more detailed information about the state of the over enclosure device +or objects within the enclosure device. +.Sh FILES +.Bl -tag -width /dev/sesN -compact +.It Pa /dev/ses\fIN\fR +SCSI Environmental Services Devices +.El +.Sh SEE ALSO +.Xr ses 4 , +.Xr syslogd 8 , +.Xr getencstat 8 , +.Xr setencstat 8 , +.Xr setobjstat 8 +.Sh BUGS +This is something of a toy, but it is better than nothing. diff --git a/usr.sbin/sesd/setencstat/Makefile b/usr.sbin/sesd/setencstat/Makefile new file mode 100644 index 00000000000..77f7c1ccb36 --- /dev/null +++ b/usr.sbin/sesd/setencstat/Makefile @@ -0,0 +1,40 @@ +# $NetBSD: $ +# $FreeBSD: src/share/examples/ses/Makefile,v 1.1 2000/01/15 22:47:15 mjacob Exp $ +# +# Copyright (c) 2000 by Matthew Jacob +# 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, +# without modification, immediately at the beginning of the file. +# 2. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# Alternatively, this software may be distributed under the terms of the +# the GNU Public License ("GPL"). +# +# 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. +# +# Matthew Jacob +# Feral Software +# mjacob@feral.com +# + +MAN = setencstat.8 +SRCS = setencstat.c eltsub.c +PROG = setencstat + +.include <bsd.prog.mk> diff --git a/usr.sbin/sesd/setencstat/setencstat.8 b/usr.sbin/sesd/setencstat/setencstat.8 new file mode 100644 index 00000000000..94536ced4d2 --- /dev/null +++ b/usr.sbin/sesd/setencstat/setencstat.8 @@ -0,0 +1,74 @@ +.\" $NetBSD: $ +.\" $OpenBSD: setencstat.8,v 1.1 2000/02/21 08:45:15 mjacob Exp $ +.\" $FreeBSD: $ +.\" +.\" Copyright (c) 2000 Matthew Jacob +.\" 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, +.\" without modification, immediately at the beginning of the file. +.\" 2. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" Alternatively, this software may be distributed under the terms of the +.\" the GNU Public License ("GPL"). +.\" +.\" 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. +.\" +.\" Matthew Jacob +.\" Feral Software +.\" mjacob@feral.com +.Dd February 21, 2000 +.Dt SETENCSTAT 8 +.Os +.Sh NAME +.Nm setencstat +.Nd set SCSI Environmental Services Device enclosure status +.Sh SYNOPSIS +.Nm +.Ar device enclosure_status +.Sh DESCRIPTION +.Nm +sets summary status for a SCSI Environmental Services (or SAF-TE) device. +The enclosure status argument may take on the values: +.Bl -tag -width Ds +.It 0 +Set the status to an \fBOK\fR state. +.It 1 +Set the status to an \fBUNRECOVERABLE\fR state. +.It 2 +Set the status to an \fBCRITICAL\fR state. +.It 4 +Set the status to an \fBNON-CRITICAL\fR state. +.It 8 +Set the status to an \fBINFORMATIONAL\fR state. +.El +.Pp +All the non-zero options may be combined. +.Pp +Note that devices may simply and silently ignore the setting of these values. +.Sh FILES +.Bl -tag -width /dev/sesN -compact +.It Pa /dev/ses\fIN\fR +SCSI Environmental Services Devices +.El +.Sh SEE ALSO +.Xr ses 4 , +.Xr sesd 8 , +.Xr getencstat 8 , +.Xr setobjstat 8 +.Sh BUGS diff --git a/usr.sbin/sesd/setobjstat/Makefile b/usr.sbin/sesd/setobjstat/Makefile new file mode 100644 index 00000000000..d804d1b1a87 --- /dev/null +++ b/usr.sbin/sesd/setobjstat/Makefile @@ -0,0 +1,40 @@ +# $NetBSD: $ +# $FreeBSD: src/share/examples/ses/Makefile,v 1.1 2000/01/15 22:47:15 mjacob Exp $ +# +# Copyright (c) 2000 by Matthew Jacob +# 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, +# without modification, immediately at the beginning of the file. +# 2. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# Alternatively, this software may be distributed under the terms of the +# the GNU Public License ("GPL"). +# +# 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. +# +# Matthew Jacob +# Feral Software +# mjacob@feral.com +# + +MAN = setobjstat.8 +SRCS = setobjstat.c eltsub.c +PROG = setobjstat + +.include <bsd.prog.mk> diff --git a/usr.sbin/sesd/setobjstat/setobjstat.8 b/usr.sbin/sesd/setobjstat/setobjstat.8 new file mode 100644 index 00000000000..00397113f47 --- /dev/null +++ b/usr.sbin/sesd/setobjstat/setobjstat.8 @@ -0,0 +1,69 @@ +.\" $NetBSD: $ +.\" $OpenBSD: setobjstat.8,v 1.1 2000/02/21 08:45:15 mjacob Exp $ +.\" $FreeBSD: $ +.\" +.\" Copyright (c) 2000 Matthew Jacob +.\" 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, +.\" without modification, immediately at the beginning of the file. +.\" 2. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission. +.\" +.\" Alternatively, this software may be distributed under the terms of the +.\" the GNU Public License ("GPL"). +.\" +.\" 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. +.\" +.\" Matthew Jacob +.\" Feral Software +.\" mjacob@feral.com +.Dd February 21, 2000 +.Dt SETOBJSTAT 8 +.Os +.Sh NAME +.Nm setobjstat +.Nd set SCSI Environmental Services Device object status +.Sh SYNOPSIS +.Nm +.Ar device objectid stat0 stat1 stat2 stat3 +.Sh DESCRIPTION +.Nm +sets the object status for a SCSI Environmental Services (or SAF-TE) device. +The +.Ar objectid +argument may be determined by running +.Xr getencstat 8 . +.Pp +The status fields are partially common (first byte only, which must +have a value of 0x80 contained in it), but otherwise quite device +specific. A complete discussion of the possible values is impractical +here. Please refer to the ANSI SCSI specification (available on +the FTP site ftp.t10.org). +.Pp +Note that devices may simply and silently ignore the setting of these values. +.Sh FILES +.Bl -tag -width /dev/sesN -compact +.It Pa /dev/ses\fIN\fR +SCSI Environmental Services Devices +.El +.Sh SEE ALSO +.Xr ses 4 , +.Xr sesd 8 , +.Xr getencstat 8 , +.Xr setencstat 8 +.Sh BUGS diff --git a/usr.sbin/sesd/srcs/chpmon.c b/usr.sbin/sesd/srcs/chpmon.c new file mode 100644 index 00000000000..52483c44f6a --- /dev/null +++ b/usr.sbin/sesd/srcs/chpmon.c @@ -0,0 +1,129 @@ +/* $NetBSD: $ */ +/* $FreeBSD: src/share/examples/ses/chpmon.c,v 1.1 2000/01/15 22:47:16 mjacob Exp $ */ +/* + * Copyright (c) 2000 by Matthew Jacob + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * the GNU Public License ("GPL"). + * + * 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. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/ioctl.h> +#include "ses.h" + +/* + * Continuously monitor all named SES devices + * and turn all but INFO enclosure status + * values into CRITICAL enclosure status. + */ +#define BADSTAT \ + (SES_ENCSTAT_UNRECOV|SES_ENCSTAT_CRITICAL|SES_ENCSTAT_NONCRITICAL) +int +main(a, v) + int a; + char **v; +{ + int fd, delay, dev; + ses_encstat stat, *carray; + + if (a < 3) { + fprintf(stderr, "usage: %s polling-interval device " + "[ device ... ]\n", *v); + return (1); + } + delay = atoi(v[1]); + carray = malloc(a); + if (carray == NULL) { + perror("malloc"); + return (1); + } + bzero((void *)carray, a); + + for (;;) { + for (dev = 2; dev < a; dev++) { + fd = open(v[dev], O_RDWR); + if (fd < 0) { + perror(v[dev]); + continue; + } + /* + * First clear any enclosure status, in case it is + * a latched status. + */ + stat = 0; + if (ioctl(fd, SESIOC_SETENCSTAT, (caddr_t) &stat) < 0) { + fprintf(stderr, "%s: SESIOC_SETENCSTAT1: %s\n", + v[dev], strerror(errno)); + (void) close(fd); + continue; + } + /* + * Now get the actual current enclosure status. + */ + if (ioctl(fd, SESIOC_GETENCSTAT, (caddr_t) &stat) < 0) { + fprintf(stderr, "%s: SESIOC_GETENCSTAT: %s\n", + v[dev], strerror(errno)); + (void) close(fd); + continue; + } + + if ((stat & BADSTAT) == 0) { + if (carray[dev]) { + fprintf(stdout, "%s: Clearing CRITICAL " + "condition\n", v[dev]); + carray[dev] = 0; + } + (void) close(fd); + continue; + } + carray[dev] = 1; + fprintf(stdout, "%s: Setting CRITICAL from:", v[dev]); + if (stat & SES_ENCSTAT_UNRECOV) + fprintf(stdout, " UNRECOVERABLE"); + + if (stat & SES_ENCSTAT_CRITICAL) + fprintf(stdout, " CRITICAL"); + + if (stat & SES_ENCSTAT_NONCRITICAL) + fprintf(stdout, " NONCRITICAL"); + putchar('\n'); + stat = SES_ENCSTAT_CRITICAL; + if (ioctl(fd, SESIOC_SETENCSTAT, (caddr_t) &stat) < 0) { + fprintf(stderr, "%s: SESIOC_SETENCSTAT 2: %s\n", + v[dev], strerror(errno)); + } + (void) close(fd); + } + sleep(delay); + } + /* NOTREACHED */ +} diff --git a/usr.sbin/sesd/srcs/eltsub.c b/usr.sbin/sesd/srcs/eltsub.c new file mode 100644 index 00000000000..3a0ff3aaf67 --- /dev/null +++ b/usr.sbin/sesd/srcs/eltsub.c @@ -0,0 +1,169 @@ +/* $NetBSD: $ */ +/* $FreeBSD: $ */ +/* $OpenBSD: eltsub.c,v 1.1 2000/02/21 08:45:15 mjacob Exp $ */ +/* + * Copyright (c) 2000 by Matthew Jacob + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * the GNU Public License ("GPL"). + * + * 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. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/ioctl.h> +#include SESINC + +char * +geteltnm(type) + int type; +{ + static char rbuf[132]; + + switch (type) { + case SESTYP_UNSPECIFIED: + sprintf(rbuf, "Unspecified"); + break; + case SESTYP_DEVICE: + sprintf(rbuf, "Device"); + break; + case SESTYP_POWER: + sprintf(rbuf, "Power supply"); + break; + case SESTYP_FAN: + sprintf(rbuf, "Cooling element"); + break; + case SESTYP_THERM: + sprintf(rbuf, "Temperature sensors"); + break; + case SESTYP_DOORLOCK: + sprintf(rbuf, "Door Lock"); + break; + case SESTYP_ALARM: + sprintf(rbuf, "Audible alarm"); + break; + case SESTYP_ESCC: + sprintf(rbuf, "Enclosure services controller electronics"); + break; + case SESTYP_SCC: + sprintf(rbuf, "SCC controller electronics"); + break; + case SESTYP_NVRAM: + sprintf(rbuf, "Nonvolatile cache"); + break; + case SESTYP_UPS: + sprintf(rbuf, "Uninterruptible power supply"); + break; + case SESTYP_DISPLAY: + sprintf(rbuf, "Display"); + break; + case SESTYP_KEYPAD: + sprintf(rbuf, "Key pad entry device"); + break; + case SESTYP_SCSIXVR: + sprintf(rbuf, "SCSI port/transceiver"); + break; + case SESTYP_LANGUAGE: + sprintf(rbuf, "Language"); + break; + case SESTYP_COMPORT: + sprintf(rbuf, "Communication Port"); + break; + case SESTYP_VOM: + sprintf(rbuf, "Voltage Sensor"); + break; + case SESTYP_AMMETER: + sprintf(rbuf, "Current Sensor"); + break; + case SESTYP_SCSI_TGT: + sprintf(rbuf, "SCSI target port"); + break; + case SESTYP_SCSI_INI: + sprintf(rbuf, "SCSI initiator port"); + break; + case SESTYP_SUBENC: + sprintf(rbuf, "Simple sub-enclosure"); + break; + default: + (void) sprintf(rbuf, "<Type 0x%x>", type); + break; + } + return (rbuf); +} + +static char * +scode2ascii(code) + u_char code; +{ + static char rbuf[32]; + switch (code & 0xf) { + case SES_OBJSTAT_UNSUPPORTED: + sprintf(rbuf, "status not supported"); + break; + case SES_OBJSTAT_OK: + sprintf(rbuf, "ok"); + break; + case SES_OBJSTAT_CRIT: + sprintf(rbuf, "critical"); + break; + case SES_OBJSTAT_NONCRIT: + sprintf(rbuf, "non-critical"); + break; + case SES_OBJSTAT_UNRECOV: + sprintf(rbuf, "unrecoverable"); + break; + case SES_OBJSTAT_NOTINSTALLED: + sprintf(rbuf, "not installed"); + break; + case SES_OBJSTAT_UNKNOWN: + sprintf(rbuf, "unknown status"); + break; + case SES_OBJSTAT_NOTAVAIL: + sprintf(rbuf, "status not available"); + break; + default: + sprintf(rbuf, "unknown status code %x", code & 0xf); + break; + } + return (rbuf); +} + + +char * +stat2ascii(eletype, cstat) + int eletype; + u_char *cstat; +{ + static char ebuf[256], *scode; + + scode = scode2ascii(cstat[0]); + sprintf(ebuf, "Status=%s (bytes=0x%02x 0x%02x 0x%02x 0x%02x)", + scode, cstat[0], cstat[1], cstat[2], cstat[3]); + return (ebuf); +} diff --git a/usr.sbin/sesd/srcs/getencstat.c b/usr.sbin/sesd/srcs/getencstat.c new file mode 100644 index 00000000000..a5e3f7a923b --- /dev/null +++ b/usr.sbin/sesd/srcs/getencstat.c @@ -0,0 +1,157 @@ +/* $NetBSD: $ */ +/* $FreeBSD: $ */ +/* $OpenBSD: getencstat.c,v 1.1 2000/02/21 08:45:15 mjacob Exp $ */ +/* + * Copyright (c) 2000 by Matthew Jacob + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * the GNU Public License ("GPL"). + * + * 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. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/ioctl.h> +#include <fcntl.h> +#include SESINC + +extern char *geteltnm __P((int)); +extern char *stat2ascii __P((int, u_char *)); + +int +main(a, v) + int a; + char **v; +{ + ses_object *objp; + ses_objstat ob; + int fd, nobj, f, i, verbose, quiet, errors; + u_char estat; + + if (a < 2) { + fprintf(stderr, "usage: %s [ -v ] device [ device ... ]\n", *v); + return (1); + } + errors = quiet = verbose = 0; + if (strcmp(v[1], "-V") == 0) { + verbose = 2; + v++; + } else if (strcmp(v[1], "-v") == 0) { + verbose = 1; + v++; + } else if (strcmp(v[1], "-q") == 0) { + quiet = 1; + verbose = 0; + v++; + } + while (*++v) { + + fd = open(*v, O_RDONLY); + if (fd < 0) { + perror(*v); + continue; + } + if (ioctl(fd, SESIOC_GETNOBJ, (caddr_t) &nobj) < 0) { + perror("SESIOC_GETNOBJ"); + (void) close(fd); + continue; + } + if (ioctl(fd, SESIOC_GETENCSTAT, (caddr_t) &estat) < 0) { + perror("SESIOC_GETENCSTAT"); + (void) close(fd); + continue; + } + if ((verbose == 0 || quiet == 1) && estat == 0) { + if (quiet == 0) + fprintf(stdout, "%s: Enclosure OK\n", *v); + (void) close(fd); + continue; + } + fprintf(stdout, "%s: Enclosure Status ", *v); + if (estat == 0) { + fprintf(stdout, "<OK"); + } else { + errors++; + f = '<'; + if (estat & SES_ENCSTAT_INFO) { + fprintf(stdout, "%cINFO", f); + f = ','; + } + if (estat & SES_ENCSTAT_NONCRITICAL) { + fprintf(stdout, "%cNONCRITICAL", f); + f = ','; + } + if (estat & SES_ENCSTAT_CRITICAL) { + fprintf(stdout, "%cCRITICAL", f); + f = ','; + } + if (estat & SES_ENCSTAT_UNRECOV) { + fprintf(stdout, "%cUNRECOV", f); + f = ','; + } + } + fprintf(stdout, ">\n"); + objp = calloc(nobj, sizeof (ses_object)); + if (objp == NULL) { + perror("calloc"); + (void) close(fd); + continue; + } + if (ioctl(fd, SESIOC_GETOBJMAP, (caddr_t) objp) < 0) { + perror("SESIOC_GETOBJMAP"); + (void) close(fd); + continue; + } + for (i = 0; i < nobj; i++) { + ob.obj_id = objp[i].obj_id; + if (ioctl(fd, SESIOC_GETOBJSTAT, (caddr_t) &ob) < 0) { + perror("SESIOC_GETOBJSTAT"); + (void) close(fd); + break; + } + if ((ob.cstat[0] & 0xf) == SES_OBJSTAT_OK) { + if (verbose) { + fprintf(stdout, + "Element 0x%x: %s OK (%s)\n", + ob.obj_id, + geteltnm(objp[i].object_type), + stat2ascii(objp[i].object_type, + ob.cstat)); + } + continue; + } + fprintf(stdout, "Element 0x%x: %s, %s\n", + ob.obj_id, geteltnm(objp[i].object_type), + stat2ascii(objp[i].object_type, ob.cstat)); + } + free(objp); + (void) close(fd); + } + return (errors); +} diff --git a/usr.sbin/sesd/srcs/getnobj.c b/usr.sbin/sesd/srcs/getnobj.c new file mode 100644 index 00000000000..164fc0f9e6e --- /dev/null +++ b/usr.sbin/sesd/srcs/getnobj.c @@ -0,0 +1,68 @@ +/* $NetBSD: $ */ +/* $FreeBSD: $ */ +/* $OpenBSD: getnobj.c,v 1.1 2000/02/21 08:45:15 mjacob Exp $ */ +/* + * Copyright (c) 2000 by Matthew Jacob + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * the GNU Public License ("GPL"). + * + * 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. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include SESINC + +int +main(argc, argv) + int argc; + char **argv; +{ + unsigned int nobj; + int fd; + + while (*++argv != NULL) { + char *name = *argv; + fd = open(name, O_RDONLY); + if (fd < 0) { + perror(name); + continue; + } + if (ioctl(fd, SESIOC_GETNOBJ, (caddr_t) &nobj) < 0) { + perror("SESIOC_GETNOBJ"); + } else { + fprintf(stdout, "%s: %d objects\n", name, nobj); + } + close (fd); + } + return (0); +} diff --git a/usr.sbin/sesd/srcs/getobjmap.c b/usr.sbin/sesd/srcs/getobjmap.c new file mode 100644 index 00000000000..8f54ad6906a --- /dev/null +++ b/usr.sbin/sesd/srcs/getobjmap.c @@ -0,0 +1,89 @@ +/* $NetBSD: $ */ +/* $FreeBSD: $ */ +/* $OpenBSD: getobjmap.c,v 1.1 2000/02/21 08:45:15 mjacob Exp $ */ +/* + * Copyright (c) 2000 by Matthew Jacob + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * the GNU Public License ("GPL"). + * + * 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. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include SESINC + +extern char *geteltnm __P((int)); + +int +main(a, v) + int a; + char **v; +{ + ses_object *objp; + int nobj, fd, i; + + while (*++v) { + fd = open(*v, O_RDONLY); + if (fd < 0) { + perror(*v); + continue; + } + if (ioctl(fd, SESIOC_GETNOBJ, (caddr_t) &nobj) < 0) { + perror("SESIOC_GETNOBJ"); + (void) close(fd); + continue; + } + fprintf(stdout, "%s: %d objects\n", *v, nobj); + if (nobj == 0) { + (void) close(fd); + continue; + } + objp = calloc(nobj, sizeof (ses_object)); + if (objp == NULL) { + perror("calloc"); + (void) close(fd); + continue; + } + if (ioctl(fd, SESIOC_GETOBJMAP, (caddr_t) objp) < 0) { + perror("SESIOC_GETOBJMAP"); + (void) close(fd); + continue; + } + for (i = 0; i < nobj; i++) { + printf(" Object %d: ID 0x%x Type '%s'\n", i, + objp[i].obj_id, geteltnm((int)objp[i].object_type)); + } + free(objp); + (void) close(fd); + } + return (0); +} diff --git a/usr.sbin/sesd/srcs/getobjstat.c b/usr.sbin/sesd/srcs/getobjstat.c new file mode 100644 index 00000000000..e3c77009077 --- /dev/null +++ b/usr.sbin/sesd/srcs/getobjstat.c @@ -0,0 +1,78 @@ +/* $NetBSD: $ */ +/* $FreeBSD: $ */ +/* $OpenBSD: getobjstat.c,v 1.1 2000/02/21 08:45:15 mjacob Exp $ */ +/* + * Copyright (c) 2000 by Matthew Jacob + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * the GNU Public License ("GPL"). + * + * 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. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include SESINC + +int +main(a, v) + int a; + char **v; +{ + int fd; + int i; + ses_objstat obj; + long cvt; + char *x; + + if (a != 3) { +usage: + fprintf(stderr, "usage: %s device objectid\n", *v); + return (1); + } + fd = open(v[1], O_RDONLY); + if (fd < 0) { + perror(v[1]); + return (1); + } + x = v[2]; + cvt = strtol(v[2], &x, 0); + if (x == v[2]) { + goto usage; + } + obj.obj_id = cvt; + if (ioctl(fd, SESIOC_GETOBJSTAT, (caddr_t) &obj) < 0) { + perror("SESIOC_GETOBJSTAT"); + return (1); + } + fprintf(stdout, "Object 0x%x: 0x%x 0x%x 0x%x 0x%x\n", obj.obj_id, + obj.cstat[0], obj.cstat[1], obj.cstat[2], obj.cstat[3]); + (void) close(fd); + return (0); +} diff --git a/usr.sbin/sesd/srcs/inienc.c b/usr.sbin/sesd/srcs/inienc.c new file mode 100644 index 00000000000..5a30fa5fdfb --- /dev/null +++ b/usr.sbin/sesd/srcs/inienc.c @@ -0,0 +1,63 @@ +/* $NetBSD: $ */ +/* $FreeBSD: $ */ +/* $OpenBSD: inienc.c,v 1.1 2000/02/21 08:45:15 mjacob Exp $ */ +/* + * Copyright (c) 2000 by Matthew Jacob + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * the GNU Public License ("GPL"). + * + * 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. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include SESINC + +int +main(a, v) + int a; + char **v; +{ + int fd; + + while (*++v) { + fd = open(*v, O_RDWR); + if (fd < 0) { + perror(*v); + continue; + } + if (ioctl(fd, SESIOC_INIT, NULL) < 0) { + perror("SESIOC_GETNOBJ"); + } + (void) close(fd); + } + return (0); +} diff --git a/usr.sbin/sesd/srcs/sesd.c b/usr.sbin/sesd/srcs/sesd.c new file mode 100644 index 00000000000..148ae7f9ae5 --- /dev/null +++ b/usr.sbin/sesd/srcs/sesd.c @@ -0,0 +1,167 @@ +/* $NetBSD: $ */ +/* $FreeBSD: $ */ +/* $OpenBSD: sesd.c,v 1.1 2000/02/21 08:45:15 mjacob Exp $ */ +/* + * Copyright (c) 2000 by Matthew Jacob + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * the GNU Public License ("GPL"). + * + * 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. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <errno.h> +#include <string.h> +#include <syslog.h> +#include <sys/ioctl.h> +#include SESINC + +#define ALLSTAT (SES_ENCSTAT_UNRECOV | SES_ENCSTAT_CRITICAL | \ + SES_ENCSTAT_NONCRITICAL | SES_ENCSTAT_INFO) + +/* + * Monitor named SES devices and note (via syslog) any changes in status. + */ + +int +main(a, v) + int a; + char **v; +{ + static char *usage = + "usage: %s [ -d ] [ -t pollinterval ] device [ device ]\n"; + int fd, polltime, dev, devbase, nodaemon, bpri; + ses_encstat stat, *carray; + + if (a < 2) { + fprintf(stderr, usage, *v); + return (1); + } + + devbase = 1; + + if (strcmp(v[1], "-d") == 0) { + nodaemon = 1; + devbase++; + } else { + nodaemon = 0; + } + + if (a > 2 && strcmp(v[2], "-t") == 0) { + devbase += 2; + polltime = atoi(v[3]); + } else { + polltime = 30; + } + + carray = malloc(a); + if (carray == NULL) { + perror("malloc"); + return (1); + } + for (dev = devbase; dev < a; dev++) + carray[dev] = (ses_encstat) -1; + + /* + * Check to make sure we can open all devices + */ + for (dev = devbase; dev < a; dev++) { + fd = open(v[dev], O_RDWR); + if (fd < 0) { + perror(v[dev]); + return (1); + } + if (ioctl(fd, SESIOC_INIT, NULL) < 0) { + fprintf(stderr, "%s: SESIOC_INIT fails- %s\n", + v[dev], strerror(errno)); + return (1); + } + (void) close(fd); + } + if (nodaemon == 0) { + if (daemon(0, 0) < 0) { + perror("daemon"); + return (1); + } + openlog("sesd", LOG_CONS, LOG_USER); + } else { + openlog("sesd", LOG_CONS|LOG_PERROR, LOG_USER); + } + + for (;;) { + for (dev = devbase; dev < a; dev++) { + char buf[128]; + fd = open(v[dev], O_RDWR); + if (fd < 0) { + syslog(LOG_ERR, "%s: %m", v[dev]); + continue; + } + + /* + * Get the actual current enclosure status. + */ + if (ioctl(fd, SESIOC_GETENCSTAT, (caddr_t) &stat) < 0) { + syslog(LOG_ERR, + "%s: SESIOC_GETENCSTAT- %m", v[dev]); + (void) close(fd); + continue; + } + (void) close(fd); + + if (stat == carray[dev]) + continue; + + carray[dev] = stat; + if ((stat & ALLSTAT) == 0) { + syslog(LOG_NOTICE, + "%s: Enclosure Status OK", v[dev]); + } + if (stat & SES_ENCSTAT_INFO) { + syslog(LOG_INFO, + "%s: Enclosure Status Has Information", + v[dev]); + } + if (stat & SES_ENCSTAT_NONCRITICAL) { + syslog(LOG_WARNING, + "%s: Enclosure Non-Critical", v[dev]); + } + if (stat & SES_ENCSTAT_CRITICAL) { + syslog(LOG_CRIT, + "%s: Enclosure Critical", v[dev]); + } + if (stat & SES_ENCSTAT_UNRECOV) { + syslog(LOG_ALERT, + "%s: Enclosure Unrecoverable", v[dev]); + } + } + sleep(polltime); + } + /* NOTREACHED */ +} diff --git a/usr.sbin/sesd/srcs/setencstat.c b/usr.sbin/sesd/srcs/setencstat.c new file mode 100644 index 00000000000..e00b181777d --- /dev/null +++ b/usr.sbin/sesd/srcs/setencstat.c @@ -0,0 +1,70 @@ +/* $NetBSD: $ */ +/* $FreeBSD: $ */ +/* $OpenBSD: setencstat.c,v 1.1 2000/02/21 08:45:15 mjacob Exp $ */ +/* + * Copyright (c) 2000 by Matthew Jacob + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * the GNU Public License ("GPL"). + * + * 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. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include SESINC + +int +main(a, v) + int a; + char **v; +{ + int fd; + long val; + ses_encstat stat; + + if (a != 3) { + fprintf(stderr, "usage: %s device enclosure_status\n", *v); + return (1); + } + fd = open(v[1], O_RDWR); + if (fd < 0) { + perror(v[1]); + return (1); + } + + val = strtol(v[2], NULL, 0); + stat = (ses_encstat) val; + if (ioctl(fd, SESIOC_SETENCSTAT, (caddr_t) &stat) < 0) { + perror("SESIOC_SETENCSTAT"); + } + (void) close(fd); + return (0); +} diff --git a/usr.sbin/sesd/srcs/setobjstat.c b/usr.sbin/sesd/srcs/setobjstat.c new file mode 100644 index 00000000000..69a5e7c7ee4 --- /dev/null +++ b/usr.sbin/sesd/srcs/setobjstat.c @@ -0,0 +1,85 @@ +/* $NetBSD: $ */ +/* $FreeBSD: $ */ +/* $OpenBSD: setobjstat.c,v 1.1 2000/02/21 08:45:15 mjacob Exp $ */ +/* + * Copyright (c) 2000 by Matthew Jacob + * 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, + * without modification, immediately at the beginning of the file. + * 2. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, this software may be distributed under the terms of the + * the GNU Public License ("GPL"). + * + * 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. + * + * Matthew Jacob + * Feral Software + * mjacob@feral.com + */ + +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include SESINC + +int +main(a, v) + int a; + char **v; +{ + int fd; + int i; + ses_objstat obj; + long cvt; + char *x; + + if (a != 7) { +usage: + fprintf(stderr, + "usage: %s device objectid stat0 stat1 stat2 stat3\n", *v); + return (1); + } + fd = open(v[1], O_RDWR); + if (fd < 0) { + perror(v[1]); + return (1); + } + x = v[2]; + cvt = strtol(v[2], &x, 0); + if (x == v[2]) { + goto usage; + } + obj.obj_id = cvt; + for (i = 0; i < 4; i++) { + x = v[3 + i]; + cvt = strtol(v[3 + i], &x, 0); + if (x == v[3 + i]) { + goto usage; + } + obj.cstat[i] = cvt; + } + if (ioctl(fd, SESIOC_SETOBJSTAT, (caddr_t) &obj) < 0) { + perror("SESIOC_SETOBJSTAT"); + } + (void) close(fd); + return (0); +} |