xref: /titanic_44/usr/src/lib/libvolmgt/common/volmgt.c (revision b941d3fc4e70b4411341c7aeb53517bbff5f2df4)
118c2aff7Sartem /*
218c2aff7Sartem  * CDDL HEADER START
318c2aff7Sartem  *
418c2aff7Sartem  * The contents of this file are subject to the terms of the
518c2aff7Sartem  * Common Development and Distribution License (the "License").
618c2aff7Sartem  * You may not use this file except in compliance with the License.
718c2aff7Sartem  *
818c2aff7Sartem  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
918c2aff7Sartem  * or http://www.opensolaris.org/os/licensing.
1018c2aff7Sartem  * See the License for the specific language governing permissions
1118c2aff7Sartem  * and limitations under the License.
1218c2aff7Sartem  *
1318c2aff7Sartem  * When distributing Covered Code, include this CDDL HEADER in each
1418c2aff7Sartem  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1518c2aff7Sartem  * If applicable, add the following below this CDDL HEADER, with the
1618c2aff7Sartem  * fields enclosed by brackets "[]" replaced with your own identifying
1718c2aff7Sartem  * information: Portions Copyright [yyyy] [name of copyright owner]
1818c2aff7Sartem  *
1918c2aff7Sartem  * CDDL HEADER END
2018c2aff7Sartem  */
2118c2aff7Sartem /*
22*b941d3fcSartem  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
2318c2aff7Sartem  * Use is subject to license terms.
2418c2aff7Sartem  */
2518c2aff7Sartem 
2618c2aff7Sartem #pragma ident	"%Z%%M%	%I%	%E% SMI"
2718c2aff7Sartem 
2818c2aff7Sartem #include	<stdio.h>
2918c2aff7Sartem #include	<string.h>
3018c2aff7Sartem #include	<dirent.h>
3118c2aff7Sartem #include	<fcntl.h>
3218c2aff7Sartem #include	<string.h>
3318c2aff7Sartem #include	<errno.h>
3418c2aff7Sartem #include	<limits.h>
3518c2aff7Sartem #include	<unistd.h>
3618c2aff7Sartem #include	<sys/mkdev.h>
3718c2aff7Sartem #include	<volmgt.h>
3818c2aff7Sartem #include	<ctype.h>
3918c2aff7Sartem #include	<sys/types.h>
4018c2aff7Sartem #include	<sys/stat.h>
4118c2aff7Sartem #include	<sys/param.h>
4218c2aff7Sartem #include	"volmgt_private.h"
4318c2aff7Sartem 
4418c2aff7Sartem /*
4518c2aff7Sartem  * arc approved interface
4618c2aff7Sartem  *	- can not be modified without approval from an arc
4718c2aff7Sartem  *
4818c2aff7Sartem  * committment level:
4918c2aff7Sartem  *	public
5018c2aff7Sartem  *
5118c2aff7Sartem  * description:
5218c2aff7Sartem  *	volmgt_running: check to see if volume management is running.
5318c2aff7Sartem  *
5418c2aff7Sartem  * arguments:
5518c2aff7Sartem  *	none.
5618c2aff7Sartem  *
5718c2aff7Sartem  * return value(s):
5818c2aff7Sartem  *	TRUE if volume management is running, FALSE if not.
5918c2aff7Sartem  *
6018c2aff7Sartem  * preconditions:
6118c2aff7Sartem  *	none.
6218c2aff7Sartem  */
6318c2aff7Sartem int
volmgt_running(void)6418c2aff7Sartem volmgt_running(void)
6518c2aff7Sartem {
6618c2aff7Sartem 	/* vold is dead */
6718c2aff7Sartem 	return (FALSE);
6818c2aff7Sartem }
6918c2aff7Sartem 
7018c2aff7Sartem 
7118c2aff7Sartem /*
7218c2aff7Sartem  * arc approved interface
7318c2aff7Sartem  *	- can not be modified without approval from an arc
7418c2aff7Sartem  *
7518c2aff7Sartem  * committment level:
7618c2aff7Sartem  *	public
7718c2aff7Sartem  *
7818c2aff7Sartem  * description:
7918c2aff7Sartem  *	volmgt_inuse: check to see if volume management is currently
8018c2aff7Sartem  *	managing a particular device.
8118c2aff7Sartem  *
8218c2aff7Sartem  * arguments:
8318c2aff7Sartem  *	path - the name of the device in /dev.  For example,
8418c2aff7Sartem  *	  "/dev/rdiskette".
8518c2aff7Sartem  *
8618c2aff7Sartem  * return value(s):
8718c2aff7Sartem  *	TRUE if volume management is managing the device, FALSE if not.
8818c2aff7Sartem  *
8918c2aff7Sartem  * preconditions:
9018c2aff7Sartem  *	none.
9118c2aff7Sartem  */
9218c2aff7Sartem /* ARGSUSED */
9318c2aff7Sartem int
volmgt_inuse(char * path)9418c2aff7Sartem volmgt_inuse(char *path)
9518c2aff7Sartem {
9618c2aff7Sartem 	return (FALSE);
9718c2aff7Sartem }
9818c2aff7Sartem 
9918c2aff7Sartem 
10018c2aff7Sartem /*
10118c2aff7Sartem  * arc approved interface
10218c2aff7Sartem  *	- can not be modified without approval from an arc
10318c2aff7Sartem  *
10418c2aff7Sartem  * committment level:
10518c2aff7Sartem  *	public
10618c2aff7Sartem  *
10718c2aff7Sartem  * description:
10818c2aff7Sartem  *	volmgt_check: have volume management look at its devices to check
10918c2aff7Sartem  *	for media having arrived.  Since volume management can't
11018c2aff7Sartem  *	automatically check all types of devices, this function is provided
11118c2aff7Sartem  *	to allow applications to cause the check to happen automatically.
11218c2aff7Sartem  *
11318c2aff7Sartem  * arguments:
11418c2aff7Sartem  *	path - the name of the device in /dev.  For example,
11518c2aff7Sartem  *	  /dev/rdiskette.  If path is NULL, all "checkable" devices are
11618c2aff7Sartem  *	  checked.
11718c2aff7Sartem  *
11818c2aff7Sartem  * return value(s):
11918c2aff7Sartem  *	TRUE if media was found in the device, FALSE if not.
12018c2aff7Sartem  *
12118c2aff7Sartem  * preconditions:
12218c2aff7Sartem  *	volume management must be running.
12318c2aff7Sartem  */
12418c2aff7Sartem /* ARGSUSED */
12518c2aff7Sartem int
volmgt_check(char * path)12618c2aff7Sartem volmgt_check(char *path)
12718c2aff7Sartem {
12818c2aff7Sartem 	return (FALSE);
12918c2aff7Sartem }
13018c2aff7Sartem 
13118c2aff7Sartem 
13218c2aff7Sartem /*
13318c2aff7Sartem  * arc approved interface
13418c2aff7Sartem  *	- can not be modified without approval from an arc
13518c2aff7Sartem  *
13618c2aff7Sartem  * committment level:
13718c2aff7Sartem  *	public
13818c2aff7Sartem  *
13918c2aff7Sartem  * description:
14018c2aff7Sartem  *	volmgt_ownspath: check to see if the given path is contained in
14118c2aff7Sartem  *	the volume management name space.
14218c2aff7Sartem  *
14318c2aff7Sartem  * arguments:
14418c2aff7Sartem  *	path - string containing the path.
14518c2aff7Sartem  *
14618c2aff7Sartem  * return value(s):
14718c2aff7Sartem  *	TRUE if the path is owned by volume management, FALSE if not.
14818c2aff7Sartem  *	Will return FALSE if volume management isn't running.
14918c2aff7Sartem  *
15018c2aff7Sartem  * preconditions:
15118c2aff7Sartem  *	none.
15218c2aff7Sartem  */
15318c2aff7Sartem /* ARGSUSED */
15418c2aff7Sartem int
volmgt_ownspath(char * path)15518c2aff7Sartem volmgt_ownspath(char *path)
15618c2aff7Sartem {
15718c2aff7Sartem 	return (FALSE);
15818c2aff7Sartem }
15918c2aff7Sartem 
16018c2aff7Sartem 
16118c2aff7Sartem /*
16218c2aff7Sartem  * arc approved interface
16318c2aff7Sartem  *	- can not be modified without approval from an arc
16418c2aff7Sartem  *
16518c2aff7Sartem  * committment level:
16618c2aff7Sartem  *	public
16718c2aff7Sartem  *
16818c2aff7Sartem  * description:
16918c2aff7Sartem  *	volmgt_root: return the root of where the volume management
17018c2aff7Sartem  *	name space is mounted.
17118c2aff7Sartem  *
17218c2aff7Sartem  * arguments:
17318c2aff7Sartem  *	none.
17418c2aff7Sartem  *
17518c2aff7Sartem  * return value(s):
17618c2aff7Sartem  *	Returns a pointer to a static string containing the path to the
17718c2aff7Sartem  *	volume management root (e.g. "/vol").
17818c2aff7Sartem  *	Will return NULL if volume management isn't running.
17918c2aff7Sartem  *
18018c2aff7Sartem  * preconditions:
18118c2aff7Sartem  *	none.
18218c2aff7Sartem  */
18318c2aff7Sartem const char *
volmgt_root(void)18418c2aff7Sartem volmgt_root(void)
18518c2aff7Sartem {
18618c2aff7Sartem 	static const char *vold_root = "/dev";
18718c2aff7Sartem 
18818c2aff7Sartem 	return (vold_root);
18918c2aff7Sartem }
19018c2aff7Sartem 
19118c2aff7Sartem 
19218c2aff7Sartem /*
19318c2aff7Sartem  * arc approved interface
19418c2aff7Sartem  *	- can not be modified without approval from an arc
19518c2aff7Sartem  *
19618c2aff7Sartem  * committment level:
19718c2aff7Sartem  *	public
19818c2aff7Sartem  *
19918c2aff7Sartem  * description:
20018c2aff7Sartem  *	volmgt_symname: Returns the volume management symbolic name
20118c2aff7Sartem  *	for a given device.  If an application wants to determine
20218c2aff7Sartem  *	what the symbolic name (e.g. "floppy0") for the /dev/rdiskette
20318c2aff7Sartem  *	device would be, this is the function to use.
20418c2aff7Sartem  *
20518c2aff7Sartem  * arguments:
20618c2aff7Sartem  *	path - a string containing the /dev device name.  For example,
20718c2aff7Sartem  *	"/dev/diskette" or "/dev/rdiskette".
20818c2aff7Sartem  *
20918c2aff7Sartem  *	Note: must be a block- or char-spcl device, and have a non-zero
21018c2aff7Sartem  *	st_rdev (real device) stat() value.
21118c2aff7Sartem  *
21218c2aff7Sartem  * return value(s):
21318c2aff7Sartem  *	pointer to a string containing the symbolic name.
21418c2aff7Sartem  *
21518c2aff7Sartem  *	NULL indicates that volume management isn't managing that device.
21618c2aff7Sartem  *
21718c2aff7Sartem  *	The string must be free(3)'d.
21818c2aff7Sartem  *
21918c2aff7Sartem  * preconditions:
22018c2aff7Sartem  *	none.
22118c2aff7Sartem  */
22218c2aff7Sartem /* ARGSUSED */
22318c2aff7Sartem char *
volmgt_symname(char * path)22418c2aff7Sartem volmgt_symname(char *path)
22518c2aff7Sartem {
22618c2aff7Sartem 	return (NULL);
22718c2aff7Sartem }
22818c2aff7Sartem 
22918c2aff7Sartem 
23018c2aff7Sartem /*
23118c2aff7Sartem  * arc approved interface
23218c2aff7Sartem  *	- can not be modified without approval from an arc
23318c2aff7Sartem  *
23418c2aff7Sartem  * committment level:
23518c2aff7Sartem  *	public
23618c2aff7Sartem  *
23718c2aff7Sartem  * description:
23818c2aff7Sartem  *	volmgt_symdev: Returns the device given the volume management
23918c2aff7Sartem  *	symbolic name. If an application wants to determine
24018c2aff7Sartem  *	what the device associated with a particular symbolic name
24118c2aff7Sartem  *	might be, this is the function to use.
24218c2aff7Sartem  *
24318c2aff7Sartem  * arguments:
24418c2aff7Sartem  *	path - a string containing the symbolic device name.  For example,
24518c2aff7Sartem  *	"cdrom0" or "floppy0".
24618c2aff7Sartem  *
24718c2aff7Sartem  * return value(s):
24818c2aff7Sartem  *	pointer to a string containing the /dev name.
24918c2aff7Sartem  *
25018c2aff7Sartem  *	NULL indicates that volume management isn't managing that device.
25118c2aff7Sartem  *
25218c2aff7Sartem  *	The string must be free(3)'d.
25318c2aff7Sartem  *
25418c2aff7Sartem  * preconditions:
25518c2aff7Sartem  *	none.
25618c2aff7Sartem  */
25718c2aff7Sartem /* ARGSUSED */
25818c2aff7Sartem char *
volmgt_symdev(char * symname)25918c2aff7Sartem volmgt_symdev(char *symname)
26018c2aff7Sartem {
26118c2aff7Sartem 	return (NULL);
26218c2aff7Sartem }
26318c2aff7Sartem 
26418c2aff7Sartem 
26518c2aff7Sartem /*
26618c2aff7Sartem  * arc approved interface
26718c2aff7Sartem  *	- can not be modified without approval from an arc
26818c2aff7Sartem  *
26918c2aff7Sartem  * committment level:
27018c2aff7Sartem  *	public
27118c2aff7Sartem  *
27218c2aff7Sartem  * description:
27318c2aff7Sartem  *	volmgt_feat_enabled: check to see if a volume management feature
27418c2aff7Sartem  *	is available
27518c2aff7Sartem  *
27618c2aff7Sartem  * arguments:
27718c2aff7Sartem  *	feat_str - a string containing the feature to be checked for
27818c2aff7Sartem  *
27918c2aff7Sartem  * return value(s):
28018c2aff7Sartem  *	return non-zero if the specified feature is available in
28118c2aff7Sartem  *	volume management, else return zero
28218c2aff7Sartem  *
28318c2aff7Sartem  * preconditions:
28418c2aff7Sartem  *	none.
28518c2aff7Sartem  */
28618c2aff7Sartem 
28718c2aff7Sartem 
28818c2aff7Sartem /*
28918c2aff7Sartem  * the following is a lit of the "feature" available in volmgt
29018c2aff7Sartem  *
29118c2aff7Sartem  * this list is meant to be updated when new features (that users may
29218c2aff7Sartem  * want to use) are added to volmgt
29318c2aff7Sartem  *
29418c2aff7Sartem  * note: feature strings added should be all lower case, and spaces are
29518c2aff7Sartem  * discouraged
29618c2aff7Sartem  *
29718c2aff7Sartem  * (see psarc/1995/138 for more info)
29818c2aff7Sartem  */
29918c2aff7Sartem static char	*volmgt_feat_list[] = {
30018c2aff7Sartem #ifdef	DIRECT_DEV_ACCESS_WORKING
30118c2aff7Sartem 	"direct-dev-access",		/* access through /dev co-exists */
30218c2aff7Sartem #endif
30318c2aff7Sartem 	"floppy-summit-interfaces",	/* volmgt_{acquire,release} */
30418c2aff7Sartem 	NULL
30518c2aff7Sartem };
30618c2aff7Sartem 
30718c2aff7Sartem 
30818c2aff7Sartem int
volmgt_feature_enabled(char * feat_str)30918c2aff7Sartem volmgt_feature_enabled(char *feat_str)
31018c2aff7Sartem {
31118c2aff7Sartem 	return (0);
31218c2aff7Sartem }
31318c2aff7Sartem /*
31418c2aff7Sartem  * arc approved interface
31518c2aff7Sartem  *	- can not be modified without approval from an arc
31618c2aff7Sartem  *
31718c2aff7Sartem  * committment level:
31818c2aff7Sartem  *	uncommitted
31918c2aff7Sartem  *
32018c2aff7Sartem  * description:
32118c2aff7Sartem  *	volmgt_acquire: try to acquire the volmgt advisory device reservation
32218c2aff7Sartem  *	for a specific device.
32318c2aff7Sartem  *
32418c2aff7Sartem  * arguments:
32518c2aff7Sartem  *	dev - a device name to attempt reserving.  This string can be:
32618c2aff7Sartem  *		- a full path name to a device
32718c2aff7Sartem  *		- a symbolic device name (e.g. floppy0)
32818c2aff7Sartem  *
32918c2aff7Sartem  *	id  - a reservation string that hopefully describes the application
33018c2aff7Sartem  *		making this reservation.
33118c2aff7Sartem  *
33218c2aff7Sartem  *	pid - a pointer to a pid_t type.  If this argument is not NULL
33318c2aff7Sartem  *		and the requested device is already reserved, the process
33418c2aff7Sartem  *		id of the reservation owner will be returned in this
33518c2aff7Sartem  *		location.
33618c2aff7Sartem  *
33718c2aff7Sartem  *	ovr - an override indicator.  If set to non-zero, the caller requests
33818c2aff7Sartem  *		that this reservation be made unconditionally.
33918c2aff7Sartem  *
34018c2aff7Sartem  *	err - the address of a pointer to a string which is to receive the
34118c2aff7Sartem  *		id argument used when the current device was reserved.  This
34218c2aff7Sartem  *		is only used when the current reservation attempt fails due
34318c2aff7Sartem  *		to an already existing reservation for this device.
34418c2aff7Sartem  *
34518c2aff7Sartem  * return value(s):
34618c2aff7Sartem  *	A non-zero indicator if successful.
34718c2aff7Sartem  *
34818c2aff7Sartem  *	A zero indicator if unsuccessful.  If errno is EBUSY, then the err
34918c2aff7Sartem  *	argument will be set to point to the string that the process currently
35018c2aff7Sartem  *	holding the reservation supplied when reserving the device.  It is up
35118c2aff7Sartem  *	to the caller to release the storage occupied by the string via
35218c2aff7Sartem  *	free(3C) when no longer needed.
35318c2aff7Sartem  *
35418c2aff7Sartem  * preconditions:
35518c2aff7Sartem  *	none
35618c2aff7Sartem  */
35718c2aff7Sartem /* ARGSUSED */
35818c2aff7Sartem int
volmgt_acquire(char * dev,char * id,int ovr,char ** err,pid_t * pidp)35918c2aff7Sartem volmgt_acquire(char *dev, char *id, int ovr, char **err, pid_t *pidp)
36018c2aff7Sartem {
36118c2aff7Sartem 	return (0);
36218c2aff7Sartem }
36318c2aff7Sartem 
36418c2aff7Sartem 
36518c2aff7Sartem /*
36618c2aff7Sartem  * arc approved interface
36718c2aff7Sartem  *	- can not be modified without approval from an arc
36818c2aff7Sartem  *
36918c2aff7Sartem  * committment level:
37018c2aff7Sartem  *	uncommitted
37118c2aff7Sartem  *
37218c2aff7Sartem  * description:
37318c2aff7Sartem  *	volmgt_release: try to release the volmgt advisory device reservation
37418c2aff7Sartem  *	for a specific device.
37518c2aff7Sartem  *
37618c2aff7Sartem  * arguments:
37718c2aff7Sartem  *	dev - a device name to attempt reserving.  This string can be:
37818c2aff7Sartem  *		- a full path name to a device
37918c2aff7Sartem  *		- a symbolic device name (e.g. floppy0)
38018c2aff7Sartem  *
38118c2aff7Sartem  * return value(s):
38218c2aff7Sartem  *	A non-zero indicator if successful
38318c2aff7Sartem  *	A zero indicator if unsuccessful
38418c2aff7Sartem  *
38518c2aff7Sartem  * preconditions:
38618c2aff7Sartem  *	none
38718c2aff7Sartem  */
38818c2aff7Sartem int
volmgt_release(char * dev)38918c2aff7Sartem volmgt_release(char *dev)
39018c2aff7Sartem {
39118c2aff7Sartem 	return (0);
39218c2aff7Sartem }
39318c2aff7Sartem 
39418c2aff7Sartem 
39518c2aff7Sartem /*
39618c2aff7Sartem  * returns the "value" of the attribute.
39718c2aff7Sartem  * If the attribute is boolean and is TRUE,
39818c2aff7Sartem  * "true" is returned.  If the boolean is
39918c2aff7Sartem  * FALSE, NULL is returned.  If the attribute
40018c2aff7Sartem  * doesn't exist, NULL is returned.  The pointer
40118c2aff7Sartem  * returned by media_getattr has been malloc'd and
40218c2aff7Sartem  * it is the callers responsibility to free it.
40318c2aff7Sartem  */
40418c2aff7Sartem /*
40518c2aff7Sartem  * arc approved interface
40618c2aff7Sartem  *	- can not be modified without approval from an arc
40718c2aff7Sartem  *
40818c2aff7Sartem  * committment level:
40918c2aff7Sartem  *	public
41018c2aff7Sartem  *
41118c2aff7Sartem  * description:
41218c2aff7Sartem  *	media_getattr: returns the value for an attribute for a piece of
41318c2aff7Sartem  * 	removable media.
41418c2aff7Sartem  *
41518c2aff7Sartem  * arguments:
41618c2aff7Sartem  *	path - Path to the media in /vol.  Can be the block or character
41718c2aff7Sartem  *		device.
41818c2aff7Sartem  *
41918c2aff7Sartem  *	attr - name of the attribute.
42018c2aff7Sartem  *
42118c2aff7Sartem  * return value(s):
42218c2aff7Sartem  *	returns NULL or a pointer to a string that contains the value for
42318c2aff7Sartem  * 	the requested attribute.
42418c2aff7Sartem  *
42518c2aff7Sartem  *	NULL can mean:
42618c2aff7Sartem  *	 - the media doesn't exist
42718c2aff7Sartem  *	 - there is no more space for malloc(3)
42818c2aff7Sartem  *	 - the attribute doesn't exist for the named media
42918c2aff7Sartem  *	 - the attribute is a boolean and is FALSE
43018c2aff7Sartem  *
43118c2aff7Sartem  *	the pointer to the string must be free'd with free(3).
43218c2aff7Sartem  *
43318c2aff7Sartem  * preconditions:
43418c2aff7Sartem  *	volume management (vold) must be running.
43518c2aff7Sartem  */
43618c2aff7Sartem /* ARGSUSED */
43718c2aff7Sartem char *
media_getattr(char * vol_path,char * attr)43818c2aff7Sartem media_getattr(char *vol_path, char *attr)
43918c2aff7Sartem {
44018c2aff7Sartem 	return (NULL);
44118c2aff7Sartem }
44218c2aff7Sartem 
44318c2aff7Sartem 
44418c2aff7Sartem /*
44518c2aff7Sartem  * sets the attribute "attr" to value "value".
44618c2aff7Sartem  *
44718c2aff7Sartem  * If value == "" the flag is
44818c2aff7Sartem  * considered to be a TRUE boolean.
44918c2aff7Sartem  *
45018c2aff7Sartem  * If value == 0, it is considered to be a FALSE boolean.
45118c2aff7Sartem  * returns TRUE on success, FALSE on failure.
45218c2aff7Sartem  *
45318c2aff7Sartem  * Can fail for reasons of permission, or if you
45418c2aff7Sartem  * write a read-only attribute.
45518c2aff7Sartem  */
45618c2aff7Sartem 
45718c2aff7Sartem /*
45818c2aff7Sartem  * arc approved interface
45918c2aff7Sartem  *	- can not be modified without approval from an arc
46018c2aff7Sartem  *
46118c2aff7Sartem  * committment level:
46218c2aff7Sartem  *	public
46318c2aff7Sartem  *
46418c2aff7Sartem  * description:
46518c2aff7Sartem  *	media_setattr: set an attribute for a piece of media to a
46618c2aff7Sartem  *	particular value.
46718c2aff7Sartem  *
46818c2aff7Sartem  * arguments:
46918c2aff7Sartem  *	path - Path to the media in /vol.  Can be the block or character
47018c2aff7Sartem  *		device.
47118c2aff7Sartem  *
47218c2aff7Sartem  *	attr - name of the attribute.
47318c2aff7Sartem  *
47418c2aff7Sartem  *	value - value of the attribute.  If value == "", the flag is
47518c2aff7Sartem  *		considered to be a boolean that is TRUE.  If value == 0, it
47618c2aff7Sartem  *		is considered to be a FALSE boolean.
47718c2aff7Sartem  *
47818c2aff7Sartem  * return value(s):
47918c2aff7Sartem  *	TRUE on success, FALSE for failure.
48018c2aff7Sartem  *
48118c2aff7Sartem  *	Can fail because:
48218c2aff7Sartem  *		- don't have permission to set the attribute because caller
48318c2aff7Sartem  *		  is not the owner of the media and attribute is a "system"
48418c2aff7Sartem  *		  attribute.
48518c2aff7Sartem  *
48618c2aff7Sartem  *		- don't have permission to set the attribute because the
48718c2aff7Sartem  *		  attribute is a "system" attribute and is read-only.
48818c2aff7Sartem  *
48918c2aff7Sartem  * preconditions:
49018c2aff7Sartem  *	volume management must be running.
49118c2aff7Sartem  */
49218c2aff7Sartem /* ARGSUSED */
49318c2aff7Sartem int
media_setattr(char * vol_path,char * attr,char * value)49418c2aff7Sartem media_setattr(char *vol_path, char *attr, char *value)
49518c2aff7Sartem {
49618c2aff7Sartem 	return (FALSE);
49718c2aff7Sartem }
49818c2aff7Sartem 
49918c2aff7Sartem 
50018c2aff7Sartem /*
50118c2aff7Sartem  * Returns the "id" of a volume.  If the returned value
50218c2aff7Sartem  * & VOLID_TMP, the volume is temporary and this value
50318c2aff7Sartem  * cannot be relied upon across reboots.
50418c2aff7Sartem  */
50518c2aff7Sartem /*
50618c2aff7Sartem  * arc approved interface
50718c2aff7Sartem  *	- can not be modified without approval from an arc
50818c2aff7Sartem  *
50918c2aff7Sartem  * committment level:
51018c2aff7Sartem  *	public
51118c2aff7Sartem  *
51218c2aff7Sartem  * description:
51318c2aff7Sartem  *	media_getid: return the "id" of a piece of media.
51418c2aff7Sartem  *
51518c2aff7Sartem  * arguments:
51618c2aff7Sartem  *	path - Path to the media in /vol.  Can be the block or character
51718c2aff7Sartem  *		device.
51818c2aff7Sartem  * return value(s):
51918c2aff7Sartem  *	returns a u_longlong_t that is the "id" of the volume.
52018c2aff7Sartem  *
52118c2aff7Sartem  * preconditions:
52218c2aff7Sartem  *	volume management must be running.
52318c2aff7Sartem  */
52418c2aff7Sartem u_longlong_t
media_getid(char * vol_path)52518c2aff7Sartem media_getid(char *vol_path)
52618c2aff7Sartem {
52718c2aff7Sartem 	return (0);
52818c2aff7Sartem }
52918c2aff7Sartem /*
53018c2aff7Sartem  * arc approved interface (pending)
53118c2aff7Sartem  *	- can not be modified without approval from an arc
53218c2aff7Sartem  *
53318c2aff7Sartem  * committment level:
53418c2aff7Sartem  *	public
53518c2aff7Sartem  *
53618c2aff7Sartem  * description:
53718c2aff7Sartem  *	media_findname: try to come up with the character device when
53818c2aff7Sartem  *	provided with a starting point.  This interface provides the
53918c2aff7Sartem  *	application programmer to provide "user friendly" names and
54018c2aff7Sartem  *	easily determine the "/vol" name.
54118c2aff7Sartem  *
54218c2aff7Sartem  * arguments:
54318c2aff7Sartem  *	start - a string describing a device.  This string can be:
54418c2aff7Sartem  *		- a full path name to a device (insures it's a
54518c2aff7Sartem  *		  character device by using getfullrawname()).
54618c2aff7Sartem  *		- a full path name to a volume management media name
54718c2aff7Sartem  *		  with partitions (will return the lowest numbered
54818c2aff7Sartem  *		  raw partition.
54918c2aff7Sartem  *		- the name of a piece of media (e.g. "fred").
55018c2aff7Sartem  *		- a symbolic device name (e.g. floppy0, cdrom0, etc)
55118c2aff7Sartem  *		- a name like "floppy" or "cdrom".  Will pick the lowest
55218c2aff7Sartem  *		  numbered device with media in it.
55318c2aff7Sartem  *
55418c2aff7Sartem  * return value(s):
55518c2aff7Sartem  *	A pointer to a string that contains the character device
55618c2aff7Sartem  *	most appropriate to the "start" argument.
55718c2aff7Sartem  *
55818c2aff7Sartem  *	NULL indicates that we were unable to find media based on "start".
55918c2aff7Sartem  *
56018c2aff7Sartem  *	The string must be free(3)'d.
56118c2aff7Sartem  *
56218c2aff7Sartem  * preconditions:
56318c2aff7Sartem  *	none.
56418c2aff7Sartem  */
56518c2aff7Sartem /* ARGSUSED */
56618c2aff7Sartem char *
media_findname(char * start)56718c2aff7Sartem media_findname(char *start)
56818c2aff7Sartem {
569*b941d3fcSartem 	/*
570*b941d3fcSartem 	 * Eventually should implement using HAL interfaces.
571*b941d3fcSartem 	 * In the short term however, return NULL for aliases,
572*b941d3fcSartem 	 * and self for absolute pathnames.
573*b941d3fcSartem 	 */
574*b941d3fcSartem 	if (start[0] == '/') {
575*b941d3fcSartem 		return (strdup(start));
576*b941d3fcSartem 	} else {
57718c2aff7Sartem 		return (NULL);
57818c2aff7Sartem 	}
579*b941d3fcSartem }
58018c2aff7Sartem 
58118c2aff7Sartem struct alias {
58218c2aff7Sartem 	char	*alias;
58318c2aff7Sartem 	char	*name;
58418c2aff7Sartem };
58518c2aff7Sartem 
58618c2aff7Sartem /*
58718c2aff7Sartem  * "old" aliases -- used to be used when vold wasn't running
58818c2aff7Sartem  */
58918c2aff7Sartem static struct alias device_aliases[] = {
59018c2aff7Sartem 	{ "fd", "/dev/rdiskette" },
59118c2aff7Sartem 	{ "fd0", "/dev/rdiskette" },
59218c2aff7Sartem 	{ "fd1", "/dev/rdiskette1" },
59318c2aff7Sartem 	{ "diskette", "/dev/rdiskette" },
59418c2aff7Sartem 	{ "diskette0", "/dev/rdiskette0" },
59518c2aff7Sartem 	{ "diskette1", "/dev/rdiskette1" },
59618c2aff7Sartem 	{ "rdiskette", "/dev/rdiskette" },
59718c2aff7Sartem 	{ "rdiskette0", "/dev/rdiskette0" },
59818c2aff7Sartem 	{ "rdiskette1", "/dev/rdiskette1" },
59918c2aff7Sartem 	{ "floppy", "/dev/rdiskette" },
60018c2aff7Sartem 	{ "floppy0", "/dev/rdiskette0" },
60118c2aff7Sartem 	{ "floppy1", "/dev/rdiskette1" },
60218c2aff7Sartem 	{ "cd", "cdrom0" },
60318c2aff7Sartem 	{ "cd0", "cdrom0" },
60418c2aff7Sartem 	{ "cd1", "cdrom1" },
60518c2aff7Sartem 	{ NULL, NULL }
60618c2aff7Sartem };
60718c2aff7Sartem 
60818c2aff7Sartem /*
60918c2aff7Sartem  * This is an ON Consolidation Private interface.
61018c2aff7Sartem  */
61118c2aff7Sartem /* ARGSUSED */
61218c2aff7Sartem char *
_media_oldaliases(char * start)61318c2aff7Sartem _media_oldaliases(char *start)
61418c2aff7Sartem {
61518c2aff7Sartem 	struct alias	*s;
61618c2aff7Sartem 	char		*p;
61718c2aff7Sartem 	char		*res = NULL;
61818c2aff7Sartem 
61918c2aff7Sartem 	for (s = device_aliases; s->alias != NULL; s++) {
62018c2aff7Sartem 		if (strcmp(start, s->alias) == 0) {
62118c2aff7Sartem 			res = strdup(s->name);
62218c2aff7Sartem 			break;
62318c2aff7Sartem 		}
62418c2aff7Sartem 	}
62518c2aff7Sartem 
62618c2aff7Sartem 	return (res);
62718c2aff7Sartem }
62818c2aff7Sartem 
62918c2aff7Sartem 
63018c2aff7Sartem /*
63118c2aff7Sartem  * This is an ON Consolidation Private interface.
63218c2aff7Sartem  *
63318c2aff7Sartem  * Print out the aliases available to the program user.  Changes
63418c2aff7Sartem  * depending in whether volume management is running.
63518c2aff7Sartem  */
63618c2aff7Sartem void
_media_printaliases(void)63718c2aff7Sartem _media_printaliases(void)
63818c2aff7Sartem {
63918c2aff7Sartem }
640