libhal-storage.c

00001 /***************************************************************************
00002  * CVSID: $Id: libhal-storage.c,v 1.32 2006/02/23 00:23:13 david Exp $
00003  *
00004  * libhal-storage.c : 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.1
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 #ifdef HAVE_CONFIG_H
00029 #  include <config.h>
00030 #endif
00031 
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034 #include <string.h>
00035 #include <dbus/dbus.h>
00036 
00037 #include "../libhal/libhal.h"
00038 #include "libhal-storage.h"
00039 
00040 
00041 #ifdef ENABLE_NLS
00042 # include <libintl.h>
00043 # define _(String) dgettext (GETTEXT_PACKAGE, String)
00044 # ifdef gettext_noop
00045 #   define N_(String) gettext_noop (String)
00046 # else
00047 #   define N_(String) (String)
00048 # endif
00049 #else
00050 /* Stubs that do something close enough.  */
00051 # define textdomain(String) (String)
00052 # define gettext(String) (String)
00053 # define dgettext(Domain,Message) (Message)
00054 # define dcgettext(Domain,Message,Type) (Message)
00055 # define bindtextdomain(Domain,Directory) (Domain)
00056 # define _(String) (String)
00057 # define N_(String) (String)
00058 #endif
00059 
00071 typedef struct IconMappingEntry_s {
00072     LibHalStoragePolicyIcon icon;
00073     char *path;
00074     struct IconMappingEntry_s *next;
00075 } IconMappingEntry;
00076 
00077 struct LibHalStoragePolicy_s {
00078     IconMappingEntry *icon_mappings;
00079 };
00080 
00081 LibHalStoragePolicy *
00082 libhal_storage_policy_new ()
00083 {
00084     LibHalStoragePolicy *p;
00085 
00086     p = malloc (sizeof (LibHalStoragePolicy));
00087     if (p == NULL)
00088         goto out;
00089 
00090     p->icon_mappings = NULL;
00091 out:
00092     return p;
00093 }
00094 
00095 void
00096 libhal_storage_policy_free (LibHalStoragePolicy *policy)
00097 {
00098     IconMappingEntry *i;
00099     IconMappingEntry *j;
00100 
00101     /* free all icon mappings */
00102     for (i = policy->icon_mappings; i != NULL; i = j) {
00103         j = i->next;
00104         free (i->path);
00105         free (i);
00106     }
00107 
00108     free (policy);
00109 }
00110 
00111 void
00112 libhal_storage_policy_set_icon_path (LibHalStoragePolicy *policy, LibHalStoragePolicyIcon icon, const char *path)
00113 {
00114     IconMappingEntry *i;
00115 
00116     /* see if it already exist */
00117     for (i = policy->icon_mappings; i != NULL; i = i->next) {
00118         if (i->icon == icon) {
00119             free (i->path);
00120             i->path = strdup (path);
00121             goto out;
00122         }
00123     }
00124 
00125     i = malloc (sizeof (IconMappingEntry));
00126     if (i == NULL)
00127         goto out;
00128     i->icon = icon;
00129     i->path = strdup (path);
00130     i->next = policy->icon_mappings;
00131     policy->icon_mappings = i;
00132 
00133 out:
00134     return;
00135 }
00136 
00137 void
00138 libhal_storage_policy_set_icon_mapping (LibHalStoragePolicy *policy, LibHalStoragePolicyIconPair *pairs)
00139 {
00140     LibHalStoragePolicyIconPair *i;
00141 
00142     for (i = pairs; i->icon != 0x00; i++) {
00143         libhal_storage_policy_set_icon_path (policy, i->icon, i->icon_path);
00144     }
00145 }
00146 
00147 const char *
00148 libhal_storage_policy_lookup_icon (LibHalStoragePolicy *policy, LibHalStoragePolicyIcon icon)
00149 {
00150     IconMappingEntry *i;
00151     const char *path;
00152 
00153     path = NULL;
00154     for (i = policy->icon_mappings; i != NULL; i = i->next) {
00155         if (i->icon == icon) {
00156             path = i->path;
00157             goto out;
00158         }
00159     }
00160 out:
00161     return path;
00162 }
00163 
00164 
00165 #define MAX_STRING_SZ 256
00166 
00167 char *
00168 libhal_volume_policy_compute_size_as_string (LibHalVolume *volume)
00169 {
00170     dbus_uint64_t size;
00171     char *result;
00172     char* sizes_str[] = {"K", "M", "G", "T", NULL};
00173     dbus_uint64_t cur = 1000L;
00174     dbus_uint64_t base = 10L;
00175     dbus_uint64_t step = 10L*10L*10L;
00176     int cur_str = 0;
00177     char buf[MAX_STRING_SZ];
00178 
00179     result = NULL;
00180 
00181     size = libhal_volume_get_size (volume);
00182 
00183     do {
00184         if (sizes_str[cur_str+1] == NULL || size < cur*step) {
00185             /* found the unit, display a comma number if result is a single digit */
00186             if (size < cur*base) {
00187                 snprintf (buf, MAX_STRING_SZ, "%.01f%s", 
00188                       ((double)size)/((double)cur), sizes_str[cur_str]);
00189                 result = strdup (buf);
00190             } else {
00191                 snprintf (buf, MAX_STRING_SZ, "%lld%s", size / cur, sizes_str[cur_str]);
00192                 result = strdup (buf);
00193                 }
00194             goto out;
00195         }
00196 
00197         cur *= step;
00198         cur_str++;
00199     } while (1);
00200 
00201 out:
00202     return result;
00203 }
00204 
00205 static void
00206 fixup_string (char *s)
00207 {
00208     /* TODO: first strip leading and trailing whitespace */
00209     /*g_strstrip (s);*/
00210 
00211     /* TODO: could do nice things on all-upper case strings */
00212 }
00213 
00214 /* volume may be NULL (e.g. if drive supports removable media) */
00215 char *
00216 libhal_drive_policy_compute_display_name (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
00217 {
00218     char *name;
00219     char *size_str;
00220     char *vendormodel_str;
00221     const char *model;
00222     const char *vendor;
00223     LibHalDriveType drive_type;
00224     dbus_bool_t drive_is_hotpluggable;
00225     dbus_bool_t drive_is_removable;
00226     LibHalDriveCdromCaps drive_cdrom_caps;
00227     char buf[MAX_STRING_SZ];
00228 
00229     model = libhal_drive_get_model (drive);
00230     vendor = libhal_drive_get_vendor (drive);
00231     drive_type = libhal_drive_get_type (drive);
00232     drive_is_hotpluggable = libhal_drive_is_hotpluggable (drive);
00233     drive_is_removable = libhal_drive_uses_removable_media (drive);
00234     drive_cdrom_caps = libhal_drive_get_cdrom_caps (drive);
00235 
00236     if (volume != NULL)
00237         size_str = libhal_volume_policy_compute_size_as_string (volume);
00238     else
00239         size_str = NULL;
00240 
00241     if (vendor == NULL || strlen (vendor) == 0) {
00242         if (model == NULL || strlen (model) == 0)
00243             vendormodel_str = strdup ("");
00244         else
00245             vendormodel_str = strdup (model);
00246     } else {
00247         if (model == NULL || strlen (model) == 0)
00248             vendormodel_str = strdup (vendor);
00249         else {
00250             snprintf (buf, MAX_STRING_SZ, "%s %s", vendor, model);
00251             vendormodel_str = strdup (buf);
00252         }
00253     }
00254 
00255     fixup_string (vendormodel_str);
00256 
00257     if (drive_type==LIBHAL_DRIVE_TYPE_CDROM) {
00258 
00259         /* Optical drive handling */
00260         char *first;
00261         char *second;
00262 
00263 
00264         first = "CD-ROM";
00265         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_CDR)
00266             first = "CD-R";
00267         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_CDRW)
00268             first = "CD-RW";
00269 
00270         second = "";
00271         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDROM)
00272             second = "/DVD-ROM";
00273         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSR)
00274             second = "/DVD+R";
00275         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRW)
00276             second = "/DVD+RW";
00277         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDR)
00278             second = "/DVD-R";
00279         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDRW)
00280             second = "/DVD-RW";
00281         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDRAM)
00282             second = "/DVD-RAM";
00283         if ((drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDR) &&
00284             (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSR)) {
00285             if(drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRDL)
00286                 second = "/DVD±R DL";
00287             else
00288                 second = "/DVD±R";
00289         }
00290         if ((drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDRW) &&
00291             (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRW)) {
00292                         if(drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRDL)
00293                                 second = "/DVD±RW DL";
00294                         else
00295                                 second = "/DVD±RW";
00296                 }
00297         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_BDROM)
00298             second = "/BD-ROM";
00299         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_BDR)
00300             second = "/BD-R";
00301         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_BDRE)
00302             second = "/BD-RE";
00303         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_HDDVDROM)
00304             second = "/HD DVD-ROM";
00305         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_HDDVDR)
00306             second = "/HD DVD-R";
00307         if (drive_cdrom_caps & LIBHAL_DRIVE_CDROM_CAPS_HDDVDRW)
00308             second = "/HD DVD-RW";
00309 
00310         if (drive_is_hotpluggable) {
00311             snprintf (buf, MAX_STRING_SZ, _("External %s%s Drive"), first, second);
00312             name = strdup (buf);
00313         } else {
00314             snprintf (buf, MAX_STRING_SZ, _("%s%s Drive"), first, second);
00315             name = strdup (buf);
00316         }
00317             
00318     } else if (drive_type==LIBHAL_DRIVE_TYPE_FLOPPY) {
00319 
00320         /* Floppy Drive handling */
00321 
00322         if (drive_is_hotpluggable)
00323             name = strdup (_("External Floppy Drive"));
00324         else
00325             name = strdup (_("Floppy Drive"));
00326     } else if (drive_type==LIBHAL_DRIVE_TYPE_DISK && !drive_is_removable) {
00327 
00328         /* Harddisks */
00329 
00330         if (size_str != NULL) {
00331             if (drive_is_hotpluggable) {
00332                 snprintf (buf, MAX_STRING_SZ, _("%s External Hard Drive"), size_str);
00333                 name = strdup (buf);
00334             } else {
00335                 snprintf (buf, MAX_STRING_SZ, _("%s Hard Drive"), size_str);
00336                 name = strdup (buf);
00337             }
00338         } else {
00339             if (drive_is_hotpluggable)
00340                 name = strdup (_("External Hard Drive"));
00341             else
00342                 name = strdup (_("Hard Drive"));
00343         }
00344     } else {
00345 
00346         /* The rest - includes drives with removable Media */
00347 
00348         if (strlen (vendormodel_str) > 0)
00349             name = strdup (vendormodel_str);
00350         else
00351             name = strdup (_("Drive"));
00352     }
00353 
00354     free (vendormodel_str);
00355     free (size_str);
00356 
00357     return name;
00358 }
00359 
00360 char *
00361 libhal_volume_policy_compute_display_name (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
00362 {
00363     char *name;
00364     char *size_str;
00365     const char *volume_label;
00366     const char *model;
00367     const char *vendor;
00368     LibHalDriveType drive_type;
00369     dbus_bool_t drive_is_hotpluggable;
00370     dbus_bool_t drive_is_removable;
00371     LibHalDriveCdromCaps drive_cdrom_caps;
00372     char buf[MAX_STRING_SZ];
00373 
00374     volume_label = libhal_volume_get_label (volume);
00375     model = libhal_drive_get_model (drive);
00376     vendor = libhal_drive_get_vendor (drive);
00377     drive_type = libhal_drive_get_type (drive);
00378     drive_is_hotpluggable = libhal_drive_is_hotpluggable (drive);
00379     drive_is_removable = libhal_drive_uses_removable_media (drive);
00380     drive_cdrom_caps = libhal_drive_get_cdrom_caps (drive);
00381 
00382     size_str = libhal_volume_policy_compute_size_as_string (volume);
00383 
00384     /* If the volume label is available use that 
00385      *
00386      * TODO: If label is a fully-qualified UNIX path don't use that
00387      */
00388     if (volume_label != NULL) {
00389         name = strdup (volume_label);
00390         goto out;
00391     }
00392 
00393     /* Handle media in optical drives */
00394     if (drive_type==LIBHAL_DRIVE_TYPE_CDROM) {
00395         switch (libhal_volume_get_disc_type (volume)) {
00396 
00397         default:
00398             /* explict fallthrough */
00399         case LIBHAL_VOLUME_DISC_TYPE_CDROM:
00400             name = strdup (_("CD-ROM "));
00401             break;
00402             
00403         case LIBHAL_VOLUME_DISC_TYPE_CDR:
00404             if (libhal_volume_disc_is_blank (volume))
00405                 name = strdup (_("Blank CD-R"));
00406             else
00407                 name = strdup (_("CD-R"));
00408             break;
00409             
00410         case LIBHAL_VOLUME_DISC_TYPE_CDRW:
00411             if (libhal_volume_disc_is_blank (volume))
00412                 name = strdup (_("Blank CD-RW"));
00413             else
00414                 name = strdup (_("CD-RW"));
00415             break;
00416             
00417         case LIBHAL_VOLUME_DISC_TYPE_DVDROM:
00418             name = strdup (_("DVD-ROM"));
00419             break;
00420             
00421         case LIBHAL_VOLUME_DISC_TYPE_DVDRAM:
00422             if (libhal_volume_disc_is_blank (volume))
00423                 name = strdup (_("Blank DVD-RAM"));
00424             else
00425                 name = strdup (_("DVD-RAM"));
00426             break;
00427             
00428         case LIBHAL_VOLUME_DISC_TYPE_DVDR:
00429             if (libhal_volume_disc_is_blank (volume))
00430                 name = strdup (_("Blank DVD-R"));
00431             else
00432                 name = strdup (_("DVD-R"));
00433             break;
00434             
00435         case LIBHAL_VOLUME_DISC_TYPE_DVDRW:
00436             if (libhal_volume_disc_is_blank (volume))
00437                 name = strdup (_("Blank DVD-RW"));
00438             else
00439                 name = strdup (_("DVD-RW"));
00440             break;
00441 
00442         case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR:
00443             if (libhal_volume_disc_is_blank (volume))
00444                 name = strdup (_("Blank DVD+R"));
00445             else
00446                 name = strdup (_("DVD+R"));
00447             break;
00448             
00449         case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW:
00450             if (libhal_volume_disc_is_blank (volume))
00451                 name = strdup (_("Blank DVD+RW"));
00452             else
00453                 name = strdup (_("DVD+RW"));
00454             break;
00455         
00456         case LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR_DL:
00457             if (libhal_volume_disc_is_blank (volume))
00458                 name = strdup (_("Blank DVD+R Dual-Layer"));
00459             else
00460                 name = strdup (_("DVD+R Dual-Layer"));
00461             break;
00462         
00463         case LIBHAL_VOLUME_DISC_TYPE_BDROM:
00464             name = strdup (_("BD-ROM"));
00465             break;
00466             
00467         case LIBHAL_VOLUME_DISC_TYPE_BDR:
00468             if (libhal_volume_disc_is_blank (volume))
00469                 name = strdup (_("Blank BD-R"));
00470             else
00471                 name = strdup (_("BD-R"));
00472             break;
00473         
00474         case LIBHAL_VOLUME_DISC_TYPE_BDRE:
00475             if (libhal_volume_disc_is_blank (volume))
00476                 name = strdup (_("Blank BD-RE"));
00477             else
00478                 name = strdup (_("BD-RE"));
00479             break;
00480         
00481         case LIBHAL_VOLUME_DISC_TYPE_HDDVDROM:
00482             name = strdup (_("HD DVD-ROM"));
00483             break;
00484             
00485         case LIBHAL_VOLUME_DISC_TYPE_HDDVDR:
00486             if (libhal_volume_disc_is_blank (volume))
00487                 name = strdup (_("Blank HD DVD-R"));
00488             else
00489                 name = strdup (_("HD DVD-R"));
00490             break;
00491             
00492         case LIBHAL_VOLUME_DISC_TYPE_HDDVDRW:
00493             if (libhal_volume_disc_is_blank (volume))
00494                 name = strdup (_("Blank HD DVD-RW"));
00495             else
00496                 name = strdup (_("HD DVD-RW"));
00497             break;
00498 
00499         }
00500         
00501         /* Special case for pure audio disc */
00502         if (libhal_volume_disc_has_audio (volume) && !libhal_volume_disc_has_data (volume)) {
00503             free (name);
00504             name = strdup (_("Audio CD"));
00505         }
00506 
00507         goto out;
00508     }
00509 
00510     /* Fallback: size of media */
00511     if (drive_is_removable) {
00512         snprintf (buf, MAX_STRING_SZ, _("%s Removable Media"), size_str);
00513         name = strdup (buf);
00514     } else {
00515         snprintf (buf, MAX_STRING_SZ, _("%s Media"), size_str);
00516         name = strdup (buf);
00517     }
00518 
00519     /* Fallback: Use drive name */
00520     /*name = libhal_drive_policy_compute_display_name (drive, volume);*/
00521 
00522 out:
00523     free (size_str);
00524     return name;
00525 }
00526 
00527 char *
00528 libhal_drive_policy_compute_icon_name (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
00529 {
00530     const char *name;
00531     LibHalDriveBus bus;
00532     LibHalDriveType drive_type;
00533 
00534     bus        = libhal_drive_get_bus (drive);
00535     drive_type = libhal_drive_get_type (drive);
00536 
00537     /* by design, the enums are laid out so we can do easy computations */
00538 
00539     switch (drive_type) {
00540     case LIBHAL_DRIVE_TYPE_REMOVABLE_DISK:
00541     case LIBHAL_DRIVE_TYPE_DISK:
00542     case LIBHAL_DRIVE_TYPE_CDROM:
00543     case LIBHAL_DRIVE_TYPE_FLOPPY:
00544         name = libhal_storage_policy_lookup_icon (policy, 0x10000 + drive_type*0x100 + bus);
00545         break;
00546 
00547     default:
00548         name = libhal_storage_policy_lookup_icon (policy, 0x10000 + drive_type*0x100);
00549     }
00550 
00551     if (name != NULL)
00552         return strdup (name);
00553     else
00554         return NULL;
00555 }
00556 
00557 char *
00558 libhal_volume_policy_compute_icon_name (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
00559 {
00560     const char *name;
00561     LibHalDriveBus bus;
00562     LibHalDriveType drive_type;
00563     LibHalVolumeDiscType disc_type;
00564 
00565     /* by design, the enums are laid out so we can do easy computations */
00566 
00567     if (libhal_volume_is_disc (volume)) {
00568         disc_type = libhal_volume_get_disc_type (volume);
00569         name = libhal_storage_policy_lookup_icon (policy, 0x30000 + disc_type);
00570         goto out;
00571     }
00572 
00573     if (drive == NULL) {
00574         name = libhal_storage_policy_lookup_icon (policy, LIBHAL_STORAGE_ICON_VOLUME_REMOVABLE_DISK);
00575         goto out;
00576     }
00577 
00578     bus        = libhal_drive_get_bus (drive);
00579     drive_type = libhal_drive_get_type (drive);
00580 
00581     switch (drive_type) {
00582     case LIBHAL_DRIVE_TYPE_REMOVABLE_DISK:
00583     case LIBHAL_DRIVE_TYPE_DISK:
00584     case LIBHAL_DRIVE_TYPE_CDROM:
00585     case LIBHAL_DRIVE_TYPE_FLOPPY:
00586         name = libhal_storage_policy_lookup_icon (policy, 0x20000 + drive_type*0x100 + bus);
00587         break;
00588 
00589     default:
00590         name = libhal_storage_policy_lookup_icon (policy, 0x20000 + drive_type*0x100);
00591     }
00592 out:
00593     if (name != NULL)
00594         return strdup (name);
00595     else
00596         return NULL;
00597 }
00598 
00615 dbus_bool_t
00616 libhal_volume_policy_should_be_visible (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy, 
00617                      const char *target_mount_point)
00618 {
00619     unsigned int i;
00620     dbus_bool_t is_visible;
00621     const char *label;
00622     const char *mount_point;
00623     const char *fstype;
00624     const char *fhs23_toplevel_mount_points[] = {
00625         "/",
00626         "/bin",
00627         "/boot",
00628         "/dev",
00629         "/etc",
00630         "/home",
00631         "/lib",
00632         "/lib64",
00633         "/media",
00634         "/mnt",
00635         "/opt",
00636         "/root",
00637         "/sbin",
00638         "/srv",
00639         "/tmp",
00640         "/usr",
00641         "/var",
00642         "/proc",
00643         "/sbin",
00644         NULL
00645     };
00646 
00647     is_visible = FALSE;
00648 
00649     /* skip if hal says it's not used as a filesystem */
00650     if (libhal_volume_get_fsusage (volume) != LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM)
00651         goto out;
00652 
00653     label = libhal_volume_get_label (volume);
00654     mount_point = libhal_volume_get_mount_point (volume);
00655     fstype = libhal_volume_get_fstype (volume);
00656 
00657     /* use target mount point if we're not mounted yet */
00658     if (mount_point == NULL)
00659         mount_point = target_mount_point;
00660 
00661     /* bail out if we don't know the filesystem */
00662     if (fstype == NULL)
00663         goto out;
00664 
00665     /* blacklist fhs2.3 top level mount points */
00666     if (mount_point != NULL) {
00667         for (i = 0; fhs23_toplevel_mount_points[i] != NULL; i++) {
00668             if (strcmp (mount_point, fhs23_toplevel_mount_points[i]) == 0)
00669                 goto out;
00670         }
00671     }
00672 
00673     /* blacklist partitions with name 'bootstrap' of type HFS (Apple uses that) */
00674     if (label != NULL && strcmp (label, "bootstrap") == 0 && strcmp (fstype, "hfs") == 0)
00675         goto out;
00676 
00677     /* only the real lucky mount points will make it this far :-) */
00678     is_visible = TRUE;
00679 
00680 out:
00681     return is_visible;
00682 }
00683 
00684 /*************************************************************************/
00685 
00686 #define MOUNT_OPTIONS_SIZE 256
00687 
00688 struct LibHalDrive_s {
00689     char *udi;
00690 
00691     int device_major;
00692     int device_minor;
00693     char *device_file;
00694 
00695     LibHalDriveBus bus;
00696     char *vendor;             /* may be "", is never NULL */
00697     char *model;              /* may be "", is never NULL */
00698     dbus_bool_t is_hotpluggable;
00699     dbus_bool_t is_removable;
00700     dbus_bool_t requires_eject;
00701 
00702     LibHalDriveType type;
00703     char *type_textual;
00704 
00705     char *physical_device;  /* UDI of physical device, e.g. the 
00706                  * IDE, USB, IEEE1394 device */
00707 
00708     char *dedicated_icon_drive;
00709     char *dedicated_icon_volume;
00710 
00711     char *serial;
00712     char *firmware_version;
00713     LibHalDriveCdromCaps cdrom_caps;
00714 
00715     char *desired_mount_point;
00716     char *mount_filesystem;
00717     dbus_bool_t should_mount;
00718 
00719     dbus_bool_t no_partitions_hint;
00720 
00721     LibHalContext *hal_ctx;
00722 
00723     char **capabilities;
00724 
00725     char mount_options[MOUNT_OPTIONS_SIZE];
00726 };
00727 
00728 struct LibHalVolume_s {
00729     char *udi;
00730 
00731     int device_major;
00732     int device_minor;
00733     char *device_file;
00734     char *volume_label; /* may be NULL, is never "" */
00735     dbus_bool_t is_mounted;
00736     char *mount_point;  /* NULL iff !is_mounted */
00737     char *fstype;       /* NULL iff !is_mounted or unknown */
00738     char *fsversion;
00739     char *uuid;
00740     char *storage_device;
00741 
00742     LibHalVolumeUsage fsusage;
00743 
00744     dbus_bool_t is_partition;
00745     unsigned int partition_number;
00746 
00747     int msdos_part_table_type;
00748     
00749 
00750     dbus_bool_t is_disc;
00751     LibHalVolumeDiscType disc_type;
00752     dbus_bool_t disc_has_audio;
00753     dbus_bool_t disc_has_data;
00754     dbus_bool_t disc_is_appendable;
00755     dbus_bool_t disc_is_blank;
00756     dbus_bool_t disc_is_rewritable;
00757 
00758     unsigned int block_size;
00759     unsigned int num_blocks;
00760 
00761     char *desired_mount_point;
00762     char *mount_filesystem;
00763     dbus_bool_t should_mount;
00764 
00765     dbus_bool_t ignore_volume;
00766 
00767     char *crypto_backing_volume;
00768 
00769     char mount_options[MOUNT_OPTIONS_SIZE];
00770 };
00771 
00772 const char *
00773 libhal_drive_get_dedicated_icon_drive (LibHalDrive *drive)
00774 {
00775     return drive->dedicated_icon_drive;
00776 }
00777 
00778 const char *
00779 libhal_drive_get_dedicated_icon_volume (LibHalDrive *drive)
00780 {
00781     return drive->dedicated_icon_volume;
00782 }
00783 
00788 void
00789 libhal_drive_free (LibHalDrive *drive)
00790 {
00791     if (drive == NULL )
00792         return;
00793 
00794     free (drive->udi);
00795     libhal_free_string (drive->device_file);
00796     libhal_free_string (drive->vendor);
00797     libhal_free_string (drive->model);
00798     libhal_free_string (drive->type_textual);
00799     libhal_free_string (drive->physical_device);
00800     libhal_free_string (drive->serial);
00801     libhal_free_string (drive->firmware_version);
00802     libhal_free_string (drive->desired_mount_point);
00803     libhal_free_string (drive->mount_filesystem);
00804     libhal_free_string_array (drive->capabilities);
00805 
00806     free (drive);
00807 }
00808 
00809 
00814 void
00815 libhal_volume_free (LibHalVolume *vol)
00816 {
00817     if (vol == NULL )
00818         return;
00819 
00820     free (vol->udi);
00821     libhal_free_string (vol->device_file);
00822     libhal_free_string (vol->volume_label);
00823     libhal_free_string (vol->fstype);
00824     libhal_free_string (vol->mount_point);
00825     libhal_free_string (vol->fsversion);
00826     libhal_free_string (vol->uuid);
00827     libhal_free_string (vol->desired_mount_point);
00828     libhal_free_string (vol->mount_filesystem);
00829     libhal_free_string (vol->crypto_backing_volume);
00830 
00831     free (vol);
00832 }
00833 
00834 
00835 static char **
00836 my_strvdup (char **strv)
00837 {
00838     unsigned int num_elems;
00839     unsigned int i;
00840     char **res;
00841 
00842     for (num_elems = 0; strv[num_elems] != NULL; num_elems++)
00843         ;
00844 
00845     res = calloc (num_elems + 1, sizeof (char*));
00846     if (res == NULL)
00847         goto out;
00848 
00849     for (i = 0; i < num_elems; i++)
00850         res[i] = strdup (strv[i]);
00851     res[i] = NULL;
00852 
00853 out:
00854     return res;
00855 }
00856 
00857 /* ok, hey, so this is a bit ugly */
00858 
00859 #define LIBHAL_PROP_EXTRACT_BEGIN if (FALSE)
00860 #define LIBHAL_PROP_EXTRACT_END ;
00861 #define LIBHAL_PROP_EXTRACT_INT(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_INT32) _where_ = libhal_psi_get_int (&it)
00862 #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
00863 #define LIBHAL_PROP_EXTRACT_BOOL(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_BOOLEAN) _where_ = libhal_psi_get_bool (&it)
00864 #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
00865 #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))
00866 
00875 LibHalDrive *
00876 libhal_drive_from_udi (LibHalContext *hal_ctx, const char *udi)
00877 {   
00878     char *bus_textual;
00879     LibHalDrive *drive;
00880     LibHalPropertySet *properties;
00881     LibHalPropertySetIterator it;
00882     DBusError error;
00883     unsigned int i;
00884 
00885     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
00886 
00887     drive = NULL;
00888     properties = NULL;
00889     bus_textual = NULL;
00890 
00891     dbus_error_init (&error);
00892     if (!libhal_device_query_capability (hal_ctx, udi, "storage", &error))
00893         goto error;
00894 
00895     drive = malloc (sizeof (LibHalDrive));
00896     if (drive == NULL)
00897         goto error;
00898     memset (drive, 0x00, sizeof (LibHalDrive));
00899 
00900     drive->hal_ctx = hal_ctx;
00901 
00902     drive->udi = strdup (udi);
00903     if (drive->udi == NULL)
00904         goto error;
00905 
00906     properties = libhal_device_get_all_properties (hal_ctx, udi, &error);
00907     if (properties == NULL)
00908         goto error;
00909 
00910     /* we can count on hal to give us all these properties */
00911     for (libhal_psi_init (&it, properties); libhal_psi_has_more (&it); libhal_psi_next (&it)) {
00912         int type;
00913         char *key;
00914         
00915         type = libhal_psi_get_type (&it);
00916         key = libhal_psi_get_key (&it);
00917 
00918         LIBHAL_PROP_EXTRACT_BEGIN;
00919 
00920         LIBHAL_PROP_EXTRACT_INT    ("block.minor",               drive->device_minor);
00921         LIBHAL_PROP_EXTRACT_INT    ("block.major",               drive->device_major);
00922         LIBHAL_PROP_EXTRACT_STRING ("block.device",              drive->device_file);
00923         LIBHAL_PROP_EXTRACT_STRING ("storage.bus",               bus_textual);
00924         LIBHAL_PROP_EXTRACT_STRING ("storage.vendor",            drive->vendor);
00925         LIBHAL_PROP_EXTRACT_STRING ("storage.model",             drive->model);
00926         LIBHAL_PROP_EXTRACT_STRING ("storage.drive_type",        drive->type_textual);
00927 
00928 
00929         LIBHAL_PROP_EXTRACT_STRING ("storage.icon.drive",        drive->dedicated_icon_drive);
00930         LIBHAL_PROP_EXTRACT_STRING ("storage.icon.volume",       drive->dedicated_icon_volume);
00931 
00932         LIBHAL_PROP_EXTRACT_BOOL   ("storage.hotpluggable",      drive->is_hotpluggable);
00933         LIBHAL_PROP_EXTRACT_BOOL   ("storage.removable",         drive->is_removable);
00934         LIBHAL_PROP_EXTRACT_BOOL   ("storage.requires_eject",    drive->requires_eject);
00935 
00936         LIBHAL_PROP_EXTRACT_STRING ("storage.physical_device",   drive->physical_device);
00937         LIBHAL_PROP_EXTRACT_STRING ("storage.firmware_version",  drive->firmware_version);
00938         LIBHAL_PROP_EXTRACT_STRING ("storage.serial",            drive->serial);
00939 
00940         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.cdr", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_CDR);
00941         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.cdrw", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_CDRW);
00942         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.dvd", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDROM);
00943         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.dvdplusr", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSR);
00944         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.dvdplusrw", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRW);
00945         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.dvdplusrdl", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDPLUSRDL);
00946         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.dvdr", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDR);
00947         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.dvdrw", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDRW);
00948         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.dvdram", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_DVDRAM);
00949         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.bd", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_BDROM);
00950         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.bdr", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_BDR);
00951         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.bdre", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_BDRE);
00952         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.hddvd", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_HDDVDROM);
00953         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.hddvdr", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_HDDVDR);
00954         LIBHAL_PROP_EXTRACT_BOOL_BITFIELD ("storage.cdrom.hddvdrw", drive->cdrom_caps, LIBHAL_DRIVE_CDROM_CAPS_HDDVDRW);
00955 
00956         LIBHAL_PROP_EXTRACT_BOOL   ("storage.policy.should_mount",        drive->should_mount);
00957         LIBHAL_PROP_EXTRACT_STRING ("storage.policy.desired_mount_point", drive->desired_mount_point);
00958         LIBHAL_PROP_EXTRACT_STRING ("storage.policy.mount_filesystem",    drive->mount_filesystem);
00959 
00960         LIBHAL_PROP_EXTRACT_BOOL   ("storage.no_partitions_hint",        drive->no_partitions_hint);
00961 
00962         LIBHAL_PROP_EXTRACT_STRLIST ("info.capabilities",                drive->capabilities);
00963 
00964         LIBHAL_PROP_EXTRACT_END;
00965     }
00966 
00967     if (drive->type_textual != NULL) {
00968         if (strcmp (drive->type_textual, "cdrom") == 0) {
00969             drive->cdrom_caps |= LIBHAL_DRIVE_CDROM_CAPS_CDROM;
00970             drive->type = LIBHAL_DRIVE_TYPE_CDROM;
00971         } else if (strcmp (drive->type_textual, "floppy") == 0) {
00972             drive->type = LIBHAL_DRIVE_TYPE_FLOPPY;
00973         } else if (strcmp (drive->type_textual, "disk") == 0) {
00974             if (drive->is_removable)
00975                 drive->type = LIBHAL_DRIVE_TYPE_REMOVABLE_DISK;
00976             else
00977                 drive->type = LIBHAL_DRIVE_TYPE_DISK;               
00978         } else if (strcmp (drive->type_textual, "tape") == 0) {
00979             drive->type = LIBHAL_DRIVE_TYPE_TAPE;
00980         } else if (strcmp (drive->type_textual, "compact_flash") == 0) {
00981             drive->type = LIBHAL_DRIVE_TYPE_COMPACT_FLASH;
00982         } else if (strcmp (drive->type_textual, "memory_stick") == 0) {
00983             drive->type = LIBHAL_DRIVE_TYPE_MEMORY_STICK;
00984         } else if (strcmp (drive->type_textual, "smart_media") == 0) {
00985             drive->type = LIBHAL_DRIVE_TYPE_SMART_MEDIA;
00986         } else if (strcmp (drive->type_textual, "sd_mmc") == 0) {
00987             drive->type = LIBHAL_DRIVE_TYPE_SD_MMC;
00988         } else if (strcmp (drive->type_textual, "zip") == 0) {
00989             drive->type = LIBHAL_DRIVE_TYPE_ZIP;
00990         } else if (strcmp (drive->type_textual, "jaz") == 0) {
00991             drive->type = LIBHAL_DRIVE_TYPE_JAZ;
00992         } else if (strcmp (drive->type_textual, "flashkey") == 0) {
00993             drive->type = LIBHAL_DRIVE_TYPE_FLASHKEY;
00994         } else {
00995                 drive->type = LIBHAL_DRIVE_TYPE_DISK; 
00996         }
00997 
00998     }
00999 
01000     if (drive->capabilities != NULL) {
01001         for (i = 0; drive->capabilities[i] != NULL; i++) {
01002             if (strcmp (drive->capabilities[i], "portable_audio_player") == 0) {
01003                 drive->type = LIBHAL_DRIVE_TYPE_PORTABLE_AUDIO_PLAYER;
01004                 break;
01005             } else if (strcmp (drive->capabilities[i], "camera") == 0) {
01006                 drive->type = LIBHAL_DRIVE_TYPE_CAMERA;
01007                 break;
01008             }
01009         }
01010     }
01011 
01012     if (bus_textual != NULL) {
01013         if (strcmp (bus_textual, "usb") == 0) {
01014             drive->bus = LIBHAL_DRIVE_BUS_USB;
01015         } else if (strcmp (bus_textual, "ieee1394") == 0) {
01016             drive->bus = LIBHAL_DRIVE_BUS_IEEE1394;
01017         } else if (strcmp (bus_textual, "ide") == 0) {
01018             drive->bus = LIBHAL_DRIVE_BUS_IDE;
01019         } else if (strcmp (bus_textual, "scsi") == 0) {
01020             drive->bus = LIBHAL_DRIVE_BUS_SCSI;
01021         } else if (strcmp (bus_textual, "ccw") == 0) {
01022             drive->bus = LIBHAL_DRIVE_BUS_CCW;
01023         }
01024     }
01025 
01026     libhal_free_string (bus_textual);
01027     libhal_free_property_set (properties);
01028 
01029     return drive;
01030 
01031 error:
01032     libhal_free_string (bus_textual);
01033     libhal_free_property_set (properties);
01034     libhal_drive_free (drive);
01035     return NULL;
01036 }
01037 
01038 const char *
01039 libhal_volume_get_storage_device_udi (LibHalVolume *volume)
01040 {
01041     return volume->storage_device;
01042 }
01043 
01044 const char *libhal_drive_get_physical_device_udi (LibHalDrive *drive)
01045 {
01046     return drive->physical_device;
01047 }
01048 
01049 dbus_bool_t
01050 libhal_drive_requires_eject (LibHalDrive *drive)
01051 {
01052     return drive->requires_eject;
01053 }
01054 
01063 LibHalVolume *
01064 libhal_volume_from_udi (LibHalContext *hal_ctx, const char *udi)
01065 {
01066     char *disc_type_textual;
01067     char *vol_fsusage_textual;
01068     LibHalVolume *vol;
01069     LibHalPropertySet *properties;
01070     LibHalPropertySetIterator it;
01071     DBusError error;
01072 
01073     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01074 
01075     vol = NULL;
01076     properties = NULL;
01077     disc_type_textual = NULL;
01078     vol_fsusage_textual = NULL;
01079 
01080     dbus_error_init (&error);
01081     if (!libhal_device_query_capability (hal_ctx, udi, "volume", &error))
01082         goto error;
01083 
01084     vol = malloc (sizeof (LibHalVolume));
01085     if (vol == NULL)
01086         goto error;
01087     memset (vol, 0x00, sizeof (LibHalVolume));
01088 
01089     vol->udi = strdup (udi);
01090 
01091     properties = libhal_device_get_all_properties (hal_ctx, udi, &error);
01092     if (properties == NULL)
01093         goto error;
01094 
01095     /* we can count on hal to give us all these properties */
01096     for (libhal_psi_init (&it, properties); libhal_psi_has_more (&it); libhal_psi_next (&it)) {
01097         int type;
01098         char *key;
01099         
01100         type = libhal_psi_get_type (&it);
01101         key = libhal_psi_get_key (&it);
01102 
01103         LIBHAL_PROP_EXTRACT_BEGIN;
01104 
01105         LIBHAL_PROP_EXTRACT_INT    ("volume.partition.msdos_part_table_type", vol->msdos_part_table_type);
01106 
01107         LIBHAL_PROP_EXTRACT_INT    ("block.minor",               vol->device_minor);
01108         LIBHAL_PROP_EXTRACT_INT    ("block.major",               vol->device_major);
01109         LIBHAL_PROP_EXTRACT_STRING ("block.device",              vol->device_file);
01110 
01111         LIBHAL_PROP_EXTRACT_STRING ("block.storage_device",      vol->storage_device);
01112 
01113         LIBHAL_PROP_EXTRACT_STRING ("volume.crypto_luks.clear.backing_volume", vol->crypto_backing_volume);
01114 
01115         LIBHAL_PROP_EXTRACT_INT    ("volume.block_size",         vol->block_size);
01116         LIBHAL_PROP_EXTRACT_INT    ("volume.num_blocks",         vol->num_blocks);
01117         LIBHAL_PROP_EXTRACT_STRING ("volume.label",              vol->volume_label);
01118         LIBHAL_PROP_EXTRACT_STRING ("volume.mount_point",        vol->mount_point);
01119         LIBHAL_PROP_EXTRACT_STRING ("volume.fstype",             vol->fstype);
01120         LIBHAL_PROP_EXTRACT_STRING ("volume.fsversion",             vol->fsversion);
01121         LIBHAL_PROP_EXTRACT_BOOL   ("volume.is_mounted",         vol->is_mounted);
01122         LIBHAL_PROP_EXTRACT_STRING ("volume.fsusage",            vol_fsusage_textual);
01123         LIBHAL_PROP_EXTRACT_STRING ("volume.uuid",               vol->uuid);
01124 
01125         LIBHAL_PROP_EXTRACT_BOOL   ("volume.ignore",             vol->ignore_volume);
01126 
01127         LIBHAL_PROP_EXTRACT_BOOL   ("volume.is_disc",            vol->is_disc);
01128         LIBHAL_PROP_EXTRACT_STRING ("volume.disc.type",          disc_type_textual);
01129         LIBHAL_PROP_EXTRACT_BOOL   ("volume.disc.has_audio",     vol->disc_has_audio);
01130         LIBHAL_PROP_EXTRACT_BOOL   ("volume.disc.has_data",      vol->disc_has_data);
01131         LIBHAL_PROP_EXTRACT_BOOL   ("volume.disc.is_appendable", vol->disc_is_appendable);
01132         LIBHAL_PROP_EXTRACT_BOOL   ("volume.disc.is_blank",      vol->disc_is_blank);
01133         LIBHAL_PROP_EXTRACT_BOOL   ("volume.disc.is_rewritable", vol->disc_is_rewritable);
01134 
01135         LIBHAL_PROP_EXTRACT_BOOL   ("volume.policy.should_mount",        vol->should_mount);
01136         LIBHAL_PROP_EXTRACT_STRING ("volume.policy.desired_mount_point", vol->desired_mount_point);
01137         LIBHAL_PROP_EXTRACT_STRING ("volume.policy.mount_filesystem",    vol->mount_filesystem);
01138 
01139         LIBHAL_PROP_EXTRACT_END;
01140     }
01141 
01142     if (disc_type_textual != NULL) {
01143         if (strcmp (disc_type_textual, "cd_rom") == 0) {
01144             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_CDROM;
01145         } else if (strcmp (disc_type_textual, "cd_r") == 0) {
01146             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_CDR;
01147         } else if (strcmp (disc_type_textual, "cd_rw") == 0) {
01148             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_CDRW;
01149         } else if (strcmp (disc_type_textual, "dvd_rom") == 0) {
01150             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDROM;
01151         } else if (strcmp (disc_type_textual, "dvd_ram") == 0) {
01152             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDRAM;
01153         } else if (strcmp (disc_type_textual, "dvd_r") == 0) {
01154             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDR;
01155         } else if (strcmp (disc_type_textual, "dvd_rw") == 0) {
01156             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDRW;
01157         } else if (strcmp (disc_type_textual, "dvd_plus_r") == 0) {
01158             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR;
01159         } else if (strcmp (disc_type_textual, "dvd_plus_rw") == 0) {
01160             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDPLUSRW;
01161         } else if (strcmp (disc_type_textual, "dvd_plus_r_dl") == 0) {
01162             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_DVDPLUSR_DL;
01163         } else if (strcmp (disc_type_textual, "bd_rom") == 0) {
01164             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_BDROM;
01165         } else if (strcmp (disc_type_textual, "bd_r") == 0) {
01166             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_BDR;
01167         } else if (strcmp (disc_type_textual, "bd_re") == 0) {
01168             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_BDRE;
01169         } else if (strcmp (disc_type_textual, "hddvd_rom") == 0) {
01170             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_HDDVDROM;
01171         } else if (strcmp (disc_type_textual, "hddvd_r") == 0) {
01172             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_HDDVDR;
01173         } else if (strcmp (disc_type_textual, "hddvd_rw") == 0) {
01174             vol->disc_type = LIBHAL_VOLUME_DISC_TYPE_HDDVDRW;
01175         }
01176     }
01177 
01178     vol->fsusage = LIBHAL_VOLUME_USAGE_UNKNOWN;
01179     if (vol_fsusage_textual != NULL) {
01180         if (strcmp (vol_fsusage_textual, "filesystem") == 0) {
01181             vol->fsusage = LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM;
01182         } else if (strcmp (vol_fsusage_textual, "partitiontable") == 0) {
01183             vol->fsusage = LIBHAL_VOLUME_USAGE_PARTITION_TABLE;
01184         } else if (strcmp (vol_fsusage_textual, "raid") == 0) {
01185             vol->fsusage = LIBHAL_VOLUME_USAGE_RAID_MEMBER;
01186         } else if (strcmp (vol_fsusage_textual, "crypto") == 0) {
01187             vol->fsusage = LIBHAL_VOLUME_USAGE_CRYPTO;
01188         } else {
01189             vol->fsusage = LIBHAL_VOLUME_USAGE_UNKNOWN;
01190         } 
01191     }
01192 
01193     libhal_free_string (vol_fsusage_textual);
01194     libhal_free_string (disc_type_textual);
01195     libhal_free_property_set (properties);
01196     return vol;
01197 error:
01198     libhal_free_string (vol_fsusage_textual);
01199     libhal_free_string (disc_type_textual);
01200     libhal_free_property_set (properties);
01201     libhal_volume_free (vol);
01202     return NULL;
01203 }
01204 
01205 
01214 int
01215 libhal_volume_get_msdos_part_table_type (LibHalVolume *volume)
01216 {
01217     return volume->msdos_part_table_type;
01218 }
01219 
01220 /***********************************************************************/
01221 
01229 LibHalDrive *
01230 libhal_drive_from_device_file (LibHalContext *hal_ctx, const char *device_file)
01231 {
01232     int i;
01233     char **hal_udis;
01234     int num_hal_udis;
01235     LibHalDrive *result;
01236     char *found_udi;
01237     DBusError error;
01238 
01239     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01240 
01241     result = NULL;
01242     found_udi = NULL;
01243 
01244     dbus_error_init (&error);
01245     if ((hal_udis = libhal_manager_find_device_string_match (hal_ctx, "block.device", 
01246                                  device_file, &num_hal_udis, &error)) == NULL)
01247         goto out;
01248 
01249     for (i = 0; i < num_hal_udis; i++) {
01250         char *udi;
01251         char *storage_udi;
01252         DBusError err1;
01253         DBusError err2;
01254         udi = hal_udis[i];
01255 
01256         dbus_error_init (&err1);
01257         dbus_error_init (&err2);
01258         if (libhal_device_query_capability (hal_ctx, udi, "volume", &err1)) {
01259 
01260             storage_udi = libhal_device_get_property_string (hal_ctx, udi, "block.storage_device", &err1);
01261             if (storage_udi == NULL)
01262                 continue;
01263             found_udi = strdup (storage_udi);
01264             libhal_free_string (storage_udi);
01265             break;
01266         } else if (libhal_device_query_capability (hal_ctx, udi, "storage", &err2)) {
01267             found_udi = strdup (udi);
01268         }
01269     }
01270 
01271     libhal_free_string_array (hal_udis);
01272 
01273     if (found_udi != NULL)
01274         result = libhal_drive_from_udi (hal_ctx, found_udi);
01275 
01276     free (found_udi);
01277 out:
01278     return result;
01279 }
01280 
01281 
01288 LibHalVolume *
01289 libhal_volume_from_device_file (LibHalContext *hal_ctx, const char *device_file)
01290 {
01291     int i;
01292     char **hal_udis;
01293     int num_hal_udis;
01294     LibHalVolume *result;
01295     char *found_udi;
01296     DBusError error;
01297 
01298     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01299 
01300     result = NULL;
01301     found_udi = NULL;
01302 
01303     dbus_error_init (&error);
01304     if ((hal_udis = libhal_manager_find_device_string_match (hal_ctx, "block.device", 
01305                                  device_file, &num_hal_udis, &error)) == NULL)
01306         goto out;
01307 
01308     for (i = 0; i < num_hal_udis; i++) {
01309         char *udi;
01310         udi = hal_udis[i];
01311         if (libhal_device_query_capability (hal_ctx, udi, "volume", &error)) {
01312             found_udi = strdup (udi);
01313             break;
01314         }
01315     }
01316 
01317     libhal_free_string_array (hal_udis);
01318 
01319     if (found_udi != NULL)
01320         result = libhal_volume_from_udi (hal_ctx, found_udi);
01321 
01322     free (found_udi);
01323 out:
01324     return result;
01325 }
01326 
01327 dbus_uint64_t
01328 libhal_volume_get_size (LibHalVolume *volume)
01329 {
01330     return ((dbus_uint64_t)volume->block_size) * ((dbus_uint64_t)volume->num_blocks);
01331 }
01332 
01333 
01334 dbus_bool_t
01335 libhal_drive_is_hotpluggable (LibHalDrive *drive)
01336 {
01337     return drive->is_hotpluggable;
01338 }
01339 
01340 dbus_bool_t
01341 libhal_drive_uses_removable_media (LibHalDrive *drive)
01342 {
01343     return drive->is_removable;
01344 }
01345 
01346 LibHalDriveType
01347 libhal_drive_get_type (LibHalDrive *drive)
01348 {
01349     return drive->type;
01350 }
01351 
01352 LibHalDriveBus
01353 libhal_drive_get_bus (LibHalDrive *drive)
01354 {
01355     return drive->bus;
01356 }
01357 
01358 LibHalDriveCdromCaps
01359 libhal_drive_get_cdrom_caps (LibHalDrive *drive)
01360 {
01361     return drive->cdrom_caps;
01362 }
01363 
01364 unsigned int
01365 libhal_drive_get_device_major (LibHalDrive *drive)
01366 {
01367     return drive->device_major;
01368 }
01369 
01370 unsigned int
01371 libhal_drive_get_device_minor (LibHalDrive *drive)
01372 {
01373     return drive->device_minor;
01374 }
01375 
01376 const char *
01377 libhal_drive_get_type_textual (LibHalDrive *drive)
01378 {
01379     return drive->type_textual;
01380 }
01381 
01382 const char *
01383 libhal_drive_get_device_file (LibHalDrive *drive)
01384 {
01385     return drive->device_file;
01386 }
01387 
01388 const char *
01389 libhal_drive_get_udi (LibHalDrive *drive)
01390 {
01391     return drive->udi;
01392 }
01393 
01394 const char *
01395 libhal_drive_get_serial (LibHalDrive *drive)
01396 {
01397     return drive->serial;
01398 }
01399 
01400 const char *
01401 libhal_drive_get_firmware_version (LibHalDrive *drive)
01402 {
01403     return drive->firmware_version;
01404 }
01405 
01406 const char *
01407 libhal_drive_get_model (LibHalDrive *drive)
01408 {
01409     return drive->model;
01410 }
01411 
01412 const char *
01413 libhal_drive_get_vendor (LibHalDrive *drive)
01414 {
01415     return drive->vendor;
01416 }
01417 
01418 /*****************************************************************************/
01419 
01420 const char *
01421 libhal_volume_get_udi (LibHalVolume *volume)
01422 {
01423     return volume->udi;
01424 }
01425 
01426 const char *
01427 libhal_volume_get_device_file (LibHalVolume *volume)
01428 {
01429     return volume->device_file;
01430 }
01431 
01432 unsigned int libhal_volume_get_device_major (LibHalVolume *volume)
01433 {
01434     return volume->device_major;
01435 }
01436 
01437 unsigned int libhal_volume_get_device_minor (LibHalVolume *volume)
01438 {
01439     return volume->device_minor;
01440 }
01441 
01442 const char *
01443 libhal_volume_get_fstype (LibHalVolume *volume)
01444 {
01445     return volume->fstype;
01446 }
01447 
01448 const char *
01449 libhal_volume_get_fsversion (LibHalVolume *volume)
01450 {
01451     return volume->fsversion;
01452 }
01453 
01454 LibHalVolumeUsage 
01455 libhal_volume_get_fsusage (LibHalVolume *volume)
01456 {
01457     return volume->fsusage;
01458 }
01459 
01460 dbus_bool_t 
01461 libhal_volume_is_mounted (LibHalVolume *volume)
01462 {
01463     return volume->is_mounted;
01464 }
01465 
01466 dbus_bool_t 
01467 libhal_volume_is_partition (LibHalVolume *volume)
01468 {
01469     return volume->is_partition;
01470 }
01471 
01472 dbus_bool_t
01473 libhal_volume_is_disc (LibHalVolume *volume)
01474 {
01475     return volume->is_disc;
01476 }
01477 
01478 unsigned int
01479 libhal_volume_get_partition_number (LibHalVolume *volume)
01480 {
01481     return volume->partition_number;
01482 }
01483 
01484 const char *
01485 libhal_volume_get_label (LibHalVolume *volume)
01486 {
01487     return volume->volume_label;
01488 }
01489 
01490 const char *
01491 libhal_volume_get_mount_point (LibHalVolume *volume)
01492 {
01493     return volume->mount_point;
01494 }
01495 
01496 const char *
01497 libhal_volume_get_uuid (LibHalVolume *volume)
01498 {
01499     return volume->uuid;
01500 }
01501 
01502 dbus_bool_t
01503 libhal_volume_disc_has_audio (LibHalVolume *volume)
01504 {
01505     return volume->disc_has_audio;
01506 }
01507 
01508 dbus_bool_t
01509 libhal_volume_disc_has_data (LibHalVolume *volume)
01510 {
01511     return volume->disc_has_data;
01512 }
01513 
01514 dbus_bool_t
01515 libhal_volume_disc_is_blank (LibHalVolume *volume)
01516 {
01517     return volume->disc_is_blank;
01518 }
01519 
01520 dbus_bool_t
01521 libhal_volume_disc_is_rewritable (LibHalVolume *volume)
01522 {
01523     return volume->disc_is_rewritable;
01524 }
01525 
01526 dbus_bool_t
01527 libhal_volume_disc_is_appendable (LibHalVolume *volume)
01528 {
01529     return volume->disc_is_appendable;
01530 }
01531 
01532 LibHalVolumeDiscType
01533 libhal_volume_get_disc_type (LibHalVolume *volume)
01534 {
01535     return volume->disc_type;
01536 }
01537 
01538 dbus_bool_t
01539 libhal_volume_should_ignore (LibHalVolume     *volume)
01540 {
01541     return volume->ignore_volume;
01542 }
01543 
01544 char ** 
01545 libhal_drive_find_all_volumes (LibHalContext *hal_ctx, LibHalDrive *drive, int *num_volumes)
01546 {
01547     int i;
01548     char **udis;
01549     int num_udis;
01550     const char *drive_udi;
01551     char **result;
01552     DBusError error;
01553 
01554     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01555 
01556     udis = NULL;
01557     result = NULL;
01558     *num_volumes = 0;
01559 
01560     drive_udi = libhal_drive_get_udi (drive);
01561     if (drive_udi == NULL)
01562         goto out;
01563 
01564     /* get initial list... */
01565     dbus_error_init (&error);
01566     if ((udis = libhal_manager_find_device_string_match (hal_ctx, "block.storage_device", 
01567                                  drive_udi, &num_udis, &error)) == NULL)
01568         goto out;
01569 
01570     result = malloc (sizeof (char *) * num_udis);
01571     if (result == NULL)
01572         goto out;
01573 
01574     /* ...and filter out the single UDI that is the drive itself */
01575     for (i = 0; i < num_udis; i++) {
01576         if (strcmp (udis[i], drive_udi) == 0)
01577             continue;
01578         result[*num_volumes] = strdup (udis[i]);
01579         *num_volumes = (*num_volumes) + 1;
01580     }
01581     /* set last element (above removed UDI) to NULL for libhal_free_string_array()*/
01582     result[*num_volumes] = NULL;
01583 
01584 out:
01585     libhal_free_string_array (udis);
01586     return result;
01587 }
01588 
01589 const char *
01590 libhal_volume_crypto_get_backing_volume_udi (LibHalVolume *volume)
01591 {
01592     return volume->crypto_backing_volume;
01593 }
01594 
01595 char *
01596 libhal_volume_crypto_get_clear_volume_udi (LibHalContext *hal_ctx, LibHalVolume *volume)
01597 {
01598     DBusError error;
01599     char **clear_devices;
01600     int num_clear_devices;
01601     char *result;
01602 
01603     result = NULL;
01604 
01605     LIBHAL_CHECK_LIBHALCONTEXT (hal_ctx, NULL);
01606 
01607     dbus_error_init (&error);
01608     clear_devices = libhal_manager_find_device_string_match (hal_ctx,
01609                                  "volume.crypto_luks.clear.backing_volume",
01610                                  volume->udi,
01611                                  &num_clear_devices,
01612                                  &error);
01613     if (clear_devices != NULL) {
01614 
01615         if (num_clear_devices >= 1) {
01616             result = strdup (clear_devices[0]);
01617         }
01618         libhal_free_string_array (clear_devices);
01619     }
01620 
01621     return result;
01622 }
01623 
01624 
01625 /*************************************************************************/
01626 
01627 char *
01628 libhal_drive_policy_default_get_mount_root (LibHalContext *hal_ctx)
01629 {
01630     DBusError error;
01631 
01632     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01633 
01634     dbus_error_init (&error);
01635     return libhal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer",
01636                           "storage.policy.default.mount_root", &error);
01637 }
01638 
01639 dbus_bool_t
01640 libhal_drive_policy_default_use_managed_keyword (LibHalContext *hal_ctx)
01641 {
01642     DBusError error;
01643 
01644     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, FALSE);
01645 
01646     dbus_error_init (&error);
01647     return libhal_device_get_property_bool (hal_ctx, "/org/freedesktop/Hal/devices/computer",
01648                         "storage.policy.default.use_managed_keyword", &error);
01649 }
01650 
01651 char *
01652 libhal_drive_policy_default_get_managed_keyword_primary (LibHalContext *hal_ctx)
01653 {
01654     DBusError error;
01655 
01656     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01657 
01658     dbus_error_init (&error);
01659     return libhal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer",
01660                           "storage.policy.default.managed_keyword.primary", &error);
01661 }
01662 
01663 char *
01664 libhal_drive_policy_default_get_managed_keyword_secondary (LibHalContext *hal_ctx)
01665 {
01666     DBusError error;
01667 
01668     LIBHAL_CHECK_LIBHALCONTEXT(hal_ctx, NULL);
01669 
01670     dbus_error_init (&error);
01671     return libhal_device_get_property_string (hal_ctx, "/org/freedesktop/Hal/devices/computer",
01672                           "storage.policy.default.managed_keyword.secondary", &error);
01673 }
01674 
01675 /*************************************************************************/
01676 
01677 dbus_bool_t
01678 libhal_drive_policy_is_mountable (LibHalDrive *drive, LibHalStoragePolicy *policy)
01679 {
01680     printf ("should_mount=%d, no_partitions_hint=%d\n", drive->should_mount, drive->no_partitions_hint);
01681 
01682     return drive->should_mount && drive->no_partitions_hint;
01683 }
01684 
01685 const char *
01686 libhal_drive_policy_get_desired_mount_point (LibHalDrive *drive, LibHalStoragePolicy *policy)
01687 {
01688     return drive->desired_mount_point;
01689 }
01690 
01691 /* safely strcat() at most the remaining space in 'dst' */
01692 #define strcat_len(dst, src, dstmaxlen) do {    \
01693     dst[dstmaxlen - 1] = '\0'; \
01694     strncat (dst, src, dstmaxlen - strlen (dst) - 1); \
01695 } while(0)
01696 
01697 
01698 static void
01699 mopts_collect (LibHalContext *hal_ctx, const char *namespace, int namespace_len, 
01700            const char *udi, char *options_string, size_t options_max_len, dbus_bool_t only_collect_imply_opts)
01701 {
01702     LibHalPropertySet *properties;
01703     LibHalPropertySetIterator it;
01704     DBusError error;
01705 
01706     if(hal_ctx == 0) {
01707         fprintf (stderr,"%s %d : LibHalContext *ctx is NULL\n",__FILE__, __LINE__);
01708         return;
01709     }
01710 
01711     dbus_error_init (&error);
01712 
01713     /* first collect from root computer device */
01714     properties = libhal_device_get_all_properties (hal_ctx, udi, &error);
01715     if (properties == NULL)
01716         goto error;
01717     for (libhal_psi_init (&it, properties); libhal_psi_has_more (&it); libhal_psi_next (&it)) {
01718         int type;
01719         char *key;
01720         
01721         type = libhal_psi_get_type (&it);
01722         key = libhal_psi_get_key (&it);
01723         if (libhal_psi_get_type (&it) == LIBHAL_PROPERTY_TYPE_BOOLEAN &&
01724             strncmp (key, namespace, namespace_len - 1) == 0) {
01725             const char *option = key + namespace_len - 1;
01726             char *location;
01727             dbus_bool_t is_imply_opt;
01728 
01729             is_imply_opt = FALSE;
01730             if (strcmp (option, "user") == 0 ||
01731                 strcmp (option, "users") == 0 ||
01732                 strcmp (option, "defaults") == 0 ||
01733                 strcmp (option, "pamconsole") == 0)
01734                 is_imply_opt = TRUE;
01735 
01736             
01737             if (only_collect_imply_opts) {
01738                 if (!is_imply_opt)
01739                     continue;
01740             } else {
01741                 if (is_imply_opt)
01742                     continue;
01743             }
01744 
01745             if (libhal_psi_get_bool (&it)) {
01746                 /* see if option is already there */
01747                 location = strstr (options_string, option);
01748                 if (location == NULL) {
01749                     if (strlen (options_string) > 0)
01750                         strcat_len (options_string, ",", options_max_len);
01751                     strcat_len (options_string, option, options_max_len);
01752                 }
01753             } else {
01754                 /* remove option if already there */
01755                 location = strstr (options_string, option);
01756                 if (location != NULL) {
01757                     char *end;
01758 
01759                     end = strchr (location, ',');
01760                     if (end == NULL) {
01761                         location[0] = '\0';
01762                     } else {
01763                         strcpy (location, end + 1); /* skip the extra comma */
01764                     }
01765                 }
01766 
01767             }
01768         }
01769     }
01770 error:
01771     libhal_free_property_set (properties);
01772 }
01773 
01774 
01775 const char *
01776 libhal_drive_policy_get_mount_options (LibHalDrive *drive, LibHalStoragePolicy *policy)
01777 {
01778     const char *result;
01779     char stor_mount_option_default_begin[] = "storage.policy.default.mount_option.";
01780     char stor_mount_option_begin[] = "storage.policy.mount_option.";
01781 
01782     result = NULL;
01783     drive->mount_options[0] = '\0';
01784 
01785     /* collect options != ('pamconsole', 'user', 'users', 'defaults' options that imply other options)  */
01786     mopts_collect (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin),
01787                "/org/freedesktop/Hal/devices/computer", drive->mount_options, MOUNT_OPTIONS_SIZE, TRUE);
01788     mopts_collect (drive->hal_ctx, stor_mount_option_begin, sizeof (stor_mount_option_begin),
01789                drive->udi, drive->mount_options, MOUNT_OPTIONS_SIZE, TRUE);
01790     /* ensure ('pamconsole', 'user', 'users', 'defaults' options that imply other options), are first */
01791     mopts_collect (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin),
01792                "/org/freedesktop/Hal/devices/computer", drive->mount_options, MOUNT_OPTIONS_SIZE, FALSE);
01793     mopts_collect (drive->hal_ctx, stor_mount_option_begin, sizeof (stor_mount_option_begin),
01794                drive->udi, drive->mount_options, MOUNT_OPTIONS_SIZE, FALSE);
01795 
01796     result = drive->mount_options;
01797 
01798     return result;
01799 }
01800 
01801 const char *
01802 libhal_drive_policy_get_mount_fs (LibHalDrive *drive, LibHalStoragePolicy *policy)
01803 {
01804     return drive->mount_filesystem;
01805 }
01806 
01807 
01808 dbus_bool_t
01809 libhal_volume_policy_is_mountable (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
01810 {
01811     return drive->should_mount && volume->should_mount;
01812 }
01813 
01814 const char *libhal_volume_policy_get_desired_mount_point (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
01815 {
01816     return volume->desired_mount_point;
01817 }
01818 
01819 const char *libhal_volume_policy_get_mount_options (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
01820 {
01821     const char *result;
01822     char stor_mount_option_default_begin[] = "storage.policy.default.mount_option.";
01823     char vol_mount_option_begin[] = "volume.policy.mount_option.";
01824 
01825     result = NULL;
01826     volume->mount_options[0] = '\0';
01827 
01828     /* ensure ('pamconsole', 'user', 'users', 'defaults' options that imply other options), are first */
01829     mopts_collect (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin),
01830                "/org/freedesktop/Hal/devices/computer", volume->mount_options, MOUNT_OPTIONS_SIZE, TRUE);
01831     mopts_collect (drive->hal_ctx, vol_mount_option_begin, sizeof (vol_mount_option_begin),
01832                volume->udi, volume->mount_options, MOUNT_OPTIONS_SIZE, TRUE);
01833     /* collect options != ('pamconsole', 'user', 'users', 'defaults' options that imply other options)  */
01834     mopts_collect (drive->hal_ctx, stor_mount_option_default_begin, sizeof (stor_mount_option_default_begin),
01835                "/org/freedesktop/Hal/devices/computer", volume->mount_options, MOUNT_OPTIONS_SIZE, FALSE);
01836     mopts_collect (drive->hal_ctx, vol_mount_option_begin, sizeof (vol_mount_option_begin),
01837                volume->udi, volume->mount_options, MOUNT_OPTIONS_SIZE, FALSE);
01838 
01839     result = volume->mount_options;
01840 
01841     return result;
01842 }
01843 
01844 const char *libhal_volume_policy_get_mount_fs (LibHalDrive *drive, LibHalVolume *volume, LibHalStoragePolicy *policy)
01845 {
01846     return volume->mount_filesystem;
01847 }
01848 
01849 dbus_bool_t       
01850 libhal_drive_no_partitions_hint (LibHalDrive *drive)
01851 {
01852     return drive->no_partitions_hint;
01853 }
01854 

Generated on Thu Aug 10 10:02:40 2006 for HAL by  doxygen 1.4.7