hal/libhal-storage libhal-storage.c, 1.36, 1.37 libhal-storage.h,
1.20, 1.21
Danny Kukawka
dkukawka at kemper.freedesktop.org
Mon Jul 10 11:23:06 PDT 2006
Update of /cvs/hal/hal/libhal-storage
In directory kemper:/tmp/cvs-serv9656/libhal-storage
Modified Files:
libhal-storage.c libhal-storage.h
Log Message:
2006-07-10 Danny Kukawka <danny.kukawka at web.de>
* libhal-storage/libhal-storage.c: (libhal_volume_from_udi),
(libhal_volume_get_size), (libhal_volume_get_disc_capacity):
Fixed libhal_volume_get_size to return volume.size if available
instead of compute the value from volume.block_size and
volume.num_blocks which can be wrong values. Added slightly
adopted patch from Wouter Paesen <wouter at kangaroot.net> to get
disc_capacity of a volume via lib (fd.o bug #6496)
* libhal-storage/libhal-storage.h: fd.o bug #6496
Index: libhal-storage.c
===================================================================
RCS file: /cvs/hal/hal/libhal-storage/libhal-storage.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- libhal-storage.c 3 Jul 2006 16:42:01 -0000 1.36
+++ libhal-storage.c 10 Jul 2006 18:23:04 -0000 1.37
@@ -737,7 +737,6 @@
int msdos_part_table_type;
-
dbus_bool_t is_disc;
LibHalVolumeDiscType disc_type;
dbus_bool_t disc_has_audio;
@@ -758,6 +757,9 @@
char *crypto_backing_volume;
char mount_options[MOUNT_OPTIONS_SIZE];
+
+ dbus_uint64_t volume_size;
+ dbus_uint64_t disc_capacity;
};
const char *
@@ -853,6 +855,7 @@
#define LIBHAL_PROP_EXTRACT_BEGIN if (FALSE)
#define LIBHAL_PROP_EXTRACT_END ;
#define LIBHAL_PROP_EXTRACT_INT(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_INT32) _where_ = libhal_psi_get_int (&it)
+#define LIBHAL_PROP_EXTRACT_UINT64(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_UINT64) _where_ = libhal_psi_get_uint64 (&it)
#define LIBHAL_PROP_EXTRACT_STRING(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_STRING) _where_ = (libhal_psi_get_string (&it) != NULL && strlen (libhal_psi_get_string (&it)) > 0) ? strdup (libhal_psi_get_string (&it)) : NULL
#define LIBHAL_PROP_EXTRACT_BOOL(_property_, _where_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_BOOLEAN) _where_ = libhal_psi_get_bool (&it)
#define LIBHAL_PROP_EXTRACT_BOOL_BITFIELD(_property_, _where_, _field_) else if (strcmp (key, _property_) == 0 && type == LIBHAL_PROPERTY_TYPE_BOOLEAN) _where_ |= libhal_psi_get_bool (&it) ? _field_ : 0
@@ -1109,6 +1112,7 @@
LIBHAL_PROP_EXTRACT_INT ("volume.block_size", vol->block_size);
LIBHAL_PROP_EXTRACT_INT ("volume.num_blocks", vol->num_blocks);
+ LIBHAL_PROP_EXTRACT_UINT64 ("volume.size", vol->volume_size);
LIBHAL_PROP_EXTRACT_STRING ("volume.label", vol->volume_label);
LIBHAL_PROP_EXTRACT_STRING ("volume.mount_point", vol->mount_point);
LIBHAL_PROP_EXTRACT_STRING ("volume.fstype", vol->fstype);
@@ -1127,6 +1131,7 @@
LIBHAL_PROP_EXTRACT_BOOL ("volume.disc.is_appendable", vol->disc_is_appendable);
LIBHAL_PROP_EXTRACT_BOOL ("volume.disc.is_blank", vol->disc_is_blank);
LIBHAL_PROP_EXTRACT_BOOL ("volume.disc.is_rewritable", vol->disc_is_rewritable);
+ LIBHAL_PROP_EXTRACT_UINT64 ("volume.disc.capacity", vol->disc_capacity);
LIBHAL_PROP_EXTRACT_BOOL ("volume.policy.should_mount", vol->should_mount);
LIBHAL_PROP_EXTRACT_STRING ("volume.policy.desired_mount_point", vol->desired_mount_point);
@@ -1323,7 +1328,16 @@
dbus_uint64_t
libhal_volume_get_size (LibHalVolume *volume)
{
- return ((dbus_uint64_t)volume->block_size) * ((dbus_uint64_t)volume->num_blocks);
+ if (volume->volume_size > 0)
+ return volume->volume_size;
+ else
+ return ((dbus_uint64_t)volume->block_size) * ((dbus_uint64_t)volume->num_blocks):
+}
+
+dbus_uint64_t
+libhal_volume_get_disc_capacity (LibHalVolume *volume)
+{
+ return volume->disc_capacity;
}
Index: libhal-storage.h
===================================================================
RCS file: /cvs/hal/hal/libhal-storage/libhal-storage.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- libhal-storage.h 9 May 2006 20:28:01 -0000 1.20
+++ libhal-storage.h 10 Jul 2006 18:23:04 -0000 1.21
@@ -273,6 +273,7 @@
const char *device_file);
void libhal_volume_free (LibHalVolume *volume);
dbus_uint64_t libhal_volume_get_size (LibHalVolume *volume);
+dbus_uint64_t libhal_volume_get_disc_capacity (LibHalVolume *volume);
const char *libhal_volume_get_udi (LibHalVolume *volume);
const char *libhal_volume_get_device_file (LibHalVolume *volume);
More information about the hal-commit
mailing list