setencstat.c revision 1.1
11.1Smjacob/* $NetBSD: setencstat.c,v 1.1 2000/02/21 08:10:30 mjacob Exp $ */ 21.1Smjacob/* $FreeBSD: $ */ 31.1Smjacob/* $OpenBSD: $ */ 41.1Smjacob/* 51.1Smjacob * Copyright (c) 2000 by Matthew Jacob 61.1Smjacob * All rights reserved. 71.1Smjacob * 81.1Smjacob * Redistribution and use in source and binary forms, with or without 91.1Smjacob * modification, are permitted provided that the following conditions 101.1Smjacob * are met: 111.1Smjacob * 1. Redistributions of source code must retain the above copyright 121.1Smjacob * notice, this list of conditions, and the following disclaimer, 131.1Smjacob * without modification, immediately at the beginning of the file. 141.1Smjacob * 2. The name of the author may not be used to endorse or promote products 151.1Smjacob * derived from this software without specific prior written permission. 161.1Smjacob * 171.1Smjacob * Alternatively, this software may be distributed under the terms of the 181.1Smjacob * the GNU Public License ("GPL"). 191.1Smjacob * 201.1Smjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 211.1Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221.1Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231.1Smjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 241.1Smjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251.1Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261.1Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271.1Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281.1Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291.1Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301.1Smjacob * SUCH DAMAGE. 311.1Smjacob * 321.1Smjacob * Matthew Jacob 331.1Smjacob * Feral Software 341.1Smjacob * mjacob@feral.com 351.1Smjacob */ 361.1Smjacob 371.1Smjacob#include <unistd.h> 381.1Smjacob#include <stdlib.h> 391.1Smjacob#include <stdio.h> 401.1Smjacob#include <fcntl.h> 411.1Smjacob#include <sys/ioctl.h> 421.1Smjacob#include SESINC 431.1Smjacob 441.1Smjacobint 451.1Smjacobmain(a, v) 461.1Smjacob int a; 471.1Smjacob char **v; 481.1Smjacob{ 491.1Smjacob int fd; 501.1Smjacob long val; 511.1Smjacob ses_encstat stat; 521.1Smjacob 531.1Smjacob if (a != 3) { 541.1Smjacob fprintf(stderr, "usage: %s device enclosure_status\n", *v); 551.1Smjacob return (1); 561.1Smjacob } 571.1Smjacob fd = open(v[1], O_RDWR); 581.1Smjacob if (fd < 0) { 591.1Smjacob perror(v[1]); 601.1Smjacob return (1); 611.1Smjacob } 621.1Smjacob 631.1Smjacob val = strtol(v[2], NULL, 0); 641.1Smjacob stat = (ses_encstat) val; 651.1Smjacob if (ioctl(fd, SESIOC_SETENCSTAT, (caddr_t) &stat) < 0) { 661.1Smjacob perror("SESIOC_SETENCSTAT"); 671.1Smjacob } 681.1Smjacob (void) close(fd); 691.1Smjacob return (0); 701.1Smjacob} 71