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.13 2005/08/10 20:34:21 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  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 LibHalDrive_s;
    00045 typedef struct LibHalDrive_s LibHalDrive;
    00046 struct LibHalVolume_s;
    00047 typedef struct LibHalVolume_s LibHalVolume;
    00048 struct LibHalStoragePolicy_s;
    00049 typedef struct LibHalStoragePolicy_s LibHalStoragePolicy;
    00050 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
    00051
    00052
    00053 typedef enum {
    00054     LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK           = 0x10000,
    00055     LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_IDE       = 0x10001,
    00056     LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_SCSI      = 0x10002,
    00057     LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_USB       = 0x10003,
    00058     LIBHAL_STORAGE_ICON_DRIVE_REMOVABLE_DISK_IEEE1394  = 0x10004,
    00059     LIBHAL_STORAGE_ICON_DRIVE_DISK                     = 0x10100,
    00060     LIBHAL_STORAGE_ICON_DRIVE_DISK_IDE                 = 0x10101,
    00061     LIBHAL_STORAGE_ICON_DRIVE_DISK_SCSI                = 0x10102,
    00062     LIBHAL_STORAGE_ICON_DRIVE_DISK_USB                 = 0x10103,
    00063     LIBHAL_STORAGE_ICON_DRIVE_DISK_IEEE1394            = 0x10104,
    00064     LIBHAL_STORAGE_ICON_DRIVE_CDROM                    = 0x10200,
    00065     LIBHAL_STORAGE_ICON_DRIVE_CDROM_IDE                = 0x10201,
    00066     LIBHAL_STORAGE_ICON_DRIVE_CDROM_SCSI               = 0x10202,
    00067     LIBHAL_STORAGE_ICON_DRIVE_CDROM_USB                = 0x10203,
    00068     LIBHAL_STORAGE_ICON_DRIVE_CDROM_IEEE1394           = 0x10204,
    00069     LIBHAL_STORAGE_ICON_DRIVE_FLOPPY                   = 0x10300,
    00070     LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_IDE               = 0x10301,
    00071     LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_SCSI              = 0x10302,
    00072     LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_USB               = 0x10303,
    00073     LIBHAL_STORAGE_ICON_DRIVE_FLOPPY_IEEE1394          = 0x10304,
    00074     LIBHAL_STORAGE_ICON_DRIVE_TAPE                     = 0x10400,
    00075     LIBHAL_STORAGE_ICON_DRIVE_COMPACT_FLASH            = 0x10500,
    00076     LIBHAL_STORAGE_ICON_DRIVE_MEMORY_STICK             = 0x10600,
    00077     LIBHAL_STORAGE_ICON_DRIVE_SMART_MEDIA              = 0x10700,
    00078     LIBHAL_STORAGE_ICON_DRIVE_SD_MMC                   = 0x10800,
    00079     LIBHAL_STORAGE_ICON_DRIVE_CAMERA                   = 0x10900,
    00080     LIBHAL_STORAGE_ICON_DRIVE_PORTABLE_AUDIO_PLAYER    = 0x10a00,
    00081     LIBHAL_STORAGE_ICON_DRIVE_ZIP                      = 0x10b00,
    00082         LIBHAL_STORAGE_ICON_DRIVE_JAZ                      = 0x10c00,
    00083         LIBHAL_STORAGE_ICON_DRIVE_FLASH_KEY                = 0x10d00,
    00084
    00085     LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK          = 0x20000,
    00086     LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_IDE      = 0x20001,
    00087     LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_SCSI     = 0x20002,
    00088     LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_USB      = 0x20003,
    00089     LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK_IEEE1394 = 0x20004,
    00090     LIBHAL_STORAGE_ICON_VOLUME_DISK                    = 0x20100,
    00091     LIBHAL_STORAGE_ICON_VOLUME_DISK_IDE                = 0x20101,
    00092     LIBHAL_STORAGE_ICON_VOLUME_DISK_SCSI               = 0x20102,
    00093     LIBHAL_STORAGE_ICON_VOLUME_DISK_USB                = 0x20103,
    00094     LIBHAL_STORAGE_ICON_VOLUME_DISK_IEEE1394           = 0x20104,
    00095     LIBHAL_STORAGE_ICON_VOLUME_CDROM                   = 0x20200,
    00096     LIBHAL_STORAGE_ICON_VOLUME_CDROM_IDE               = 0x20201,
    00097     LIBHAL_STORAGE_ICON_VOLUME_CDROM_SCSI              = 0x20202,
    00098     LIBHAL_STORAGE_ICON_VOLUME_CDROM_USB               = 0x20203,
    00099     LIBHAL_STORAGE_ICON_VOLUME_CDROM_IEEE1394          = 0x20204,
    00100     LIBHAL_STORAGE_ICON_VOLUME_FLOPPY                  = 0x20300,
    00101     LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_IDE              = 0x20301,
    00102     LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_SCSI             = 0x20302,
    00103     LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_USB              = 0x20303,
    00104     LIBHAL_STORAGE_ICON_VOLUME_FLOPPY_IEEE1394         = 0x20304,
    00105     LIBHAL_STORAGE_ICON_VOLUME_TAPE                    = 0x20400,
    00106     LIBHAL_STORAGE_ICON_VOLUME_COMPACT_FLASH           = 0x20500,
    00107     LIBHAL_STORAGE_ICON_VOLUME_MEMORY_STICK            = 0x20600,
    00108     LIBHAL_STORAGE_ICON_VOLUME_SMART_MEDIA             = 0x20700,
    00109     LIBHAL_STORAGE_ICON_VOLUME_SD_MMC                  = 0x20800,
    00110     LIBHAL_STORAGE_ICON_VOLUME_CAMERA                  = 0x20900,
    00111     LIBHAL_STORAGE_ICON_VOLUME_PORTABLE_AUDIO_PLAYER   = 0x20a00,
    00112     LIBHAL_STORAGE_ICON_VOLUME_ZIP                     = 0x20b00,
    00113         LIBHAL_STORAGE_ICON_VOLUME_JAZ                     = 0x20c00,
    00114         LIBHAL_STORAGE_ICON_VOLUME_FLASH_KEY               = 0x20d00,
    00115
    00116     LIBHAL_STORAGE_ICON_DISC_CDROM                     = 0x30000,
    00117     LIBHAL_STORAGE_ICON_DISC_CDR                       = 0x30001,
    00118     LIBHAL_STORAGE_ICON_DISC_CDRW                      = 0x30002,
    00119     LIBHAL_STORAGE_ICON_DISC_DVDROM                    = 0x30003,
    00120     LIBHAL_STORAGE_ICON_DISC_DVDRAM                    = 0x30004,
    00121     LIBHAL_STORAGE_ICON_DISC_DVDR                      = 0x30005,
    00122     LIBHAL_STORAGE_ICON_DISC_DVDRW                     = 0x30006,
    00123     LIBHAL_STORAGE_ICON_DISC_DVDPLUSR                  = 0x30007,
    00124     LIBHAL_STORAGE_ICON_DISC_DVDPLUSRW                 = 0x30008
    00125 } LibHalStoragePolicyIcon;
    00126
    00127 typedef struct {
    00128     LibHalStoragePolicyIcon icon;
    00129     const char *icon_path;
    00130 } LibHalStoragePolicyIconPair;
    00131
    00132 LibHalStoragePolicy *libhal_storage_policy_new          (void);
    00133 void                 libhal_storage_policy_free         (LibHalStoragePolicy *policy);
    00134
    00135 void                 libhal_storage_policy_set_icon_path    (LibHalStoragePolicy *policy,
    00136                                  LibHalStoragePolicyIcon icon,
    00137                                  const char *path);
    00138
    00139 void                 libhal_storage_policy_set_icon_mapping (LibHalStoragePolicy *policy,
    00140                                  LibHalStoragePolicyIconPair *pairs);
    00141 const char          *libhal_storage_policy_lookup_icon      (LibHalStoragePolicy *policy,
    00142                                  LibHalStoragePolicyIcon icon);
    00143
    00144 typedef enum {
    00145     LIBHAL_DRIVE_BUS_UNKNOWN     = 0x00,
    00146     LIBHAL_DRIVE_BUS_IDE         = 0x01,
    00147     LIBHAL_DRIVE_BUS_SCSI        = 0x02,
    00148     LIBHAL_DRIVE_BUS_USB         = 0x03,
    00149     LIBHAL_DRIVE_BUS_IEEE1394    = 0x04,
    00150     LIBHAL_DRIVE_BUS_CCW         = 0x05
    00151 } LibHalDriveBus;
    00152
    00153 typedef enum {
    00154     LIBHAL_DRIVE_TYPE_REMOVABLE_DISK        = 0x00,
    00155     LIBHAL_DRIVE_TYPE_DISK                  = 0x01,
    00156     LIBHAL_DRIVE_TYPE_CDROM                 = 0x02,
    00157     LIBHAL_DRIVE_TYPE_FLOPPY                = 0x03,
    00158     LIBHAL_DRIVE_TYPE_TAPE                  = 0x04,
    00159     LIBHAL_DRIVE_TYPE_COMPACT_FLASH         = 0x05,
    00160     LIBHAL_DRIVE_TYPE_MEMORY_STICK          = 0x06,
    00161     LIBHAL_DRIVE_TYPE_SMART_MEDIA           = 0x07,
    00162     LIBHAL_DRIVE_TYPE_SD_MMC                = 0x08,
    00163     LIBHAL_DRIVE_TYPE_CAMERA                = 0x09,
    00164     LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER = 0x0a,
    00165     LIBHAL_DRIVE_TYPE_ZIP                   = 0x0b,
    00166     LIBHAL_DRIVE_TYPE_JAZ                   = 0x0c,
    00167     LIBHAL_DRIVE_TYPE_FLASHKEY              = 0x0d
    00168 } LibHalDriveType;
    00169
    00170 typedef enum {
    00171     LIBHAL_DRIVE_CDROM_CAPS_CDROM      = 0x0001,
    00172     LIBHAL_DRIVE_CDROM_CAPS_CDR        = 0x0002,
    00173     LIBHAL_DRIVE_CDROM_CAPS_CDRW       = 0x0004,
    00174     LIBHAL_DRIVE_CDROM_CAPS_DVDRAM     = 0x0008,
    00175     LIBHAL_DRIVE_CDROM_CAPS_DVDROM     = 0x0010,
    00176     LIBHAL_DRIVE_CDROM_CAPS_DVDR       = 0x0020,
    00177     LIBHAL_DRIVE_CDROM_CAPS_DVDRW      = 0x0040,
    00178     LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSR   = 0x0080,
    00179     LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRW  = 0x0100,
    00180     LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRDL = 0x0120
    00181
    00182 } LibHalDriveCdromCaps;
    00183
    00184 LibHalDrive         *libhal_drive_from_udi                    (LibHalContext *hal_ctx,
    00185                                    const char *udi);
    00186 LibHalDrive         *libhal_drive_from_device_file            (LibHalContext *hal_ctx,
    00187                                    const char *device_file);
    00188 void                 libhal_drive_free                        (LibHalDrive *drive);
    00189
    00190 dbus_bool_t          libhal_drive_is_hotpluggable          (LibHalDrive      *drive);
    00191 dbus_bool_t          libhal_drive_uses_removable_media     (LibHalDrive      *drive);
    00192 dbus_bool_t          libhal_drive_no_partitions_hint       (LibHalDrive      *drive);
    00193 dbus_bool_t          libhal_drive_requires_eject           (LibHalDrive      *drive);
    00194 LibHalDriveType      libhal_drive_get_type                 (LibHalDrive      *drive);
    00195 LibHalDriveBus       libhal_drive_get_bus                  (LibHalDrive      *drive);
    00196 LibHalDriveCdromCaps libhal_drive_get_cdrom_caps           (LibHalDrive      *drive);
    00197 unsigned int         libhal_drive_get_device_major         (LibHalDrive      *drive);
    00198 unsigned int         libhal_drive_get_device_minor         (LibHalDrive      *drive);
    00199 const char          *libhal_drive_get_type_textual         (LibHalDrive      *drive);
    00200 const char          *libhal_drive_get_device_file          (LibHalDrive      *drive);
    00201 const char          *libhal_drive_get_udi                  (LibHalDrive      *drive);
    00202 const char          *libhal_drive_get_serial               (LibHalDrive      *drive);
    00203 const char          *libhal_drive_get_firmware_version     (LibHalDrive      *drive);
    00204 const char          *libhal_drive_get_model                (LibHalDrive      *drive);
    00205 const char          *libhal_drive_get_vendor               (LibHalDrive      *drive);
    00206 const char          *libhal_drive_get_physical_device_udi  (LibHalDrive      *drive);
    00207
    00208 const char          *libhal_drive_get_dedicated_icon_drive    (LibHalDrive      *drive);
    00209 const char          *libhal_drive_get_dedicated_icon_volume   (LibHalDrive      *drive);
    00210
    00211 char                *libhal_drive_policy_compute_display_name (LibHalDrive        *drive,
    00212                                    LibHalVolume        *volume,
    00213                                    LibHalStoragePolicy *policy);
    00214 char                *libhal_drive_policy_compute_icon_name    (LibHalDrive         *drive,
    00215                                    LibHalVolume        *volume,
    00216                                    LibHalStoragePolicy *policy);
    00217
    00218 dbus_bool_t          libhal_drive_policy_is_mountable            (LibHalDrive         *drive,
    00219                                   LibHalStoragePolicy *policy);
    00220 const char          *libhal_drive_policy_get_desired_mount_point (LibHalDrive         *drive,
    00221                                   LibHalStoragePolicy *policy);
    00222 const char          *libhal_drive_policy_get_mount_options       (LibHalDrive         *drive,
    00223                                       LibHalStoragePolicy *policy);
    00224 const char          *libhal_drive_policy_get_mount_fs            (LibHalDrive      *drive,
    00225                                   LibHalStoragePolicy *policy);
    00226
    00227 char               **libhal_drive_find_all_volumes (LibHalContext *hal_ctx,
    00228                             LibHalDrive   *drive,
    00229                             int       *num_volumes);
    00230
    00231
    00232 char        *libhal_drive_policy_default_get_mount_root                (LibHalContext *hal_ctx);
    00233 dbus_bool_t  libhal_drive_policy_default_use_managed_keyword           (LibHalContext *hal_ctx);
    00234 char        *libhal_drive_policy_default_get_managed_keyword_primary   (LibHalContext *hal_ctx);
    00235 char        *libhal_drive_policy_default_get_managed_keyword_secondary (LibHalContext *hal_ctx);
    00236
    00237
    00238 typedef enum {
    00239     LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM,
    00240     LIBHAL_VOLUME_USAGE_PARTITION_TABLE,
    00241     LIBHAL_VOLUME_USAGE_RAID_MEMBER,
    00242     LIBHAL_VOLUME_USAGE_CRYPTO,
    00243     LIBHAL_VOLUME_USAGE_UNKNOWN
    00244 } LibHalVolumeUsage;
    00245
    00246 typedef enum {
    00247     LIBHAL_VOLUME_DISC_TYPE_CDROM       = 0x00,
    00248     LIBHAL_VOLUME_DISC_TYPE_CDR         = 0x01,
    00249     LIBHAL_VOLUME_DISC_TYPE_CDRW        = 0x02,
    00250     LIBHAL_VOLUME_DISC_TYPE_DVDROM      = 0x03,
    00251     LIBHAL_VOLUME_DISC_TYPE_DVDRAM      = 0x04,
    00252     LIBHAL_VOLUME_DISC_TYPE_DVDR        = 0x05,
    00253     LIBHAL_VOLUME_DISC_TYPE_DVDRW       = 0x06,
    00254     LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR    = 0x07,
    00255     LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW   = 0x08,
    00256     LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR_DL = 0x09
    00257 } LibHalVolumeDiscType;
    00258
    00259 LibHalVolume     *libhal_volume_from_udi                      (LibHalContext *hal_ctx,
    00260                                    const char *udi);
    00261 LibHalVolume     *libhal_volume_from_device_file              (LibHalContext *hal_ctx,
    00262                                    const char *device_file);
    00263 void              libhal_volume_free                          (LibHalVolume     *volume);
    00264 dbus_uint64_t     libhal_volume_get_size                      (LibHalVolume     *volume);
    00265
    00266 const char          *libhal_volume_get_udi                       (LibHalVolume     *volume);
    00267 const char          *libhal_volume_get_device_file               (LibHalVolume     *volume);
    00268 unsigned int         libhal_volume_get_device_major              (LibHalVolume     *volume);
    00269 unsigned int         libhal_volume_get_device_minor              (LibHalVolume     *volume);
    00270 const char          *libhal_volume_get_fstype                    (LibHalVolume     *volume);
    00271 const char          *libhal_volume_get_fsversion                 (LibHalVolume     *volume);
    00272 LibHalVolumeUsage    libhal_volume_get_fsusage                   (LibHalVolume     *volume);
    00273 dbus_bool_t          libhal_volume_is_mounted                    (LibHalVolume     *volume);
    00274 dbus_bool_t          libhal_volume_is_partition                  (LibHalVolume     *volume);
    00275 dbus_bool_t          libhal_volume_is_disc                       (LibHalVolume     *volume);
    00276 unsigned int         libhal_volume_get_partition_number          (LibHalVolume     *volume);
    00277 const char          *libhal_volume_get_label                     (LibHalVolume     *volume);
    00278 const char          *libhal_volume_get_mount_point               (LibHalVolume     *volume);
    00279 const char          *libhal_volume_get_uuid                      (LibHalVolume     *volume);
    00280 const char          *libhal_volume_get_storage_device_udi        (LibHalVolume     *volume);
    00281
    00282 dbus_bool_t          libhal_volume_disc_has_audio             (LibHalVolume     *volume);
    00283 dbus_bool_t          libhal_volume_disc_has_data              (LibHalVolume     *volume);
    00284 dbus_bool_t          libhal_volume_disc_is_blank              (LibHalVolume     *volume);
    00285 dbus_bool_t          libhal_volume_disc_is_rewritable         (LibHalVolume     *volume);
    00286 dbus_bool_t          libhal_volume_disc_is_appendable         (LibHalVolume     *volume);
    00287 LibHalVolumeDiscType libhal_volume_get_disc_type              (LibHalVolume     *volume);
    00288
    00289 int               libhal_volume_get_msdos_part_table_type     (LibHalVolume     *volume);
    00290
    00291 char             *libhal_volume_policy_compute_size_as_string (LibHalVolume     *volume);
    00292
    00293 char             *libhal_volume_policy_compute_display_name   (LibHalDrive         *drive,
    00294                                    LibHalVolume        *volume,
    00295                                    LibHalStoragePolicy *policy);
    00296 char             *libhal_volume_policy_compute_icon_name      (LibHalDrive         *drive,
    00297                                    LibHalVolume        *volume,
    00298                                    LibHalStoragePolicy *policy);
    00299
    00300 dbus_bool_t       libhal_volume_policy_should_be_visible      (LibHalDrive         *drive,
    00301                                    LibHalVolume        *volume,
    00302                                    LibHalStoragePolicy *policy,
    00303                                    const char          *target_mount_point);
    00304
    00305 dbus_bool_t       libhal_volume_policy_is_mountable     (LibHalDrive         *drive,
    00306                                  LibHalVolume        *volume,
    00307                                  LibHalStoragePolicy *policy);
    00308 const char       *libhal_volume_policy_get_desired_mount_point  (LibHalDrive         *drive,
    00309                                  LibHalVolume        *volume,
    00310                                  LibHalStoragePolicy *policy);
    00311 const char       *libhal_volume_policy_get_mount_options    (LibHalDrive         *drive,
    00312                                      LibHalVolume        *volume,
    00313                                      LibHalStoragePolicy *policy);
    00314 const char       *libhal_volume_policy_get_mount_fs         (LibHalDrive         *drive,
    00315                                      LibHalVolume        *volume,
    00316                                      LibHalStoragePolicy *policy);
    00317
    00320 #if defined(__cplusplus)
    00321 }
    00322 #endif
    00323
    00324 #endif /* LIBHAL_STORAGE_H */