getvol.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) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1997, by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdio.h>
#include <string.h>
#include <devmgmt.h>
#include "libadm.h"
#include <stdlib.h>
#define LABELSIZ 6
#define BELL "\007"
#define FORMFS_MSG ",\\n\\ \\ or [f] to format %s and place a filesystem on it"
#define FORMAT_MSG ",\\n\\ \\ or [f] to format the %s"
#define MAKEFS_MSG ",\\n\\ \\ or [m] to place a filesystem on %s"
#define EJECT_MSG ",\\n\\ \\ or [e] to eject the %s"
#define UNLOAD_MSG ",\\n\\ \\ or [u] to unload/offline the %s"
#define WLABEL_MSG ",\\n\\ \\ or [w] to write a new label on the %s"
#define OLABEL_MSG ",\\n\\ \\ or [o] to use the current label anyway"
#define QUIT_MSG ",\\n\\ \\ or [q] to quit"
#define ERR_ACCESS "\n%s (%s) cannot be accessed.\n"
#define ERR_FMT "\nAttempt to format %s failed.\n"
#define ERR_MKFS "\nAttempt to place filesystem on %s failed.\n"
#define ERR_REMOVE "\nExecution of \"removecmd\"[%s] failed.\n"
static void elabel(void);
static void doformat(char *, char *, char *);
static void labelerr(char *, char *);
static int ckilabel(char *, int);
static int insert(char *, char *, int, char *);
static char *cdevice; /* character device name */
static char *pname; /* device presentation name */
static char *volume; /* volume name */
/*
* Return:
* 0 - okay, label matches
* 1 - device not accessable
* 2 - unknown device (devattr failed)
* 3 - user selected quit
* 4 - label does not match
*/
/*
* macros from labelit to behave correctly for tape
* is a kludge, should use devmgmt
*/
#ifdef RT
#else
#endif
int
{
}
int
{
int n, override;
return (2); /* bad device */
}
if (!pname)
}
if (label) {
*pt = '\0';
}
} else
origvolname[0] = '\0';
}
override = 0;
for (;;) {
if (n < 0)
override++;
else if (n)
return (n); /* input function failed */
}
/* device was not accessible */
return (1);
return (1);
/* display advice on how to ready device */
continue;
}
/* check label on device */
if (label) {
elabel();
else {
return (4);
continue;
}
}
}
break;
}
return (0);
}
static int
{
int n, c;
*pt = '\0';
}
} else
volname[0] = '\0';
*pt++ = (char)c;
*pt = '\0';
look = "Current fsname: ";
while (*pt) {
*pt = '\0';
look = ", Current volname: ";
look = ", Blocks: ";
} else
break;
} else
pt++;
}
/* mismatched label */
if (flag) {
} else {
return (1);
}
}
return (0);
}
static int
{
char buffer[512];
int n;
"Enter text for fsname label:"))
return (n);
} else
"Enter text for volume label:"))
return (n);
} else
} else {
}
return (1);
}
if (label)
return (0);
}
static void
elabel(void)
{
}
static int
{
int n;
char *fmtcmd;
char *mkfscmd;
char *voltxt;
char *removecmd;
char *dev_type;
if (prompt) {
prompt++;
else if (*prompt == '%') {
switch (prompt[1]) {
case 'v':
break;
case 'p':
break;
default:
*pt = '\0';
break;
}
prompt += 2;
continue;
}
}
*pt = '\0';
} else {
" should appear on the %s:\\n\\t%s",
}
" The %s should be internally labeled as follows:",
voltxt);
"\\n\\t%s\\n", label);
}
}
n = 0;
keyword[n++] = "go";
keyword[n++] = "f";
keyword[n++] = "f";
}
keyword[n++] = "m";
}
keyword[n++] = "f";
}
}
keyword[n++] = "w";
}
keyword[n++] = "o";
}
keyword[n++] = "e";
} else {
keyword[n++] = "u";
}
}
if (ckquit)
*pt++ = ':';
*pt = '\0';
for (;;) {
return (n);
if (*strval == 'f') {
else
continue;
} else if (*strval == 'm') {
continue;
continue;
} else if (*strval == 'w') {
continue;
} else if (*strval == 'o')
return (-1);
break;
}
return (0);
}
static void
{
char buffer[512];
return;
}
}
return;
}
}
}
void
{
char *removecmd;
char buffer[512];
if (echo)
if (echo)
return;
}
}
}
}
static void
{
if (volume)
"The internal label on the inserted %s is\n", volume);
else
}