1*421949a3Ssevan /* $NetBSD: setobjstat.c,v 1.3 2018/01/23 21:06:26 sevan Exp $ */
2f249807bSmjacob /* $FreeBSD: $ */
3f249807bSmjacob /* $OpenBSD: $ */
4f249807bSmjacob /*
5f249807bSmjacob * Copyright (c) 2000 by Matthew Jacob
6f249807bSmjacob * All rights reserved.
7f249807bSmjacob *
8f249807bSmjacob * Redistribution and use in source and binary forms, with or without
9f249807bSmjacob * modification, are permitted provided that the following conditions
10f249807bSmjacob * are met:
11f249807bSmjacob * 1. Redistributions of source code must retain the above copyright
12f249807bSmjacob * notice, this list of conditions, and the following disclaimer,
13f249807bSmjacob * without modification, immediately at the beginning of the file.
14f249807bSmjacob * 2. The name of the author may not be used to endorse or promote products
15f249807bSmjacob * derived from this software without specific prior written permission.
16f249807bSmjacob *
17f249807bSmjacob * Alternatively, this software may be distributed under the terms of the
18f249807bSmjacob * the GNU Public License ("GPL").
19f249807bSmjacob *
20f249807bSmjacob * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21f249807bSmjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22f249807bSmjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23f249807bSmjacob * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
24f249807bSmjacob * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25f249807bSmjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26f249807bSmjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27f249807bSmjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28f249807bSmjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29f249807bSmjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30f249807bSmjacob * SUCH DAMAGE.
31f249807bSmjacob *
32f249807bSmjacob * Matthew Jacob
33f249807bSmjacob * Feral Software
34f249807bSmjacob * mjacob@feral.com
35f249807bSmjacob */
36f249807bSmjacob
37f249807bSmjacob #include <unistd.h>
38f249807bSmjacob #include <stdlib.h>
39f249807bSmjacob #include <stdio.h>
40f249807bSmjacob #include <fcntl.h>
41f249807bSmjacob #include <sys/ioctl.h>
42f249807bSmjacob #include SESINC
43f249807bSmjacob
44f249807bSmjacob int
main(int a,char * v[])45*421949a3Ssevan main(int a, char *v[])
46f249807bSmjacob {
47f249807bSmjacob int fd;
48f249807bSmjacob int i;
49f249807bSmjacob ses_objstat obj;
50f249807bSmjacob long cvt;
51f249807bSmjacob char *x;
52f249807bSmjacob
53f249807bSmjacob if (a != 7) {
54f249807bSmjacob usage:
55f249807bSmjacob fprintf(stderr,
56f249807bSmjacob "usage: %s device objectid stat0 stat1 stat2 stat3\n", *v);
57f249807bSmjacob return (1);
58f249807bSmjacob }
59f249807bSmjacob fd = open(v[1], O_RDWR);
60f249807bSmjacob if (fd < 0) {
61f249807bSmjacob perror(v[1]);
62f249807bSmjacob return (1);
63f249807bSmjacob }
64f249807bSmjacob x = v[2];
65f249807bSmjacob cvt = strtol(v[2], &x, 0);
66f249807bSmjacob if (x == v[2]) {
67f249807bSmjacob goto usage;
68f249807bSmjacob }
69f249807bSmjacob obj.obj_id = cvt;
70f249807bSmjacob for (i = 0; i < 4; i++) {
71f249807bSmjacob x = v[3 + i];
72f249807bSmjacob cvt = strtol(v[3 + i], &x, 0);
73f249807bSmjacob if (x == v[3 + i]) {
74f249807bSmjacob goto usage;
75f249807bSmjacob }
76f249807bSmjacob obj.cstat[i] = cvt;
77f249807bSmjacob }
78f249807bSmjacob if (ioctl(fd, SESIOC_SETOBJSTAT, (caddr_t) &obj) < 0) {
79f249807bSmjacob perror("SESIOC_SETOBJSTAT");
80f249807bSmjacob }
81f249807bSmjacob (void) close(fd);
82f249807bSmjacob return (0);
83f249807bSmjacob }
84