volprivate.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) 1995-1997 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* routines in this module are meant to be called by other libvolmgt
* routines only
*/
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <string.h>
#include <libintl.h>
#include <limits.h>
#include <unistd.h>
#include <stdlib.h>
#ifdef DEBUG
#endif
#include "volmgt_private.h"
/*
* We have been passed a path which (presumably) is a volume.
* We look through the directory until we find a name which is
* a character device.
*/
char *
getrawpart0(char *path)
{
char *res;
int len;
/* open the directory */
goto dun;
}
/* get length of directory part */
/* scan the directory */
/* skip "." and ".." */
continue;
}
continue;
}
/* ensure we have room for this name */
/* XXX: just give up? */
continue;
}
/* create a pathname for this device */
continue; /* this shouldn't happen */
}
/* check for a char-spcl device */
goto dun;
}
}
/* raw part not found */
dun:
}
return (res);
}
/*
* fix the getfull{raw,blk}name problem for the fd and diskette case
*
* return value is malloc'ed, and must be free'd
*
* no match gets a malloc'ed null string
*/
char *
volmgt_getfullblkname(char *n)
{
extern char *getfullblkname(char *);
char *rval;
char *s;
char c;
char *res;
/* try to get full block-spcl device name */
rval = getfullblkname(n);
/* found it */
goto dun;
}
/* we have a null-string result */
/* free null string */
}
/* ok, so we either have a bad device or a floppy */
/* try the rfd# or rdiskette forms */
/*
* we do not have to check for room here, since we will
* be making the string one shorter
*/
c = *++s; /* save the first char */
*s = NULLC; /* replace it with a null */
*s++ = c; /* give the first char back */
goto dun;
}
/* no match found */
dun:
return (res);
}
char *
volmgt_getfullrawname(char *n)
{
extern char *getfullrawname(char *);
char *rval;
char *s;
char c;
char *res;
#ifdef DEBUG
denter("volmgt_getfullrawname(%s): entering\n", n);
#endif
/* try to get full char-spcl device name */
rval = getfullrawname(n);
/* found it */
goto dun;
}
/* we have a null-string result */
/* free null string */
}
/* ok, so we either have a bad device or a floppy */
/* try the "fd", "diskette", and the "dsk" form */
/*
* ensure we have room to add one more char
*/
c = *++s; /* save the first char */
*s = NULLC; /* replace it with a null */
*s = c; /* put first charback */
goto dun;
}
}
/* no match found */
dun:
#ifdef DEBUG
dexit("volmgt_getfullrawname: returning %s\n",
#endif
return (res);
}
/*
* volctl_name -- return name of volctl device
*/
const char *
volctl_name(void)
{
return (dev_name);
}
/*
* concat_paths -- create a pathname from two (or three) components
*
* truncate the result if it is too large
*
* assume that res has a defined length of MAXPATHLEN+1
*
* ("head" and "tail" are required, but "tail2" is optional)
*/
char *
{
int len_avail = MAXPATHLEN;
/* put in as much of the head as will fit */
/* see if there is room to proceed */
if (len_avail > 0) {
/* there is room to append a slash */
*cp++ = '/';
len_avail--;
/* see if there is room to proceed */
if (len_avail > 0) {
/* there is room to append the tail */
/* see if there is room to proceed */
/* there is room to add tail2 (and need) */
}
}
}
/* null terminate result (just in case) and return */
return (res);
}
#ifdef DEBUG
/*
* debug print routines -- private to libvolmgt
*/
#define DEBUG_INDENT_SPACES " "
int debug_level = 0;
static void
{
int i;
int j;
char date_buf[256];
time_t t;
(void) time(&t);
for (i = 0; i < debug_level; i++) {
}
}
/*
* denter -- do a derrprint(), then increment debug level
*/
void
{
debug_level++;
}
/*
* dexit -- decrement debug level then do a derrprint()
*/
void
{
if (--debug_level < 0) {
debug_level = 0;
}
}
/*
* dprintf -- print debug info, indenting based on debug level
*/
void
{
}
#endif /* DEBUG */