xref: /titanic_52/usr/src/cmd/rmvolmgr/rmm_common.h (revision 14ea4bb737263733ad80a36b4f73f681c30a6b45)
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 enum {
52 	RMM_PRINT_MOUNTABLE	= 0x1,
53 	RMM_PRINT_EJECTABLE	= 0x2
54 };
55 
56 #define	HAL_BRANCH_LOCAL	"/org/freedesktop/Hal/devices/local"
57 
58 #define	NELEM(a)	(sizeof (a) / sizeof (*(a)))
59 
60 extern char *progname;
61 
62 LibHalContext	*rmm_hal_init(LibHalDeviceAdded, LibHalDeviceRemoved,
63 		LibHalDevicePropertyModified, DBusError *, rmm_error_t *);
64 void		rmm_hal_fini(LibHalContext *hal_ctx);
65 
66 LibHalDrive	*rmm_hal_volume_find(LibHalContext *, const char *,
67 		DBusError *, GSList **);
68 LibHalDrive	*rmm_hal_volume_find_default(LibHalContext *, DBusError *,
69 		const char **, GSList **);
70 LibHalDrive	*rmm_hal_volume_findby(LibHalContext *, const char *,
71 		const char *, GSList **);
72 LibHalDrive	*rmm_hal_volume_findby_nickname(LibHalContext *, const char *,
73 		GSList **);
74 void		rmm_print_volume_nicknames(LibHalContext *, DBusError *, int);
75 void		rmm_volumes_free(GSList *);
76 
77 boolean_t	rmm_hal_mount(LibHalContext *, const char *,
78 		char **, int, char *, DBusError *);
79 boolean_t	rmm_hal_unmount(LibHalContext *, const char *, DBusError *);
80 boolean_t	rmm_hal_eject(LibHalContext *, const char *, DBusError *);
81 boolean_t	rmm_hal_closetray(LibHalContext *, const char *, DBusError *);
82 boolean_t	rmm_hal_rescan(LibHalContext *, const char *, DBusError *);
83 boolean_t	rmm_hal_claim_branch(LibHalContext *, const char *);
84 boolean_t	rmm_hal_unclaim_branch(LibHalContext *, const char *);
85 
86 boolean_t	rmm_action(LibHalContext *, const char *name, action_t action,
87 		struct action_arg *aap, char **, int, char *);
88 boolean_t	rmm_rescan(LibHalContext *, const char *, boolean_t);
89 
90 void		rmm_update_vold_mountpoints(LibHalContext *, const char *,
91 		struct action_arg *);
92 
93 boolean_t	rmm_volume_aa_from_prop(LibHalContext *, const char *,
94 		LibHalVolume *, struct action_arg *);
95 void		rmm_volume_aa_update_mountpoint(LibHalContext *, const char *,
96 		struct action_arg *aap);
97 void		rmm_volume_aa_free(struct action_arg *);
98 
99 char		*rmm_get_mnttab_mount_point(const char *);
100 const char	*rmm_strerror(DBusError *, int);
101 void		rmm_dbus_error_free(DBusError *);
102 
103 char		*rmm_vold_convert_volume_label(const char *name, size_t len);
104 int		makepath(char *, mode_t);
105 void		dprintf(const char *, ...);
106 
107 #ifdef	__cplusplus
108 }
109 #endif
110 
111 #endif	/* _COMMON_H */
112