xref: /titanic_50/usr/src/cmd/rmvolmgr/rmm_common.h (revision 0ebe310024a809595007753781dc9969750affbc)
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 /*
2218c2aff7Sartem  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
2318c2aff7Sartem  * Use is subject to license terms.
2418c2aff7Sartem  */
2518c2aff7Sartem 
2618c2aff7Sartem #ifndef	_COMMON_H
2718c2aff7Sartem #define	_COMMON_H
2818c2aff7Sartem 
2918c2aff7Sartem #pragma ident	"%Z%%M%	%I%	%E% SMI"
3018c2aff7Sartem 
3118c2aff7Sartem #ifdef	__cplusplus
3218c2aff7Sartem extern "C" {
3318c2aff7Sartem #endif
3418c2aff7Sartem 
3518c2aff7Sartem #include <sys/types.h>
3618c2aff7Sartem #include <unistd.h>
3718c2aff7Sartem #include <zone.h>
3818c2aff7Sartem 
3918c2aff7Sartem #include <glib.h>
4018c2aff7Sartem #include <libhal.h>
4118c2aff7Sartem #include <libhal-storage.h>
4218c2aff7Sartem 
4318c2aff7Sartem #include "vold.h"
4418c2aff7Sartem 
4518c2aff7Sartem typedef enum {
4618c2aff7Sartem 	RMM_EOK = 0,
4718c2aff7Sartem 	RMM_EDBUS_CONNECT,	/* cannot connect to DBUS */
4818c2aff7Sartem 	RMM_EHAL_CONNECT	/* cannot connect to HAL */
4918c2aff7Sartem } rmm_error_t;
5018c2aff7Sartem 
51*0ebe3100Sartem enum {
52*0ebe3100Sartem 	RMM_PRINT_MOUNTABLE	= 0x1,
53*0ebe3100Sartem 	RMM_PRINT_EJECTABLE	= 0x2
54*0ebe3100Sartem };
55*0ebe3100Sartem 
5618c2aff7Sartem #define	HAL_BRANCH_LOCAL	"/org/freedesktop/Hal/devices/local"
5718c2aff7Sartem 
5818c2aff7Sartem #define	NELEM(a)	(sizeof (a) / sizeof (*(a)))
5918c2aff7Sartem 
6018c2aff7Sartem extern char *progname;
6118c2aff7Sartem 
6218c2aff7Sartem LibHalContext	*rmm_hal_init(LibHalDeviceAdded, LibHalDeviceRemoved,
6318c2aff7Sartem 		LibHalDevicePropertyModified, DBusError *, rmm_error_t *);
6418c2aff7Sartem void		rmm_hal_fini(LibHalContext *hal_ctx);
6518c2aff7Sartem 
6618c2aff7Sartem LibHalDrive	*rmm_hal_volume_find(LibHalContext *, const char *,
6718c2aff7Sartem 		DBusError *, GSList **);
6818c2aff7Sartem LibHalDrive	*rmm_hal_volume_find_default(LibHalContext *, DBusError *,
6918c2aff7Sartem 		const char **, GSList **);
7018c2aff7Sartem LibHalDrive	*rmm_hal_volume_findby(LibHalContext *, const char *,
7118c2aff7Sartem 		const char *, GSList **);
7218c2aff7Sartem LibHalDrive	*rmm_hal_volume_findby_nickname(LibHalContext *, const char *,
7318c2aff7Sartem 		GSList **);
74*0ebe3100Sartem void		rmm_print_volume_nicknames(LibHalContext *, DBusError *, int);
7518c2aff7Sartem void		rmm_volumes_free(GSList *);
7618c2aff7Sartem 
7718c2aff7Sartem boolean_t	rmm_hal_mount(LibHalContext *, const char *,
7818c2aff7Sartem 		char **, int, char *, DBusError *);
7918c2aff7Sartem boolean_t	rmm_hal_unmount(LibHalContext *, const char *, DBusError *);
8018c2aff7Sartem boolean_t	rmm_hal_eject(LibHalContext *, const char *, DBusError *);
8118c2aff7Sartem boolean_t	rmm_hal_closetray(LibHalContext *, const char *, DBusError *);
8218c2aff7Sartem boolean_t	rmm_hal_rescan(LibHalContext *, const char *, DBusError *);
8318c2aff7Sartem boolean_t	rmm_hal_claim_branch(LibHalContext *, const char *);
8418c2aff7Sartem boolean_t	rmm_hal_unclaim_branch(LibHalContext *, const char *);
8518c2aff7Sartem 
8618c2aff7Sartem boolean_t	rmm_action(LibHalContext *, const char *name, action_t action,
8718c2aff7Sartem 		struct action_arg *aap, char **, int, char *);
8818c2aff7Sartem boolean_t	rmm_rescan(LibHalContext *, const char *, boolean_t);
8918c2aff7Sartem 
9018c2aff7Sartem void		rmm_update_vold_mountpoints(LibHalContext *, const char *,
9118c2aff7Sartem 		struct action_arg *);
9218c2aff7Sartem 
9318c2aff7Sartem boolean_t	rmm_volume_aa_from_prop(LibHalContext *, const char *,
9418c2aff7Sartem 		LibHalVolume *, struct action_arg *);
9518c2aff7Sartem void		rmm_volume_aa_update_mountpoint(LibHalContext *, const char *,
9618c2aff7Sartem 		struct action_arg *aap);
9718c2aff7Sartem void		rmm_volume_aa_free(struct action_arg *);
9818c2aff7Sartem 
9918c2aff7Sartem char		*rmm_get_mnttab_mount_point(const char *);
10018c2aff7Sartem const char	*rmm_strerror(DBusError *, int);
10118c2aff7Sartem void		rmm_dbus_error_free(DBusError *);
10218c2aff7Sartem 
10318c2aff7Sartem char		*rmm_vold_convert_volume_label(const char *name, size_t len);
10418c2aff7Sartem int		makepath(char *, mode_t);
10518c2aff7Sartem void		dprintf(const char *, ...);
10618c2aff7Sartem 
10718c2aff7Sartem #ifdef	__cplusplus
10818c2aff7Sartem }
10918c2aff7Sartem #endif
11018c2aff7Sartem 
11118c2aff7Sartem #endif	/* _COMMON_H */
112