HAL Storage and Volumes library

HAL Storage and Volumes library. More...

Data Structures

struct  IconMappingEntry_s
struct  LibHalStoragePolicy_s
struct  LibHalDrive_s
struct  LibHalVolume_s

Defines

#define MAX_STRING_SZ   256
#define MOUNT_OPTIONS_SIZE   256
#define LIBHAL_PROP_EXTRACT_BEGIN   if (FALSE)
#define LIBHAL_PROP_EXTRACT_END   ;
#define LIBHAL_PROP_EXTRACT_INT(_property_, _where_)   else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_INT32) _where_ = libhal_psi_get_int (&it)
#define LIBHAL_PROP_EXTRACT_UINT64(_property_, _where_)   else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_UINT64) _where_ = libhal_psi_get_uint64 (&it)
#define LIBHAL_PROP_EXTRACT_STRING(_property_, _where_)   else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_STRING) _where_ = (libhal_psi_get_string (&it) != NULL && strlen (libhal_psi_get_string (&it)) > 0) ? strdup (libhal_psi_get_string (&it)) : NULL
#define LIBHAL_PROP_EXTRACT_BOOL(_property_, _where_)   else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_BOOLEAN) _where_ = libhal_psi_get_bool (&it)
#define LIBHAL_PROP_EXTRACT_BOOL_BITFIELD(_property_, _where_, _field_)   else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_BOOLEAN) _where_ |= libhal_psi_get_bool (&it) ? _field_ : 0
#define LIBHAL_PROP_EXTRACT_STRLIST(_property_, _where_)   else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_STRLIST) _where_ = my_strvdup (libhal_psi_get_strlist (&it))
#define strcat_len(dst, src, dstmaxlen)

Typedefs

typedef IconMappingEntry_s IconMappingEntry
 typdef of IconMappingEntry_s

Functions

