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*97ddcdceSArtem Kachitchkine * Copyright 2009 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 #ifdef __cplusplus 3018c2aff7Sartem extern "C" { 3118c2aff7Sartem #endif 3218c2aff7Sartem 3318c2aff7Sartem #include <sys/types.h> 3418c2aff7Sartem #include <unistd.h> 3518c2aff7Sartem #include <zone.h> 3618c2aff7Sartem 3718c2aff7Sartem #include <glib.h> 3818c2aff7Sartem #include <libhal.h> 3918c2aff7Sartem #include <libhal-storage.h> 4018c2aff7Sartem 4118c2aff7Sartem #include "vold.h" 4218c2aff7Sartem 4318c2aff7Sartem typedef enum { 4418c2aff7Sartem RMM_EOK = 0, 4518c2aff7Sartem RMM_EDBUS_CONNECT, /* cannot connect to DBUS */ 4618c2aff7Sartem RMM_EHAL_CONNECT /* cannot connect to HAL */ 4718c2aff7Sartem } rmm_error_t; 4818c2aff7Sartem 490ebe3100Sartem enum { 500ebe3100Sartem RMM_PRINT_MOUNTABLE = 0x1, 510ebe3100Sartem RMM_PRINT_EJECTABLE = 0x2 520ebe3100Sartem }; 530ebe3100Sartem 54b941d3fcSartem /* D-Bus timeout in milliseconds */ 55b941d3fcSartem enum { 56b941d3fcSartem RMM_MOUNT_TIMEOUT = 60000, 57b941d3fcSartem RMM_UNMOUNT_TIMEOUT = 60000, 58b941d3fcSartem RMM_EJECT_TIMEOUT = 60000, 59b941d3fcSartem RMM_CLOSETRAY_TIMEOUT = 60000 60b941d3fcSartem }; 61b941d3fcSartem 6218c2aff7Sartem #define HAL_BRANCH_LOCAL "/org/freedesktop/Hal/devices/local" 6318c2aff7Sartem 6418c2aff7Sartem #define NELEM(a) (sizeof (a) / sizeof (*(a))) 6518c2aff7Sartem 6618c2aff7Sartem extern char *progname; 6718c2aff7Sartem 6818c2aff7Sartem LibHalContext *rmm_hal_init(LibHalDeviceAdded, LibHalDeviceRemoved, 69*97ddcdceSArtem Kachitchkine LibHalDevicePropertyModified, LibHalDeviceCondition, 70*97ddcdceSArtem Kachitchkine DBusError *, rmm_error_t *); 7118c2aff7Sartem void rmm_hal_fini(LibHalContext *hal_ctx); 7218c2aff7Sartem 7318c2aff7Sartem LibHalDrive *rmm_hal_volume_find(LibHalContext *, const char *, 7418c2aff7Sartem DBusError *, GSList **); 7518c2aff7Sartem LibHalDrive *rmm_hal_volume_find_default(LibHalContext *, DBusError *, 7618c2aff7Sartem const char **, GSList **); 7718c2aff7Sartem LibHalDrive *rmm_hal_volume_findby(LibHalContext *, const char *, 7818c2aff7Sartem const char *, GSList **); 7918c2aff7Sartem LibHalDrive *rmm_hal_volume_findby_nickname(LibHalContext *, const char *, 8018c2aff7Sartem GSList **); 810ebe3100Sartem void rmm_print_volume_nicknames(LibHalContext *, DBusError *, int); 8218c2aff7Sartem void rmm_volumes_free(GSList *); 8318c2aff7Sartem 8418c2aff7Sartem boolean_t rmm_hal_mount(LibHalContext *, const char *, 8518c2aff7Sartem char **, int, char *, DBusError *); 8618c2aff7Sartem boolean_t rmm_hal_unmount(LibHalContext *, const char *, DBusError *); 8718c2aff7Sartem boolean_t rmm_hal_eject(LibHalContext *, const char *, DBusError *); 8818c2aff7Sartem boolean_t rmm_hal_closetray(LibHalContext *, const char *, DBusError *); 8918c2aff7Sartem boolean_t rmm_hal_rescan(LibHalContext *, const char *, DBusError *); 9018c2aff7Sartem boolean_t rmm_hal_claim_branch(LibHalContext *, const char *); 9118c2aff7Sartem boolean_t rmm_hal_unclaim_branch(LibHalContext *, const char *); 9218c2aff7Sartem 9318c2aff7Sartem boolean_t rmm_action(LibHalContext *, const char *name, action_t action, 9418c2aff7Sartem struct action_arg *aap, char **, int, char *); 9518c2aff7Sartem boolean_t rmm_rescan(LibHalContext *, const char *, boolean_t); 9618c2aff7Sartem 9718c2aff7Sartem void rmm_update_vold_mountpoints(LibHalContext *, const char *, 9818c2aff7Sartem struct action_arg *); 9918c2aff7Sartem 10018c2aff7Sartem boolean_t rmm_volume_aa_from_prop(LibHalContext *, const char *, 10118c2aff7Sartem LibHalVolume *, struct action_arg *); 10218c2aff7Sartem void rmm_volume_aa_update_mountpoint(LibHalContext *, const char *, 10318c2aff7Sartem struct action_arg *aap); 10418c2aff7Sartem void rmm_volume_aa_free(struct action_arg *); 10518c2aff7Sartem 10618c2aff7Sartem char *rmm_get_mnttab_mount_point(const char *); 10718c2aff7Sartem const char *rmm_strerror(DBusError *, int); 10818c2aff7Sartem void rmm_dbus_error_free(DBusError *); 10918c2aff7Sartem 11018c2aff7Sartem char *rmm_vold_convert_volume_label(const char *name, size_t len); 11118c2aff7Sartem int makepath(char *, mode_t); 11218c2aff7Sartem void dprintf(const char *, ...); 11318c2aff7Sartem 11418c2aff7Sartem #ifdef __cplusplus 11518c2aff7Sartem } 11618c2aff7Sartem #endif 11718c2aff7Sartem 11818c2aff7Sartem #endif /* _COMMON_H */ 119