volutil.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) 1996 by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#include <unistd.h>
#ifdef DEBUG_IOCTL
#endif
#include <volmgt.h>
#include <ctype.h>
#include "volmgt_private.h"
const char *volctl_name(void);
/*
* arc approved interface
* - can not be modified without approval from an arc
*
* committment level:
* public
*
* description:
* volmgt_running: check to see if volume management is running.
*
* arguments:
* none.
*
* return value(s):
* TRUE if volume management is running, FALSE if not.
*
* preconditions:
* none.
*/
int
volmgt_running(void)
{
const char *volctl_dev = volctl_name();
int res;
#ifdef DEBUG
denter("volmgt_running: entering\n");
#endif
#ifdef DEBUG
#endif
return (res);
}
/*
* arc approved interface
* - can not be modified without approval from an arc
*
* committment level:
* public
*
* description:
* volmgt_inuse: check to see if volume management is currently
* managing a particular device.
*
* arguments:
* path - the name of the device in /dev. For example,
*
* return value(s):
* TRUE if volume management is managing the device, FALSE if not.
*
* preconditions:
* none.
*/
int
volmgt_inuse(char *path)
{
const char *volctl_dev = volctl_name();
int fd = -1;
int ret_val;
#ifdef DEBUG
denter("volmgt_inuse(%s): entering\n",
#endif
#ifdef DEBUG_STAT
#endif
goto dun;
}
#ifdef DEBUG_OPEN
#endif
#ifdef DEBUG
#endif
goto dun;
}
#ifdef DEBUG_IOCTL
#endif
goto dun;
}
dun:
if (fd >= 0) {
}
#ifdef DEBUG
#endif
return (ret_val);
}
/*
* arc approved interface
* - can not be modified without approval from an arc
*
* committment level:
* public
*
* description:
* volmgt_check: have volume management look at its devices to check
* for media having arrived. Since volume management can't
* automatically check all types of devices, this function is provided
* to allow applications to cause the check to happen automatically.
*
* arguments:
* path - the name of the device in /dev. For example,
* checked.
*
* return value(s):
* TRUE if media was found in the device, FALSE if not.
*
* preconditions:
* volume management must be running.
*/
int
volmgt_check(char *path)
{
const char *volctl_dev = volctl_name();
int fd = -1;
int ret_val;
#ifdef DEBUG
denter("volmgt_check(%s): entering\n",
#endif
#ifdef DEBUG_STAT
#endif
goto dun;
}
}
#ifdef DEBUG_OPEN
#endif
#ifdef DEBUG
#endif
goto dun;
}
/* if "no device" specified, that means "all devices" */
}
#ifdef DEBUG_IOCTL
#endif
goto dun;
}
dun:
if (fd >= 0) {
}
#ifdef DEBUG
dexit("volmgt_check: returning %s\n",
#endif
return (ret_val);
}
/*
* arc approved interface
* - can not be modified without approval from an arc
*
* committment level:
* public
*
* description:
* volmgt_ownspath: check to see if the given path is contained in
* the volume management name space.
*
* arguments:
* path - string containing the path.
*
* return value(s):
* TRUE if the path is owned by volume management, FALSE if not.
* Will return FALSE if volume management isn't running.
*
* preconditions:
* none.
*/
int
volmgt_ownspath(char *path)
{
static uint vold_root_len;
int ret_val;
vold_root = volmgt_root();
}
} else {
}
return (ret_val);
}
/*
* arc approved interface
* - can not be modified without approval from an arc
*
* committment level:
* public
*
* description:
* volmgt_root: return the root of where the volume management
* name space is mounted.
*
* arguments:
* none.
*
* return value(s):
* Returns a pointer to a static string containing the path to the
* volume management root (e.g. "/vol").
* Will return NULL if volume management isn't running.
*
* preconditions:
* none.
*/
const char *
volmgt_root(void)
{
const char *volctl_dev = volctl_name();
int fd = -1;
#ifdef DEBUG
denter("volmgt_root: entering\n");
#endif
goto dun;
}
#ifdef DEBUG_OPEN
#endif
#ifdef DEBUG
#endif
/* a guess is better than nothing? */
goto dun;
}
#ifdef DEBUG_IOCTL
#endif
#ifdef DEBUG
"volmgt_root: ioctl(VOLIOCROOT) on \"%s\" failed (errno %d)\n",
volctl_dev, errno);
#endif
goto dun;
}
dun:
if (fd >= 0) {
}
#ifdef DEBUG
#endif
return ((const char *)vold_root);
}
/*
* arc approved interface
* - can not be modified without approval from an arc
*
* committment level:
* public
*
* description:
* volmgt_symname: Returns the volume management symbolic name
* for a given device. If an application wants to determine
* device would be, this is the function to use.
*
* arguments:
* path - a string containing the /dev device name. For example,
*
* Note: must be a block- or char-spcl device, and have a non-zero
* st_rdev (real device) stat() value.
*
* return value(s):
* pointer to a string containing the symbolic name.
*
* NULL indicates that volume management isn't managing that device.
*
* The string must be free(3)'d.
*
* preconditions:
* none.
*/
char *
volmgt_symname(char *path)
{
const char *volctl_dev = volctl_name();
int fd = -1;
struct vioc_symname sn;
#ifdef DEBUG
#endif
/* just in case */
#ifdef DEBUG
dprintf("volmgt_symname error: input path is null!\n");
#endif
goto dun;
}
#ifdef DEBUG_STAT
#endif
#ifdef DEBUG
dprintf("volmgt_symname error: can't stat \"%s\" (errno %d)\n",
#endif
goto dun;
}
/* ensure we have a spcl device with a non-zero st_rdev */
#ifdef DEBUG
dprintf("volmgt_symname error: %s not blk- or chr-spcl\n",
path);
#endif
goto dun;
}
#ifdef DEBUG
dprintf("volmgt_symname error: dev_t of %s is zero!\n",
path);
#endif
}
#ifdef DEBUG_OPEN
#endif
#ifdef DEBUG
dprintf("volmgt_symname error: can't open \"%s\" (errno %d)\n",
volctl_dev, errno);
#endif
goto dun;
}
#ifdef DEBUG_IOCTL
"volmgt_symname: ioctl(%s, VOLIOCSYMNAME, {%d.%d, %#x, %d})ing\n",
sn.sn_pathlen);
#endif
}
#ifdef DEBUG
else {
"volmgt_symname: ioctl(VOLIOCSYMNAME) failed (errno %d)\n",
errno);
}
#endif
dun:
if (fd >= 0) {
}
#ifdef DEBUG
dexit("volmgt_symname: returning \"%s\"\n",
#endif
return (result);
}
/*
* arc approved interface
* - can not be modified without approval from an arc
*
* committment level:
* public
*
* description:
* volmgt_symdev: Returns the device given the volume management
* symbolic name. If an application wants to determine
* what the device associated with a particular symbolic name
* might be, this is the function to use.
*
* arguments:
* path - a string containing the symbolic device name. For example,
* "cdrom0" or "floppy0".
*
* return value(s):
* pointer to a string containing the /dev name.
*
* NULL indicates that volume management isn't managing that device.
*
* The string must be free(3)'d.
*
* preconditions:
* none.
*/
char *
volmgt_symdev(char *symname)
{
const char *volctl_dev = volctl_name();
int fd = -1;
struct vioc_symdev sd;
#ifdef DEBUG
#endif
#ifdef DEBUG_OPEN
#endif
#ifdef DEBUG
dprintf("volmgt_symdev error: can't open \"%s\" (errno %d)\n",
volctl_dev, errno);
#endif
goto dun;
}
#ifdef DEBUG_IOCTL
dprintf("---- make the ioctl for VOLIOCSYMDEV ----\n");
#endif
}
#ifdef DEBUG
else {
"volmgt_symdev: VOLIOCSYMDEV ioctl failed (errno %d)\n",
errno);
}
#endif
dun:
if (fd >= 0) {
}
#ifdef DEBUG
dexit("volmgt_symdev: returning \"%s\"\n",
#endif
return (result);
}
/*
* arc approved interface
* - can not be modified without approval from an arc
*
* committment level:
* public
*
* description:
* volmgt_feat_enabled: check to see if a volume management feature
* is available
*
* arguments:
* feat_str - a string containing the feature to be checked for
*
* return value(s):
* return non-zero if the specified feature is available in
* volume management, else return zero
*
* preconditions:
* none.
*/
/*
* the following is a lit of the "feature" available in volmgt
*
* this list is meant to be updated when new features (that users may
* want to use) are added to volmgt
*
* note: feature strings added should be all lower case, and spaces are
* discouraged
*
* (see psarc/1995/138 for more info)
*/
static char *volmgt_feat_list[] = {
#ifdef DIRECT_DEV_ACCESS_WORKING
"direct-dev-access", /* access through /dev co-exists */
#endif
"floppy-summit-interfaces", /* volmgt_{acquire,release} */
};
int
volmgt_feature_enabled(char *feat_str)
{
int i;
char *cp;
int res = 0;
/* ensure no hoser can core dump us */
return (0); /* I guess this isn't a match */
}
/* ensure feat string passed in is all lower case (as feats are) */
}
}
/* now scan for a match */
for (i = 0; volmgt_feat_list[i] != NULL; i++) {
res++;
break;
}
}
return (res);
}