LibHalStoragePolicy * libhal_storage_policy_new ()
void libhal_storage_policy_free (LibHalStoragePolicy *policy)
void libhal_storage_policy_set_icon_path (LibHalStoragePolicy *policy, LibHalStoragePolicyIcon icon, const char *path)
void libhal_storage_policy_set_icon_mapping (LibHalStoragePolicy *policy, LibHalStoragePolicyIconPair *pairs)
const char * libhal_storage_policy_lookup_icon (LibHalStoragePolicy *policy, LibHalStoragePolicyIcon icon)
char * libhal_volume_policy_compute_size_as_string (LibHalVolume *volume)
static void fixup_string (char *s)
char * libhal_drive_policy_compute_display_name (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
char * libhal_volume_policy_compute_display_name (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
char * libhal_drive_policy_compute_icon_name (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
char * libhal_volume_policy_compute_icon_name (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
dbus_bool_t libhal_volume_policy_should_be_visible (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy, const char *target_mount_point)
 Policy function to determine if a volume should be visible in a desktop environment.
const char * libhal_drive_get_dedicated_icon_drive (LibHalDrive *drive)
const char * libhal_drive_get_dedicated_icon_volume (LibHalDrive *drive)
void libhal_drive_free (LibHalDrive *drive)
 Free all resources used by a LibHalDrive object.
void libhal_volume_free (LibHalVolume *vol)
 Free all resources used by a LibHalVolume object.
static char ** my_strvdup (char **strv)
LibHalDrive * libhal_drive_from_udi (LibHalContext *hal_ctx, const char *udi)
 Given a UDI for a HAL device of capability 'storage', this function retrieves all the relevant properties into convenient in-process data structures.
const char * libhal_volume_get_storage_device_udi (LibHalVolume *volume)
const char * libhal_drive_get_physical_device_udi (LibHalDrive *drive)
dbus_bool_t libhal_drive_requires_eject (LibHalDrive *drive)
LibHalVolume * libhal_volume_from_udi (LibHalContext *hal_ctx, const char *udi)
 Given a UDI for a LIBHAL device of capability 'volume', this function retrieves all the relevant properties into convenient in-process data structures.
int libhal_volume_get_msdos_part_table_type (LibHalVolume *volume)
 If the volume is on a drive with a MSDOS style partition table, return the partition table id.
LibHalDrive * libhal_drive_from_device_file (LibHalContext *hal_ctx, const char *device_file)
 Get the drive object that either is (when given e.g.
LibHalVolume * libhal_volume_from_device_file (LibHalContext *hal_ctx, const char *device_file)
 Get the volume object for a given device file.
dbus_uint64_t libhal_volume_get_size (LibHalVolume *volume)
dbus_uint64_t libhal_volume_get_disc_capacity (LibHalVolume *volume)
dbus_bool_t libhal_drive_is_hotpluggable (LibHalDrive *drive)
dbus_bool_t libhal_drive_uses_removable_media (LibHalDrive *drive)
LibHalDriveType libhal_drive_get_type (LibHalDrive *drive)
LibHalDriveBus libhal_drive_get_bus (LibHalDrive *drive)
LibHalDriveCdromCaps libhal_drive_get_cdrom_caps (LibHalDrive *drive)
unsigned int libhal_drive_get_device_major (LibHalDrive *drive)
unsigned int libhal_drive_get_device_minor (LibHalDrive *drive)
const char * libhal_drive_get_type_textual (LibHalDrive *drive)
const char * libhal_drive_get_device_file (LibHalDrive *drive)
const char * libhal_drive_get_udi (LibHalDrive *drive)
const char * libhal_drive_get_serial (LibHalDrive *drive)
const char * libhal_drive_get_firmware_version (LibHalDrive *drive)
const char * libhal_drive_get_model (LibHalDrive *drive)
const char * libhal_drive_get_vendor (LibHalDrive *drive)
const char * libhal_volume_get_udi (LibHalVolume *volume)
const char * libhal_volume_get_device_file (LibHalVolume *volume)
unsigned int libhal_volume_get_device_major (LibHalVolume *volume)
unsigned int libhal_volume_get_device_minor (LibHalVolume *volume)
const char * libhal_volume_get_fstype (LibHalVolume *volume)
const char * libhal_volume_get_fsversion (LibHalVolume *volume)
LibHalVolumeUsage libhal_volume_get_fsusage (LibHalVolume *volume)
dbus_bool_t libhal_volume_is_mounted (LibHalVolume *volume)
dbus_bool_t libhal_volume_is_partition (LibHalVolume *volume)
dbus_bool_t libhal_volume_is_disc (LibHalVolume *volume)
unsigned int libhal_volume_get_partition_number (LibHalVolume *volume)
const char * libhal_volume_get_label (LibHalVolume *volume)
const char * libhal_volume_get_mount_point (LibHalVolume *volume)
const char * libhal_volume_get_uuid (LibHalVolume *volume)
dbus_bool_t libhal_volume_disc_has_audio (LibHalVolume *volume)
dbus_bool_t libhal_volume_disc_has_data (LibHalVolume *volume)
dbus_bool_t libhal_volume_disc_is_blank (LibHalVolume *volume)
dbus_bool_t libhal_volume_disc_is_rewritable (LibHalVolume *volume)
dbus_bool_t libhal_volume_disc_is_appendable (LibHalVolume *volume)
LibHalVolumeDiscType libhal_volume_get_disc_type (LibHalVolume *volume)
dbus_bool_t libhal_volume_should_ignore (LibHalVolume *volume)
char ** libhal_drive_find_all_volumes (LibHalContext *hal_ctx, LibHalDrive *drive, int *num_volumes)
const char * libhal_volume_crypto_get_backing_volume_udi (LibHalVolume *volume)
char * libhal_volume_crypto_get_clear_volume_udi (LibHalContext *hal_ctx, LibHalVolume *volume)
char * libhal_drive_policy_default_get_mount_root (LibHalContext *hal_ctx)
dbus_bool_t libhal_drive_policy_default_use_managed_keyword (LibHalContext *hal_ctx)
char * libhal_drive_policy_default_get_managed_keyword_primary (LibHalContext *hal_ctx)
char * libhal_drive_policy_default_get_managed_keyword_secondary (LibHalContext *hal_ctx)
dbus_bool_t libhal_drive_policy_is_mountable (LibHalDrive *drive, LibHalStoragePolicy *policy)
const char * libhal_drive_policy_get_desired_mount_point (LibHalDrive *drive, LibHalStoragePolicy *policy)
static void mopts_collect (LibHalContext *hal_ctx, const char *namespace, int namespace_len, const char *udi, char *options_string, size_t options_max_len, dbus_bool_t only_collect_imply_opts)
const char * libhal_drive_policy_get_mount_options (LibHalDrive *drive, LibHalStoragePolicy *policy)
const char * libhal_drive_policy_get_mount_fs (LibHalDrive *drive, LibHalStoragePolicy *policy)
dbus_bool_t libhal_volume_policy_is_mountable (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
const char * libhal_volume_policy_get_desired_mount_point (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
const char * libhal_volume_policy_get_mount_options (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
const char * libhal_volume_policy_get_mount_fs (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
dbus_bool_t libhal_drive_no_partitions_hint (LibHalDrive *drive)

Detailed Description

HAL Storage and Volumes library.


Define Documentation

#define strcat_len ( dst,
src,
dstmaxlen   ) 

Value:

do {    \
    dst[dstmaxlen - 1] = '\0'; \
    strncat (dst, src, dstmaxlen - strlen (dst) - 1); \
} while(0)

Definition at line 1706 of file libhal-storage.c.

Referenced by mopts_collect().


Function Documentation

void libhal_drive_free ( LibHalDrive *  drive  ) 

Free all resources used by a LibHalDrive object.

Parameters:
drive Object to free

Definition at line 791 of file libhal-storage.c.

References libhal_free_string(), and libhal_free_string_array().

LibHalDrive* libhal_drive_from_device_file ( LibHalContext *  hal_ctx,
const char *  device_file 
)

Get the drive object that either is (when given e.g.

/dev/sdb) or contains (when given e.g. /dev/sdb1) the given device file.

Parameters:
hal_ctx libhal context to use
device_file Name of special device file, e.g. '/dev/hdc'
Returns:
LibHalDrive object or NULL if it doesn't exist

Definition at line 1235 of file libhal-storage.c.

References libhal_device_get_property_string(), libhal_device_query_capability(), libhal_drive_from_udi(), libhal_free_string(), libhal_free_string_array(), and libhal_manager_find_device_string_match().

LibHalDrive* libhal_drive_from_udi ( LibHalContext *  hal_ctx,
const char *  udi 
)

Given a UDI for a HAL device of capability 'storage', this function retrieves all the relevant properties into convenient in-process data structures.

Parameters:
hal_ctx libhal context
udi HAL UDI
Returns:
LibHalDrive object or NULL if UDI is invalid

Definition at line 879 of file libhal-storage.c.

References libhal_device_get_all_properties(), libhal_device_query_capability(), LIBHAL_PROP_EXTRACT_BEGIN, LIBHAL_PROP_EXTRACT_BOOL, LIBHAL_PROP_EXTRACT_BOOL_BITFIELD, LIBHAL_PROP_EXTRACT_END, LIBHAL_PROP_EXTRACT_INT, LIBHAL_PROP_EXTRACT_STRING, LIBHAL_PROP_EXTRACT_STRLIST, libhal_psi_get_key(), libhal_psi_get_type(), libhal_psi_has_more(), libhal_psi_init(), and libhal_psi_next().

Referenced by libhal_drive_from_device_file().

void libhal_volume_free ( LibHalVolume *  vol  ) 

Free all resources used by a LibHalVolume object.

Parameters:
vol Object to free

Definition at line 817 of file libhal-storage.c.

References libhal_free_string().

Referenced by libhal_volume_from_udi().

LibHalVolume* libhal_volume_from_device_file ( LibHalContext *  hal_ctx,
const char *  device_file 
)

Get the volume object for a given device file.

Parameters:
hal_ctx libhal context to use
device_file Name of special device file, e.g. '/dev/hda5'
Returns:
LibHalVolume object or NULL if it doesn't exist

Definition at line 1294 of file libhal-storage.c.

References libhal_device_query_capability(), libhal_free_string_array(), libhal_manager_find_device_string_match(), and libhal_volume_from_udi().

LibHalVolume* libhal_volume_from_udi ( LibHalContext *  hal_ctx,
const char *  udi 
)

Given a UDI for a LIBHAL device of capability 'volume', this function retrieves all the relevant properties into convenient in-process data structures.

Parameters:
hal_ctx libhal context
udi HAL UDI
Returns:
LibHalVolume object or NULL if UDI is invalid

Definition at line 1067 of file libhal-storage.c.

References libhal_device_get_all_properties(), libhal_device_query_capability(), libhal_free_property_set(), libhal_free_string(), LIBHAL_PROP_EXTRACT_BEGIN, LIBHAL_PROP_EXTRACT_BOOL, LIBHAL_PROP_EXTRACT_END, LIBHAL_PROP_EXTRACT_INT, LIBHAL_PROP_EXTRACT_STRING, LIBHAL_PROP_EXTRACT_UINT64, libhal_psi_get_key(), libhal_psi_get_type(), libhal_psi_has_more(), libhal_psi_init(), libhal_psi_next(), and libhal_volume_free().

Referenced by libhal_volume_from_device_file().

int libhal_volume_get_msdos_part_table_type ( LibHalVolume *  volume  ) 

If the volume is on a drive with a MSDOS style partition table, return the partition table id.

Parameters:
volume Volume object
Returns:
The partition type or -1 if volume is not a partition or the media the volume stems from isn't partition with a MS DOS style table

Definition at line 1220 of file libhal-storage.c.

dbus_bool_t libhal_volume_policy_should_be_visible ( LibHalDrive *  drive,
LibHalVolume *  volume,
LibHalStoragePolicy *  policy,
const char *  target_mount_point 
)

Policy function to determine if a volume should be visible in a desktop environment.

This is useful to hide certain system volumes as bootstrap partitions, the /usr partition, swap partitions and other volumes that a unprivileged desktop user shouldn't know even exists.

Parameters:
drive Drive that the volume is stemming from
volume Volume
policy Policy object
target_mount_point The mount point that the volume is expected to be mounted at if not already mounted. This may e.g. stem from /etc/fstab. If this is NULL the then mount point isn't taking into account when evaluating whether the volume should be visible
Returns:
Whether the volume should be shown in a desktop environment.

Definition at line 616 of file libhal-storage.c.

References libhal_volume_get_fstype(), libhal_volume_get_fsusage(), libhal_volume_get_label(), and libhal_volume_get_mount_point().


Generated on Thu Sep 14 14:45:13 2006 for HAL by  doxygen 1.4.7