xref: /illumos-gate/usr/src/cmd/rmvolmgr/rmm_common.h (revision 60a3f738d56f92ae8b80e4b62a2331c6e1f2311f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_COMMON_H
27 #define	_COMMON_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/types.h>
36 #include <unistd.h>
37 #include <zone.h>
38 
39 #include <glib.h>
40 #include <libhal.h>
41 #include <libhal-storage.h>
42 
43 #include "vold.h"
44 
45 typedef enum {
46 	RMM_EOK = 0,
47 	RMM_EDBUS_CONNECT,	/* cannot connect to DBUS */
48 	RMM_EHAL_CONNECT	/* cannot connect to HAL */
49 } rmm_error_t;
50 
51 #define	HAL_BRANCH_LOCAL	"/org/freedesktop/Hal/devices/local"
52 
53 #define	NELEM(a)	(sizeof (a) / sizeof (*(a)))
54 
55 extern char *progname;
56 
57 LibHalContext	*rmm_hal_init(LibHalDeviceAdded, LibHalDeviceRemoved,
58 		LibHalDevicePropertyModified, DBusError *, rmm_error_t *);
59 void		rmm_hal_fini(LibHalContext *hal_ctx);
60 
61 LibHalDrive	*rmm_hal_volume_find(LibHalContext *, const char *,
62 		DBusError *, GSList **);
63 LibHalDrive	*rmm_hal_volume_find_default(LibHalContext *, DBusError *,
64 		const char **, GSList **);
65 LibHalDrive	*rmm_hal_volume_findby(LibHalContext *, const char *,
66 		const char *, GSList **);
67 LibHalDrive	*rmm_hal_volume_findby_nickname(LibHalContext *, const char *,
68 		GSList **);
69 void		rmm_print_volume_nicknames(LibHalContext *, DBusError *);
70 void		rmm_volumes_free(GSList *);
71 
72 boolean_t	rmm_hal_mount(LibHalContext *, const char *,
73 		char **, int, char *, DBusError *);
74 boolean_t	rmm_hal_unmount(LibHalContext *, const char *, DBusError *);
75 boolean_t	rmm_hal_eject(LibHalContext *, const char *, DBusError *);
76 boolean_t	rmm_hal_closetray(LibHalContext *, const char *, DBusError *);
77 boolean_t	rmm_hal_rescan(LibHalContext *, const char *, DBusError *);
78 boolean_t	rmm_hal_claim_branch(LibHalContext *, const char *);
79 boolean_t	rmm_hal_unclaim_branch(LibHalContext *, const char *);
80 
81 boolean_t	rmm_action(LibHalContext *, const char *name, action_t action,
82 		struct action_arg *aap, char **, int, char *);
83 boolean_t	rmm_rescan(LibHalContext *, const char *, boolean_t);
84 
85 void		rmm_update_vold_mountpoints(LibHalContext *, const char *,
86 		struct action_arg *);
87 
88 boolean_t	rmm_volume_aa_from_prop(LibHalContext *, const char *,
89 		LibHalVolume *, struct action_arg *);
90 void		rmm_volume_aa_update_mountpoint(LibHalContext *, const char *,
91 		struct action_arg *aap);
92 void		rmm_volume_aa_free(struct action_arg *);
93 
94 char		*rmm_get_mnttab_mount_point(const char *);
95 const char	*rmm_strerror(DBusError *, int);
96 void		rmm_dbus_error_free(DBusError *);
97 
98 char		*rmm_vold_convert_volume_label(const char *name, size_t len);
99 int		makepath(char *, mode_t);
100 void		dprintf(const char *, ...);
101 
102 #ifdef	__cplusplus
103 }
104 #endif
105 
106 #endif	/* _COMMON_H */
107