volcheck.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1993 by Sun Microsystems, Inc.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Program to kick volume management so it can check to see
* if media has been inserted.
*
* Exit codes:
* -1 - error
* 0 - no media found
* 1 - media found
*
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <fcntl.h>
char *prog_name;
void usage();
#define MIN_INTVL 1
#define DEFAULT_INTVL 2
int poll_time; /* total number of seconds to poll the device */
int verbose;
int work(int, char **);
void
{
extern char *optarg;
extern int optind;
int c;
char *av[1];
int rval;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
/* process arguments */
switch (c) {
case 't':
"Maximum time allowed is %d seconds\n"),
MAX_TIME);
exit(-1);
}
break;
case 'i':
if (poll_interval < MIN_INTVL) {
"Minimum interval is %d seconds\n"),
exit(-1);
}
break;
case 'v':
verbose = 1;
break;
default:
usage();
exit(-1);
}
}
/*
* If there's no argument, use the default
* device for checking.
*/
} else {
}
}
void
usage()
{
gettext("If path is not supplied all media is checked\n"));
}
/*
* Open the volume management control device and send the dev_t of
* the device the user has named.
*
* let the user specify "symbolic" device names. We don't do
* that yet.
*/
int
{
extern int volmgt_check(char *);
int i;
int rval;
if (poll_time > 0) {
/* this is the time'd case. */
while (poll_time > 0) {
for (i = 0; i < ac; i++) {
if (rval) {
"%s has media\n"), av[i]);
} else {
"%s has no media\n"),
av[i]);
}
}
if (rval) {
"media was found\n"));
} else {
"no media was found\n"));
}
}
}
}
rval = 0; /* doesn't really make sense in the timed case */
} else {
/* this is the one-shot case */
for (i = 0; i < ac; i++) {
if (rval) {
"%s has media\n"), av[i]);
} else {
"%s has no media\n"),
av[i]);
}
}
if (rval) {
"media was found\n"));
} else {
"no media was found\n"));
}
}
}
}
return (rval);
}