Update SES userland examples to something out of the toy stage.

Approved: jkh
This commit is contained in:
Matt Jacob 2000-02-29 05:44:19 +00:00
parent 047e0b4e52
commit daf1cffce2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=57580
20 changed files with 730 additions and 76 deletions

View File

@ -1,3 +1,5 @@
# $NetBSD: $
# $OpenBSD: $
# $FreeBSD$
#
# Copyright (c) 2000 by Matthew Jacob
@ -32,30 +34,8 @@
# mjacob@feral.com
#
CFLAGS = -O
UNUSED = getobjmap getnobj getobjstat
SUBDIR = getencstat setencstat setobjstat sesd
SUB = eltsub.o
ALL = getnobj getobjmap getencstat inienc setencstat \
setobjstat getobjstat chpmon
all: ${ALL} ${SUB}
getnobj: getnobj.o ${SUB}
$(CC) -o $@ $@.o ${SUB}
getobjmap: getobjmap.o ${SUB}
$(CC) -o $@ $@.o ${SUB}
getencstat: getencstat.o ${SUB}
$(CC) -o $@ $@.o ${SUB}
inienc: inienc.o ${SUB}
$(CC) -o $@ $@.o ${SUB}
chpmon: chpmon.o ${SUB}
$(CC) -o $@ $@.o ${SUB}
clean:
-rm -f *.o ${ALL}
.include <bsd.own.mk>
.include <bsd.subdir.mk>

View File

@ -0,0 +1,48 @@
# $NetBSD: $
# $OpenBSD: $
# $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
BINDIR ?= ${DESTDIR}/usr/sbin
.PATH: ../srcs

View File

@ -0,0 +1,39 @@
# $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
#
MAN8 = getencstat.0
SRCS = getencstat.c eltsub.c
PROG = getencstat
.include <bsd.prog.mk>

View File

@ -0,0 +1,78 @@
.\" $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

View File

@ -0,0 +1,39 @@
# $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
#
MAN8 = sesd.0
SRCS = sesd.c eltsub.c
PROG = sesd
.include <bsd.prog.mk>

View File

@ -0,0 +1,84 @@
.\" $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.

View File

@ -0,0 +1,39 @@
# $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
#
MAN8 = setencstat.0
SRCS = setencstat.c eltsub.c
PROG = setencstat
.include <bsd.prog.mk>

View File

@ -0,0 +1,72 @@
.\" $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

View File

@ -0,0 +1,39 @@
# $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
#
MAN8 = setobjstat.0
SRCS = setobjstat.c eltsub.c
PROG = setobjstat
.include <bsd.prog.mk>

View File

@ -0,0 +1,67 @@
.\" $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

View File

@ -37,7 +37,7 @@
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <cam/scsi/scsi_ses.h>
#include "ses.h"
/*
* Continuously monitor all named SES devices
@ -47,7 +47,9 @@
#define BADSTAT \
(SES_ENCSTAT_UNRECOV|SES_ENCSTAT_CRITICAL|SES_ENCSTAT_NONCRITICAL)
int
main(int a, char **v)
main(a, v)
int a;
char **v;
{
int fd, delay, dev;
ses_encstat stat, *carray;
@ -63,7 +65,7 @@ main(int a, char **v)
perror("malloc");
return (1);
}
memset(carray, 0, a);
bzero((void *)carray, a);
for (;;) {
for (dev = 2; dev < a; dev++) {

View File

@ -36,10 +36,11 @@
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <cam/scsi/scsi_ses.h>
#include SESINC
char *
geteltnm(int type)
geteltnm(type)
int type;
{
static char rbuf[132];
@ -115,7 +116,8 @@ geteltnm(int type)
}
static char *
scode2ascii(u_char code)
scode2ascii(code)
u_char code;
{
static char rbuf[32];
switch (code & 0xf) {
@ -152,7 +154,9 @@ scode2ascii(u_char code)
char *
stat2ascii(int eletype, u_char *cstat)
stat2ascii(eletype, cstat)
int eletype;
u_char *cstat;
{
static char ebuf[256], *scode;

View File

@ -37,13 +37,15 @@
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <cam/scsi/scsi_ses.h>
#include SESINC
extern char *geteltnm(int);
extern char *stat2ascii(int, u_char *);
extern char *geteltnm __P((int));
extern char *stat2ascii __P((int, u_char *));
int
main(int a, char **v)
main(a, v)
int a;
char **v;
{
ses_object *objp;
ses_objstat ob;
@ -134,16 +136,16 @@ main(int a, char **v)
if ((ob.cstat[0] & 0xf) == SES_OBJSTAT_OK) {
if (verbose) {
fprintf(stdout,
"%s Element(%x): OK (%s)\n",
geteltnm(objp[i].object_type),
"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, "%s Element(%x): %s\n",
geteltnm(objp[i].object_type), ob.obj_id,
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);

View File

@ -38,10 +38,12 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <cam/scsi/scsi_ses.h>
#include SESINC
int
main(int argc, char **argv)
main(argc, argv)
int argc;
char **argv;
{
unsigned int nobj;
int fd;

View File

@ -37,12 +37,14 @@
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <cam/scsi/scsi_ses.h>
#include SESINC
extern char *geteltnm(int);
extern char *geteltnm __P((int));
int
main(int a, char **v)
main(a, v)
int a;
char **v;
{
ses_object *objp;
int nobj, fd, i;

View File

@ -36,10 +36,12 @@
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <cam/scsi/scsi_ses.h>
#include SESINC
int
main(int a, char **v)
main(a, v)
int a;
char **v;
{
int fd;
int i;

View File

@ -37,10 +37,12 @@
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <cam/scsi/scsi_ses.h>
#include SESINC
int
main(int a, char **v)
main(a, v)
int a;
char **v;
{
int fd;

View File

@ -0,0 +1,165 @@
/* $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
*/
#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 */
}

View File

@ -37,16 +37,19 @@
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <cam/scsi/scsi_ses.h>
#include SESINC
int
main(int a, char **v)
main(a, v)
int a;
char **v;
{
int fd;
u_char stat;
long val;
ses_encstat stat;
if (a != 3) {
fprintf(stderr, "usage: %s device {enclosure_status|-p}\n", *v);
fprintf(stderr, "usage: %s device enclosure_status\n", *v);
return (1);
}
fd = open(v[1], O_RDWR);
@ -54,26 +57,9 @@ main(int a, char **v)
perror(v[1]);
return (1);
}
if (strcmp(v[2], "-p") == 0) {
/*
* First clear any enclosure status, in case it is
* a latched status.
*/
stat = 0;
if (ioctl(fd, SESIOC_SETENCSTAT, (caddr_t) &stat) < 0) {
perror("SESIOC_SETENCSTAT (pre)");
return (1);
}
/*
* Now get the actual current enclosure status.
*/
if (ioctl(fd, SESIOC_GETENCSTAT, (caddr_t) &stat) < 0) {
perror("SESIOC_GETENCSTAT");
return (1);
}
} else {
stat = atoi(v[2]);
}
val = strtol(v[2], NULL, 0);
stat = (ses_encstat) val;
if (ioctl(fd, SESIOC_SETENCSTAT, (caddr_t) &stat) < 0) {
perror("SESIOC_SETENCSTAT");
}

View File

@ -37,10 +37,12 @@
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <cam/scsi/scsi_ses.h>
#include SESINC
int
main(int a, char **v)
main(a, v)
int a;
char **v;
{
int fd;
int i;