HAL: libhal-storage.h Source File

Main Page | Modules | Data Structures | Directories | File List | Data Fields | Related Pages

# libhal-storage.h

    00001 /***************************************************************************
    00002  * CVSID: $Id: libhal-storage.h,v 1.6.2.2 2004/12/01 04:28:58 david Exp $
    00003  *
    00004  * libhal-storage.h : HAL convenience library for storage devices and volumes
    00005  *
    00006  * Copyright (C) 2004 Red Hat, Inc.
    00007  *
    00008  * Author: David Zeuthen <davidz@redhat.com>
    00009  *
    00010  * Licensed under the Academic Free License version 2.0
    00011  *
    00012  * This program is free software; you can redistribute it and/or modify
    00013  * it under the terms of the GNU General Public License as published by
    00014  * the Free Software Foundation; either version 2 of the License, or
    00015  * (at your option) any later version.
    00016  *
    00017  * This program is distributed in the hope that it will be useful,
    00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00020  * GNU General Public License for more details.
    00021  *
    00022  * You should have received a copy of the GNU General Public License
    00023  * along with this program; if not, write to the Free Software
    00024  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00025  *
    00026  **************************************************************************/
    00027
    00028 #ifndef LIBHAL_STORAGE_H
    00029 #define LIBHAL_STORAGE_H
    00030
    00031 #include <libhal.h>
    00032
    00033 #if defined(__cplusplus)
    00034 extern "C" {
    00035 #endif
    00036
    00043 #ifndef DOXYGEN_SHOULD_SKIP_THIS
    00044 struct HalDrive_s;
    00045 typedef struct HalDrive_s HalDrive;
    00046 struct HalVolume_s;
    00047 typedef struct HalVolume_s HalVolume;
    00048 struct HalStoragePolicy_s;
    00049 typedef struct HalStoragePolicy_s HalStoragePolicy;
    00050 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
    00051
    00052
    00053 typedef enum {
    00054     HAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK           = 0x10000,
    00055     HAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_IDE       = 0x10001,
    00056     HAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_SCSI      = 0x10002,
    00057     HAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_USB       = 0x10003,
    00058     HAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_IEEE1394  = 0x10004,
    00059     HAL_STORAGE_ICON_DRIVE_DISK                     = 0x10100,
    00060     HAL_STORAGE_ICON_DRIVE_DISK_IDE                 = 0x10101,
    00061     HAL_STORAGE_ICON_DRIVE_DISK_SCSI                = 0x10102,
    00062     HAL_STORAGE_ICON_DRIVE_DISK_USB                 = 0x10103,
    00063     HAL_STORAGE_ICON_DRIVE_DISK_IEEE1394            = 0x10104,
    00064     HAL_STORAGE_ICON_DRIVE_CDROM                    = 0x10200,
    00065     HAL_STORAGE_ICON_DRIVE_CDROM_IDE                = 0x10201,
    00066     HAL_STORAGE_ICON_DRIVE_CDROM_SCSI               = 0x10202,
    00067     HAL_STORAGE_ICON_DRIVE_CDROM_USB                = 0x10203,
    00068     HAL_STORAGE_ICON_DRIVE_CDROM_IEEE1394           = 0x10204,
    00069     HAL_STORAGE_ICON_DRIVE_FLOPPY                   = 0x10300,
    00070     HAL_STORAGE_ICON_DRIVE_FLOPPY_IDE               = 0x10301,
    00071     HAL_STORAGE_ICON_DRIVE_FLOPPY_SCSI              = 0x10302,
    00072     HAL_STORAGE_ICON_DRIVE_FLOPPY_USB               = 0x10303,
    00073     HAL_STORAGE_ICON_DRIVE_FLOPPY_IEEE1394          = 0x10304,
    00074     HAL_STORAGE_ICON_DRIVE_TAPE                     = 0x10400,
    00075     HAL_STORAGE_ICON_DRIVE_COMPACT_FLASH            = 0x10500,
    00076     HAL_STORAGE_ICON_DRIVE_MEMORY_STICK             = 0x10600,
    00077     HAL_STORAGE_ICON_DRIVE_SMART_MEDIA              = 0x10700,
    00078     HAL_STORAGE_ICON_DRIVE_SD_MMC                   = 0x10800,
    00079     HAL_STORAGE_ICON_DRIVE_CAMERA                   = 0x10900,
    00080     HAL_STORAGE_ICON_DRIVE_PORTABLE_AUDIO_PLAYER    = 0x10a00,
    00081 /*  HAL_STORAGE_ICON_DRIVE_ZIP                      = 0x10b00,
    00082         HAL_STORAGE_ICON_DRIVE_JAZ                      = 0x10c00,*/
    00083
    00084     HAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK          = 0x20000,
    00085     HAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_IDE      = 0x20001,
    00086     HAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_SCSI     = 0x20002,
    00087     HAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_USB      = 0x20003,
    00088     HAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_IEEE1394 = 0x20004,
    00089     HAL_STORAGE_ICON_VOLUME_DISK                    = 0x20100,
    00090     HAL_STORAGE_ICON_VOLUME_DISK_IDE                = 0x20101,
    00091     HAL_STORAGE_ICON_VOLUME_DISK_SCSI               = 0x20102,
    00092     HAL_STORAGE_ICON_VOLUME_DISK_USB                = 0x20103,
    00093     HAL_STORAGE_ICON_VOLUME_DISK_IEEE1394           = 0x20104,
    00094     HAL_STORAGE_ICON_VOLUME_CDROM                   = 0x20200,
    00095     HAL_STORAGE_ICON_VOLUME_CDROM_IDE               = 0x20201,
    00096     HAL_STORAGE_ICON_VOLUME_CDROM_SCSI              = 0x20202,
    00097     HAL_STORAGE_ICON_VOLUME_CDROM_USB               = 0x20203,
    00098     HAL_STORAGE_ICON_VOLUME_CDROM_IEEE1394          = 0x20204,
    00099     HAL_STORAGE_ICON_VOLUME_FLOPPY                  = 0x20300,
    00100     HAL_STORAGE_ICON_VOLUME_FLOPPY_IDE              = 0x20301,
    00101     HAL_STORAGE_ICON_VOLUME_FLOPPY_SCSI             = 0x20302,
    00102     HAL_STORAGE_ICON_VOLUME_FLOPPY_USB              = 0x20303,
    00103     HAL_STORAGE_ICON_VOLUME_FLOPPY_IEEE1394         = 0x20304,
    00104     HAL_STORAGE_ICON_VOLUME_TAPE                    = 0x20400,
    00105     HAL_STORAGE_ICON_VOLUME_COMPACT_FLASH           = 0x20500,
    00106     HAL_STORAGE_ICON_VOLUME_MEMORY_STICK            = 0x20600,
    00107     HAL_STORAGE_ICON_VOLUME_SMART_MEDIA             = 0x20700,
    00108     HAL_STORAGE_ICON_VOLUME_SD_MMC                  = 0x20800,
    00109     HAL_STORAGE_ICON_VOLUME_CAMERA                  = 0x20900,
    00110     HAL_STORAGE_ICON_VOLUME_PORTABLE_AUDIO_PLAYER   = 0x20a00,
    00111 /*  HAL_STORAGE_ICON_VOLUME_ZIP                     = 0x10b00,
    00112         HAL_STORAGE_ICON_VOLUME_JAZ                     = 0x10c00,*/
    00113
    00114     HAL_STORAGE_ICON_DISC_CDROM                     = 0x30000,
    00115     HAL_STORAGE_ICON_DISC_CDR                       = 0x30001,
    00116     HAL_STORAGE_ICON_DISC_CDRW                      = 0x30002,
    00117     HAL_STORAGE_ICON_DISC_DVDROM                    = 0x30003,
    00118     HAL_STORAGE_ICON_DISC_DVDRAM                    = 0x30004,
    00119     HAL_STORAGE_ICON_DISC_DVDR                      = 0x30005,
    00120     HAL_STORAGE_ICON_DISC_DVDRW                     = 0x30006,
    00121     HAL_STORAGE_ICON_DISC_DVDPLUSR                  = 0x30007,
    00122     HAL_STORAGE_ICON_DISC_DVDPLUSRW                 = 0x30008
    00123 } HalStoragePolicyIcon;
    00124
    00125 typedef struct {
    00126     HalStoragePolicyIcon icon;
    00127     const char *icon_path;
    00128 } HalStoragePolicyIconPair;
    00129
    00130 HalStoragePolicy *hal_storage_policy_new              (void);
    00131 void              hal_storage_policy_free             (HalStoragePolicy *policy);
    00132
    00133 void              hal_storage_policy_set_icon_path    (HalStoragePolicy *policy,
    00134                                HalStoragePolicyIcon icon, const char *path);
    00135 void              hal_storage_policy_set_icon_mapping (HalStoragePolicy *policy, HalStoragePolicyIconPair *pairs);
    00136 const char       *hal_storage_policy_lookup_icon      (HalStoragePolicy *policy, HalStoragePolicyIcon icon);
    00137
    00138 typedef enum {
    00139     HAL_DRIVE_BUS_UNKNOWN     = 0x00,
    00140     HAL_DRIVE_BUS_IDE         = 0x01,
    00141     HAL_DRIVE_BUS_SCSI        = 0x02,
    00142     HAL_DRIVE_BUS_USB         = 0x03,
    00143     HAL_DRIVE_BUS_IEEE1394    = 0x04
    00144 } HalDriveBus;
    00145
    00146 typedef enum {
    00147     HAL_DRIVE_TYPE_REMOVABLE_DISK        = 0x00,
    00148     HAL_DRIVE_TYPE_DISK                  = 0x01,
    00149     HAL_DRIVE_TYPE_CDROM                 = 0x02,
    00150     HAL_DRIVE_TYPE_FLOPPY                = 0x03,
    00151     HAL_DRIVE_TYPE_TAPE                  = 0x04,
    00152     HAL_DRIVE_TYPE_COMPACT_FLASH         = 0x05,
    00153     HAL_DRIVE_TYPE_MEMORY_STICK          = 0x06,
    00154     HAL_DRIVE_TYPE_SMART_MEDIA           = 0x07,
    00155     HAL_DRIVE_TYPE_SD_MMC                = 0x08,
    00156     HAL_DRIVE_TYPE_CAMERA                = 0x09,
    00157     HAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER = 0x0a/*,
    00158     HAL_DRIVE_TYPE_ZIP                   = 0x0b,
    00159     HAL_DRIVE_TYPE_JAZ                   = 0x0c*/
    00160 } HalDriveType;
    00161
    00162 typedef enum {
    00163     HAL_DRIVE_CDROM_CAPS_CDROM      = 0x0001,
    00164     HAL_DRIVE_CDROM_CAPS_CDR        = 0x0002,
    00165     HAL_DRIVE_CDROM_CAPS_CDRW       = 0x0004,
    00166     HAL_DRIVE_CDROM_CAPS_DVDRAM     = 0x0008,
    00167     HAL_DRIVE_CDROM_CAPS_DVDROM     = 0x0010,
    00168     HAL_DRIVE_CDROM_CAPS_DVDR       = 0x0020,
    00169     HAL_DRIVE_CDROM_CAPS_DVDRW      = 0x0040,
    00170     HAL_DRIVE_CDROM_CAPS_DVDPLUSR   = 0x0080,
    00171     HAL_DRIVE_CDROM_CAPS_DVDPLUSRW  = 0x0100
    00172 } HalDriveCdromCaps;
    00173
    00174 HalDrive         *hal_drive_from_udi                    (LibHalContext *hal_ctx, const char *udi);
    00175 HalDrive         *hal_drive_from_device_file            (LibHalContext *hal_ctx, const char *device_file);
    00176 void              hal_drive_free                        (HalDrive      *drive);
    00177
    00178 dbus_bool_t       hal_drive_is_hotpluggable             (HalDrive      *drive);
    00179 dbus_bool_t       hal_drive_uses_removable_media        (HalDrive      *drive);
    00180 dbus_bool_t       hal_drive_no_partitions_hint          (HalDrive      *drive);
    00181 dbus_bool_t       hal_drive_requires_eject              (HalDrive      *drive);
    00182 HalDriveType      hal_drive_get_type                    (HalDrive      *drive);
    00183 HalDriveBus       hal_drive_get_bus                     (HalDrive      *drive);
    00184 HalDriveCdromCaps hal_drive_get_cdrom_caps              (HalDrive      *drive);
    00185 unsigned int      hal_drive_get_device_major            (HalDrive      *drive);
    00186 unsigned int      hal_drive_get_device_minor            (HalDrive      *drive);
    00187 const char       *hal_drive_get_type_textual            (HalDrive      *drive);
    00188 const char       *hal_drive_get_device_file             (HalDrive      *drive);
    00189 const char       *hal_drive_get_udi                     (HalDrive      *drive);
    00190 const char       *hal_drive_get_serial                  (HalDrive      *drive);
    00191 const char       *hal_drive_get_firmware_version        (HalDrive      *drive);
    00192 const char       *hal_drive_get_model                   (HalDrive      *drive);
    00193 const char       *hal_drive_get_vendor                  (HalDrive      *drive);
    00194 const char       *hal_drive_get_physical_device_udi     (HalDrive      *drive);
    00195
    00196 const char       *hal_drive_get_dedicated_icon_drive    (HalDrive      *drive);
    00197 const char       *hal_drive_get_dedicated_icon_volume   (HalDrive      *drive);
    00198
    00199 char             *hal_drive_policy_compute_display_name (HalDrive      *drive, HalVolume *volume, HalStoragePolicy *policy);
    00200 char             *hal_drive_policy_compute_icon_name    (HalDrive      *drive, HalVolume *volume, HalStoragePolicy *policy);
    00201
    00202 dbus_bool_t       hal_drive_policy_is_mountable        (HalDrive      *drive, HalStoragePolicy *policy);
    00203 const char       *hal_drive_policy_get_desired_mount_point (HalDrive      *drive, HalStoragePolicy *policy);
    00204 const char       *hal_drive_policy_get_mount_options   (HalDrive      *drive, HalStoragePolicy *policy);
    00205 const char       *hal_drive_policy_get_mount_fs        (HalDrive      *drive, HalStoragePolicy *policy);
    00206
    00207 char            **hal_drive_find_all_volumes            (LibHalContext *hal_ctx, HalDrive *drive, int *num_volumes);
    00208
    00209
    00210 char        *hal_drive_policy_default_get_mount_root                (LibHalContext *hal_ctx);
    00211 dbus_bool_t  hal_drive_policy_default_use_managed_keyword           (LibHalContext *hal_ctx);
    00212 char        *hal_drive_policy_default_get_managed_keyword_primary   (LibHalContext *hal_ctx);
    00213 char        *hal_drive_policy_default_get_managed_keyword_secondary (LibHalContext *hal_ctx);
    00214
    00215
    00216 typedef enum {
    00217     HAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM,
    00218     HAL_VOLUME_USAGE_PARTITION_TABLE,
    00219     HAL_VOLUME_USAGE_RAID_MEMBER
    00220 } HalVolumeUsage;
    00221
    00222 typedef enum {
    00223     HAL_VOLUME_DISC_TYPE_CDROM     = 0x00,
    00224     HAL_VOLUME_DISC_TYPE_CDR       = 0x01,
    00225     HAL_VOLUME_DISC_TYPE_CDRW      = 0x02,
    00226     HAL_VOLUME_DISC_TYPE_DVDROM    = 0x03,
    00227     HAL_VOLUME_DISC_TYPE_DVDRAM    = 0x04,
    00228     HAL_VOLUME_DISC_TYPE_DVDR      = 0x05,
    00229     HAL_VOLUME_DISC_TYPE_DVDRW     = 0x06,
    00230     HAL_VOLUME_DISC_TYPE_DVDPLUSR  = 0x07,
    00231     HAL_VOLUME_DISC_TYPE_DVDPLUSRW = 0x08
    00232 } HalVolumeDiscType;
    00233
    00234 HalVolume        *hal_volume_from_udi                      (LibHalContext *hal_ctx, const char *udi);
    00235 HalVolume        *hal_volume_from_device_file              (LibHalContext *hal_ctx, const char *device_file);
    00236 void              hal_volume_free                          (HalVolume     *volume);
    00237 dbus_uint64_t     hal_volume_get_size                      (HalVolume     *volume);
    00238
    00239 const char       *hal_volume_get_udi                       (HalVolume     *volume);
    00240 const char       *hal_volume_get_device_file               (HalVolume     *volume);
    00241 unsigned int      hal_volume_get_device_major              (HalVolume     *volume);
    00242 unsigned int      hal_volume_get_device_minor              (HalVolume     *volume);
    00243 const char       *hal_volume_get_fstype                    (HalVolume     *volume);
    00244 const char       *hal_volume_get_fsversion                 (HalVolume     *volume);
    00245 HalVolumeUsage    hal_volume_get_fsusage                   (HalVolume     *volume);
    00246 dbus_bool_t       hal_volume_is_mounted                    (HalVolume     *volume);
    00247 dbus_bool_t       hal_volume_is_partition                  (HalVolume     *volume);
    00248 dbus_bool_t       hal_volume_is_disc                       (HalVolume     *volume);
    00249 unsigned int      hal_volume_get_partition_number          (HalVolume     *volume);
    00250 const char       *hal_volume_get_label                     (HalVolume     *volume);
    00251 const char       *hal_volume_get_mount_point               (HalVolume     *volume);
    00252 const char       *hal_volume_get_uuid                      (HalVolume     *volume);
    00253 const char       *hal_volume_get_storage_device_udi        (HalVolume     *volume);
    00254
    00255 dbus_bool_t       hal_volume_disc_has_audio                (HalVolume     *volume);
    00256 dbus_bool_t       hal_volume_disc_has_data                 (HalVolume     *volume);
    00257 dbus_bool_t       hal_volume_disc_is_blank                 (HalVolume     *volume);
    00258 dbus_bool_t       hal_volume_disc_is_rewritable            (HalVolume     *volume);
    00259 dbus_bool_t       hal_volume_disc_is_appendable            (HalVolume     *volume);
    00260 HalVolumeDiscType hal_volume_get_disc_type                 (HalVolume     *volume);
    00261 int               hal_volume_get_msdos_part_table_type     (HalVolume     *volume);
    00262
    00263 char             *hal_volume_policy_compute_size_as_string (HalVolume     *volume);
    00264
    00265 char             *hal_volume_policy_compute_display_name   (HalDrive      *drive, HalVolume    *volume, HalStoragePolicy *policy);
    00266 char             *hal_volume_policy_compute_icon_name      (HalDrive      *drive, HalVolume    *volume, HalStoragePolicy *policy);
    00267
    00268 dbus_bool_t       hal_volume_policy_should_be_visible      (HalDrive      *drive, HalVolume    *volume, HalStoragePolicy *policy, const char *target_mount_point);
    00269
    00270 dbus_bool_t       hal_volume_policy_is_mountable        (HalDrive *drive, HalVolume *volume, HalStoragePolicy *policy);
    00271 const char       *hal_volume_policy_get_desired_mount_point (HalDrive *drive, HalVolume *volume, HalStoragePolicy *policy);
    00272 const char       *hal_volume_policy_get_mount_options   (HalDrive *drive, HalVolume *volume, HalStoragePolicy *policy);
    00273 const char       *hal_volume_policy_get_mount_fs        (HalDrive *drive, HalVolume *volume, HalStoragePolicy *policy);
    00274
    00277 #if defined(__cplusplus)
    00278 }
    00279 #endif
    00280
    00281 #endif /* LIBHAL_STORAGE_H */