2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1993, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _VOLMGT_H
2N/A#define _VOLMGT_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <sys/types.h>
2N/A
2N/A/*
2N/A * volmgt_check:
2N/A * have volume management look at its devices to check
2N/A * for media having arrived. Since volume management can't
2N/A * automatically check all types of devices, this function is provided
2N/A * to allow applications to cause the check to happen automatically.
2N/A *
2N/A * arguments:
2N/A * path - the name of the device in /dev. For example,
2N/A * /dev/rdiskette. If path is NULL, all "checkable" devices are
2N/A * checked.
2N/A *
2N/A * return value(s):
2N/A * TRUE if media was found in the device, FALSE if not.
2N/A */
2N/Aint volmgt_check(char *path);
2N/A
2N/A/*
2N/A * volmgt_inuse:
2N/A * check to see if volume management is currently
2N/A * managing a particular device.
2N/A *
2N/A * arguments:
2N/A * path - the name of the device in /dev. For example,
2N/A * "/dev/rdiskette".
2N/A *
2N/A * return value(s):
2N/A * TRUE if volume management is managing the device, FALSE if not.
2N/A */
2N/Aint volmgt_inuse(char *path);
2N/A
2N/A/*
2N/A * volmgt_running:
2N/A * check to see if volume management is running.
2N/A *
2N/A * arguments:
2N/A * none.
2N/A *
2N/A * return value(s):
2N/A * TRUE if volume management is running, FALSE if not.
2N/A */
2N/Aint volmgt_running(void);
2N/A
2N/A/*
2N/A * volmgt_symname:
2N/A * Returns the volume management symbolic name
2N/A * for a given device. If an application wants to determine
2N/A * what the symbolic name (e.g. "floppy0") for the /dev/rdiskette
2N/A * device would be, this is the function to use.
2N/A *
2N/A * arguments:
2N/A * path - a string containing the /dev device name. For example,
2N/A * "/dev/diskette" or "/dev/rdiskette".
2N/A *
2N/A * return value(s):
2N/A * pointer to a string containing the symbolic name.
2N/A *
2N/A * NULL indicates that volume management isn't managing that device.
2N/A *
2N/A * The string must be free(3)'d.
2N/A */
2N/Achar *volmgt_symname(char *path);
2N/A
2N/A/*
2N/A * volmgt_symdev:
2N/A * Returns the device given the volume management
2N/A * symbolic name. If an application wants to determine
2N/A * what the device associated with a particular symbolic name
2N/A * might be, this is the function to use.
2N/A *
2N/A * arguments:
2N/A * path - a string containing the symbolic device name. For example,
2N/A * "cdrom0" or "floppy0".
2N/A *
2N/A * return value(s):
2N/A * pointer to a string containing the /dev name.
2N/A *
2N/A * NULL indicates that volume management isn't managing that device.
2N/A *
2N/A * The string must be free(3)'d.
2N/A */
2N/Achar *volmgt_symdev(char *symname);
2N/A
2N/A/*
2N/A * volmgt_ownspath:
2N/A * check to see if the given path is contained in
2N/A * the volume management name space.
2N/A *
2N/A * arguments:
2N/A * path - string containing the path.
2N/A *
2N/A * return value(s):
2N/A * TRUE if the path is owned by volume management, FALSE if not.
2N/A * Will return FALSE if volume management isn't running.
2N/A *
2N/A */
2N/Aint volmgt_ownspath(char *path);
2N/A
2N/A/*
2N/A * volmgt_root:
2N/A * return the root of where the volume management
2N/A * name space is mounted.
2N/A *
2N/A * arguments:
2N/A * none.
2N/A *
2N/A * return value(s):
2N/A * Returns a pointer to a string containing the path to the
2N/A * volume management root (e.g. "/vol").
2N/A * Will return NULL if volume management isn't running.
2N/A */
2N/Aconst char *volmgt_root(void);
2N/A
2N/A/*
2N/A * media_findname:
2N/A * try to come up with the character device when
2N/A * provided with a starting point. This interface provides the
2N/A * application programmer to provide "user friendly" names and
2N/A * easily determine the "/vol" name.
2N/A *
2N/A * arguments:
2N/A * start - a string describing a device. This string can be:
2N/A * - a full path name to a device (insures it's a
2N/A * character device by using getfullrawname()).
2N/A * - a full path name to a volume management media name
2N/A * with partitions (will return the lowest numbered
2N/A * raw partition.
2N/A * - the name of a piece of media (e.g. "fred").
2N/A * - a symbolic device name (e.g. floppy0, cdrom0, etc)
2N/A * - a name like "floppy" or "cdrom". Will pick the lowest
2N/A * numbered device with media in it.
2N/A *
2N/A * return value(s):
2N/A * A pointer to a string that contains the character device
2N/A * most appropriate to the "start" argument.
2N/A *
2N/A * NULL indicates that we were unable to find media based on "start".
2N/A *
2N/A * The string must be free(3)'d.
2N/A */
2N/Achar *media_findname(char *start);
2N/A
2N/A/*
2N/A * media_getattr:
2N/A * returns the value for an attribute for a piece of
2N/A * removable media.
2N/A *
2N/A * arguments:
2N/A * path - Path to the media in /vol. Can be the block or character
2N/A * device.
2N/A *
2N/A * attr - name of the attribute.
2N/A *
2N/A * return value(s):
2N/A * returns NULL or a pointer to a string that contains the value for
2N/A * the requested attribute.
2N/A *
2N/A * NULL can mean:
2N/A * - the media doesn't exist
2N/A * - there is no more space for malloc(3)
2N/A * - the attribute doesn't exist for the named media
2N/A * - the attribute is a boolean and is FALSE
2N/A *
2N/A * the pointer to the string must be free'd with free(3).
2N/A */
2N/Achar *media_getattr(char *path, char *attr);
2N/A
2N/A/*
2N/A * media_setattr:
2N/A * set an attribute for a piece of media to a
2N/A * particular value.
2N/A *
2N/A * arguments:
2N/A * path - Path to the media in /vol. Can be the block or character
2N/A * device.
2N/A *
2N/A * attr - name of the attribute.
2N/A *
2N/A * value - value of the attribute. If value == "", the flag is
2N/A * considered to be a boolean that is TRUE. If value == 0, it
2N/A * is considered to be a FALSE boolean.
2N/A *
2N/A * return value(s):
2N/A * TRUE on success, FALSE for failure.
2N/A *
2N/A * Can fail because:
2N/A * - don't have permission to set the attribute because caller
2N/A * is not the owner of the media and attribute is a "system"
2N/A * attribute.
2N/A *
2N/A * - don't have permission to set the attribute because the
2N/A * attribute is a "system" attribute and is read-only.
2N/A */
2N/Aint media_setattr(char *path, char *attr, char *value);
2N/A
2N/A/*
2N/A * media_getid:
2N/A * return the "id" of a piece of media.
2N/A *
2N/A * arguments:
2N/A * path - Path to the media in /vol. Can be the block or character
2N/A * device.
2N/A * return value(s):
2N/A * returns a u_longlong_t that is the "id" of the volume.
2N/A *
2N/A */
2N/Au_longlong_t media_getid(char *path);
2N/A
2N/A/*
2N/A * volmgt_feature_enabled:
2N/A * check to see if a volume management feature is available
2N/A *
2N/A * arguments:
2N/A * feat_str - a string containing the feature to be checked for
2N/A *
2N/A * return value(s):
2N/A * returns non-zero if the specified feature is available
2N/A * in volume management, else return zero
2N/A */
2N/Aint volmgt_feature_enabled(char *feat_str);
2N/A
2N/A/*
2N/A * volmgt_acquire
2N/A * try to acquire the volmgt advisory device reservation
2N/A * for a specific device. -- if volmgt isn't running then try to
2N/A * reserve the device specified
2N/A *
2N/A * arguments:
2N/A * dev - a device name to attempt reserving. This string can be:
2N/A * - a full path name to a device in /vol if volmgt is running
2N/A * - a symbolic device name (e.g. floppy0) if volmgt is running
2N/A * - a /dev pathname if volmgt is not running
2N/A *
2N/A * id - a reservation string that hopefully describes the application
2N/A * making this reservation.
2N/A *
2N/A * ovr - an override indicator. If set to non-zero, the caller requests
2N/A * that this reservation be made unconditionally.
2N/A *
2N/A * err - the address of a char ptr that will updated to point to the
2N/A * id argument used when the current device was reserved. This
2N/A * is only used when the current reservation attempt fails due
2N/A * to an already existing reservation for this device.
2N/A *
2N/A * pidp - a pointer to a pid_t type. If this argument is not NULL
2N/A * and the requested device is already reserved, the process
2N/A * id of the reservation owner will be returned in this
2N/A * location.
2N/A *
2N/A *
2N/A * return value(s):
2N/A * A non-zero indicator if successful.
2N/A *
2N/A * A zero indicator if unsuccessful. If errno is EBUSY, then the err
2N/A * argument will be set to point to the string that the process currently
2N/A * holding the reservation supplied when reserving the device. It is up
2N/A * to the caller to release the storage occupied by the string via
2N/A * free(3C) when no longer needed.
2N/A */
2N/Aint volmgt_acquire(char *dev, char *id, int ovr, char **err, pid_t *pidp);
2N/A
2N/A/*
2N/A * the max length for the "id" string in volmgt_acquire
2N/A */
2N/A#define VOL_RSV_MAXIDLEN 256
2N/A
2N/A/*
2N/A * volmgt_release:
2N/A * try to release the volmgt advisory device reservation
2N/A * for a specific device.
2N/A *
2N/A * arguments:
2N/A * dev - a device name to attempt reserving. This string can be:
2N/A * - a full path name to a device in /vol if volmgt is running
2N/A * - a symbolic device name (e.g. floppy0) if volmgt is running
2N/A * - a /dev pathname if volmgt is not running
2N/A *
2N/A * return value(s):
2N/A * A non-zero indicator if successful
2N/A * A zero indicator if unsuccessful
2N/A *
2N/A * preconditions:
2N/A * none
2N/A */
2N/Aint volmgt_release(char *dev);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _VOLMGT_H */