hal: Branch 'master' - 2 commits

David Zeuthen david at kemper.freedesktop.org
Sat Aug 19 10:51:25 PDT 2006


 doc/spec/hal-spec-properties.xml    |   53 +++++++++-
 doc/spec/hal-spec.html              |  177 +++++++++++++++++++++++++++---------
 hald/linux2/blockdev.c              |    2 
 hald/linux2/probing/probe-storage.c |   16 ++-
 hald/linux2/probing/probe-volume.c  |   64 +++++++++++--
 libhal-storage/libhal-storage.c     |   42 ++++++++
 libhal-storage/libhal-storage.h     |    6 +
 7 files changed, 300 insertions(+), 60 deletions(-)

New commits:
diff-tree d9bcef8e186626c8270d848f585e64c363cf6796 (from parents)
Merge: ca064f6f313f7afd134e67e0fa7ac2fc5e25dd64 27050b659a63c9ffe79f997a2d562a56821e49c3
Author: David Zeuthen <davidz at redhat.com>
Date:   Sat Aug 19 13:49:32 2006 -0400

    Merge branch 'master' of ssh://david@git.freedesktop.org/git/hal

diff-tree ca064f6f313f7afd134e67e0fa7ac2fc5e25dd64 (from 0e7375f0196a55d095c8fb890bdd1b9f5e51bef0)
Author: David Zeuthen <davidz at redhat.com>
Date:   Sat Aug 19 13:49:23 2006 -0400

    introduce some new properties for MS-DOS partition tables
    
    Introduce volume.partition.msdos_part_table_start, .msdos_part_table_size,
    and storage.removable.media_size.

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 89d3efd..12c68e5 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -2220,7 +2220,11 @@
               <entry></entry>
               <entry>partitiontable</entry>
               <entry></entry>
-              <entry>The volume conatains a partitiontable</entry>
+              <entry>
+	        The volume contains a partitiontable. If an MS-DOS extended
+		partition table is found, then <literal>volume.fstype</literal> 
+		will be <literal>msdos_extended_partitiontable</literal>.
+	      </entry>
             </row>
             <row>
               <entry></entry>
@@ -2244,9 +2248,9 @@
               <entry>
                 <literal>volume.fstype</literal> (string)
               </entry>
-              <entry>example: ext3</entry>
-              <entry>Yes (is blank if the filesystem type is unknown)</entry>
-              <entry></entry>
+              <entry>examples: ext3, vfat, msdos_extended_partitiontable</entry>
+              <entry>Yes (is blank if the type is unknown)</entry>
+              <entry>The specific type of either the file system or what the volume is used for, cf. volume.fsusage</entry>
             </row>
             <row>
               <entry>
@@ -2362,6 +2366,39 @@
             </row>
             <row>
               <entry>
+                <literal>volume.partition.msdos_part_table_start</literal> (uint64)
+              </entry>
+              <entry></entry>
+              <entry>
+                No
+              </entry>
+              <entry>
+                If available, this is the partition start offset if the disk for which
+                this volume stems from is using an MS-DOS-style partition table.
+              </entry>
+            </row>
+            <row>
+              <entry>
+                <literal>volume.partition.msdos_part_table_size</literal> (uint64)
+              </entry>
+              <entry></entry>
+              <entry>
+                No
+              </entry>
+              <entry>
+                If available, this is the partition size if the disk for which
+                this volume stems from is using an MS-DOS-style partition table.
+		This information is derived from the partition table so it might
+		not be reliable and match e.g. <literal>volume.size</literal>.
+		Specifically, for MS-DOS extended partition tables, this number
+		will be larger as the actual volume is only e.g. 1 kilobyte
+		(e.g. <literal>volume.size</literal>) while 
+		<literal>volume.partition.msdos_part_table_size</literal>
+		will be the size enclosing all the logical partitions.
+              </entry>
+            </row>
+            <row>
+              <entry>
                 <literal>volume.partition.media_size</literal> (uint64)
               </entry>
               <entry>example: 500107862016</entry>
@@ -2914,6 +2951,14 @@
             </row>
             <row>
               <entry>
+	        <literal>storage.removable.media_size</literal> (uint64)
+              </entry>
+              <entry></entry>
+              <entry>Yes</entry>
+              <entry>Size of media in storage device. Available only if media have been detected in storage device.</entry>
+            </row>
+            <row>
+              <entry>
 	        <literal>storage.size</literal> (uint64)
               </entry>
               <entry></entry>
diff --git a/doc/spec/hal-spec.html b/doc/spec/hal-spec.html
index 817f0c6..e77fde1 100644
--- a/doc/spec/hal-spec.html
+++ b/doc/spec/hal-spec.html
@@ -609,12 +609,12 @@ HREF="#dbus-api"
 ><DL
 ><DT
 ><A
-HREF="#AEN4006"
+HREF="#AEN4036"
 >Interface org.freedesktop.Hal.Manager</A
 ></DT
 ><DT
 ><A
-HREF="#AEN4025"
+HREF="#AEN4055"
 >Interface org.freedesktop.Hal.Device</A
 ></DT
 ></DL
@@ -5579,7 +5579,16 @@ CLASS="literal"
 ><TD
 >&nbsp;</TD
 ><TD
->The volume conatains a partitiontable</TD
+>&#13;	        The volume contains a partitiontable. If an MS-DOS extended
+		partition table is found, then <TT
+CLASS="literal"
+>volume.fstype</TT
+> 
+		will be <TT
+CLASS="literal"
+>msdos_extended_partitiontable</TT
+>.
+	      </TD
 ></TR
 ><TR
 ><TD
@@ -5619,11 +5628,11 @@ CLASS="literal"
 > (string)
               </TD
 ><TD
->example: ext3</TD
+>examples: ext3, vfat, msdos_extended_partitiontable</TD
 ><TD
->Yes (is blank if the filesystem type is unknown)</TD
+>Yes (is blank if the type is unknown)</TD
 ><TD
->&nbsp;</TD
+>The specific type of either the file system or what the volume is used for, cf. volume.fsusage</TD
 ></TR
 ><TR
 ><TD
@@ -5755,6 +5764,24 @@ CLASS="literal"
 ><TD
 >&#13;                <TT
 CLASS="literal"
+>volume.linux.is_device_mapper</TT
+> (bool)
+              </TD
+><TD
+>&nbsp;</TD
+><TD
+>Yes, but only on Linux</TD
+><TD
+>&#13;                If the volume stems from the Linux Device Mapper this property is set to <TT
+CLASS="literal"
+>TRUE</TT
+>.
+              </TD
+></TR
+><TR
+><TD
+>&#13;                <TT
+CLASS="literal"
 >volume.partition.number</TT
 > (int)
               </TD
@@ -5795,7 +5822,57 @@ CLASS="literal"
 ><TD
 >&#13;                <TT
 CLASS="literal"
->volume.partition.drive_size</TT
+>volume.partition.msdos_part_table_start</TT
+> (uint64)
+              </TD
+><TD
+>&nbsp;</TD
+><TD
+>&#13;                No
+              </TD
+><TD
+>&#13;                If available, this is the partition start offset if the disk for which
+                this volume stems from is using an MS-DOS-style partition table.
+              </TD
+></TR
+><TR
+><TD
+>&#13;                <TT
+CLASS="literal"
+>volume.partition.msdos_part_table_size</TT
+> (uint64)
+              </TD
+><TD
+>&nbsp;</TD
+><TD
+>&#13;                No
+              </TD
+><TD
+>&#13;                If available, this is the partition size if the disk for which
+                this volume stems from is using an MS-DOS-style partition table.
+		This information is derived from the partition table so it might
+		not be reliable and match e.g. <TT
+CLASS="literal"
+>volume.size</TT
+>.
+		Specifically, for MS-DOS extended partition tables, this number
+		will be larger as the actual volume is only e.g. 1 kilobyte
+		(e.g. <TT
+CLASS="literal"
+>volume.size</TT
+>) while 
+		<TT
+CLASS="literal"
+>volume.partition.msdos_part_table_size</TT
+>
+		will be the size enclosing all the logical partitions.
+              </TD
+></TR
+><TR
+><TD
+>&#13;                <TT
+CLASS="literal"
+>volume.partition.media_size</TT
 > (uint64)
               </TD
 ><TD
@@ -5851,7 +5928,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN1757"
+NAME="AEN1781"
 ></A
 ><TABLE
 BORDER="1"
@@ -5991,7 +6068,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN1800"
+NAME="AEN1824"
 ></A
 ><TABLE
 BORDER="1"
@@ -6165,7 +6242,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN1858"
+NAME="AEN1882"
 ></A
 ><TABLE
 BORDER="1"
@@ -6547,7 +6624,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2019"
+NAME="AEN2043"
 ></A
 ><TABLE
 BORDER="1"
@@ -6783,6 +6860,20 @@ CLASS="literal"
 ><TD
 >&#13;	        <TT
 CLASS="literal"
+>storage.removable.media_available</TT
+> (bool)
+              </TD
+><TD
+>&nbsp;</TD
+><TD
+>Yes</TD
+><TD
+>true, if and only if, media have been detected in storage device</TD
+></TR
+><TR
+><TD
+>&#13;	        <TT
+CLASS="literal"
 >storage.size</TT
 > (uint64)
               </TD
@@ -7062,7 +7153,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2219"
+NAME="AEN2249"
 ></A
 ><TABLE
 BORDER="1"
@@ -7396,7 +7487,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2353"
+NAME="AEN2383"
 ></A
 ><TABLE
 BORDER="1"
@@ -7556,7 +7647,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2411"
+NAME="AEN2441"
 ></A
 ><TABLE
 BORDER="1"
@@ -7692,7 +7783,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2453"
+NAME="AEN2483"
 ></A
 ><TABLE
 BORDER="1"
@@ -7764,7 +7855,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2475"
+NAME="AEN2505"
 ></A
 ><TABLE
 BORDER="1"
@@ -7830,7 +7921,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2495"
+NAME="AEN2525"
 ></A
 ><TABLE
 BORDER="1"
@@ -7894,7 +7985,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2515"
+NAME="AEN2545"
 ></A
 ><TABLE
 BORDER="1"
@@ -8038,7 +8129,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2565"
+NAME="AEN2595"
 ></A
 ><TABLE
 BORDER="1"
@@ -8253,7 +8344,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2637"
+NAME="AEN2667"
 ></A
 ><TABLE
 BORDER="1"
@@ -8517,7 +8608,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2733"
+NAME="AEN2763"
 ></A
 ><TABLE
 BORDER="1"
@@ -8769,7 +8860,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2822"
+NAME="AEN2852"
 ></A
 ><TABLE
 BORDER="1"
@@ -8890,7 +8981,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2864"
+NAME="AEN2894"
 ></A
 ><TABLE
 BORDER="1"
@@ -8978,7 +9069,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2893"
+NAME="AEN2923"
 ></A
 ><TABLE
 BORDER="1"
@@ -9075,7 +9166,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2921"
+NAME="AEN2951"
 ></A
 ><TABLE
 BORDER="1"
@@ -9225,7 +9316,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN2980"
+NAME="AEN3010"
 ></A
 ><TABLE
 BORDER="1"
@@ -9305,7 +9396,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3006"
+NAME="AEN3036"
 ></A
 ><TABLE
 BORDER="1"
@@ -9372,7 +9463,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3026"
+NAME="AEN3056"
 ></A
 ><TABLE
 BORDER="1"
@@ -10290,7 +10381,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3344"
+NAME="AEN3374"
 ></A
 ><TABLE
 BORDER="1"
@@ -10405,7 +10496,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3388"
+NAME="AEN3418"
 ></A
 ><TABLE
 BORDER="1"
@@ -10473,7 +10564,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3409"
+NAME="AEN3439"
 ></A
 ><TABLE
 BORDER="1"
@@ -10568,7 +10659,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3441"
+NAME="AEN3471"
 ></A
 ><TABLE
 BORDER="1"
@@ -10680,7 +10771,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3483"
+NAME="AEN3513"
 ></A
 ><TABLE
 BORDER="1"
@@ -10819,7 +10910,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3539"
+NAME="AEN3569"
 ></A
 ><TABLE
 BORDER="1"
@@ -10957,7 +11048,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3583"
+NAME="AEN3613"
 ></A
 ><TABLE
 BORDER="1"
@@ -11045,7 +11136,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3609"
+NAME="AEN3639"
 ></A
 ><TABLE
 BORDER="1"
@@ -11138,7 +11229,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3637"
+NAME="AEN3667"
 ></A
 ><TABLE
 BORDER="1"
@@ -11306,7 +11397,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3689"
+NAME="AEN3719"
 ></A
 ><TABLE
 BORDER="1"
@@ -11441,7 +11532,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3730"
+NAME="AEN3760"
 ></A
 ><TABLE
 BORDER="1"
@@ -12386,7 +12477,7 @@ CLASS="informaltable"
 ><P
 ></P
 ><A
-NAME="AEN3964"
+NAME="AEN3994"
 ></A
 ><TABLE
 BORDER="1"
@@ -12549,7 +12640,7 @@ CLASS="sect2"
 ><HR><H3
 CLASS="sect2"
 ><A
-NAME="AEN4006"
+NAME="AEN4036"
 >Interface org.freedesktop.Hal.Manager</A
 ></H3
 ><P
@@ -12653,7 +12744,7 @@ CLASS="sect3"
 ><HR><H4
 CLASS="sect3"
 ><A
-NAME="AEN4017"
+NAME="AEN4047"
 >Example</A
 ></H4
 ><P
@@ -12762,7 +12853,7 @@ CLASS="sect2"
 ><HR><H3
 CLASS="sect2"
 ><A
-NAME="AEN4025"
+NAME="AEN4055"
 >Interface org.freedesktop.Hal.Device</A
 ></H3
 ><P
diff --git a/hald/linux2/blockdev.c b/hald/linux2/blockdev.c
index e9713aa..d232115 100644
--- a/hald/linux2/blockdev.c
+++ b/hald/linux2/blockdev.c
@@ -907,6 +907,7 @@ hotplug_event_begin_add_blockdev (const 
 		hal_device_property_set_string (d, "storage.physical_device", parent->udi);
 		hal_device_property_set_bool (d, "storage.removable", TRUE);
 		hal_device_property_set_bool (d, "storage.removable.media_available", FALSE);
+		hal_device_property_set_uint64 (d, "storage.removable.media_size", 0);
 		hal_device_property_set_bool (d, "storage.hotpluggable", FALSE);
 		hal_device_property_set_bool (d, "storage.requires_eject", FALSE);
 		hal_device_property_set_uint64 (d, "storage.size", 0);
@@ -1050,6 +1051,7 @@ hotplug_event_begin_add_blockdev (const 
 		}
 
 		hal_device_property_set_bool (d, "storage.removable.media_available", FALSE);
+		hal_device_property_set_uint64 (d, "storage.removable.media_size", 0);
 		hal_device_property_set_bool (d, "storage.removable", is_removable);
 		/* set storage.size only if we have fixed media */
 		if (!is_removable) {
diff --git a/hald/linux2/probing/probe-storage.c b/hald/linux2/probing/probe-storage.c
index 74f8bab..75f0b8b 100644
--- a/hald/linux2/probing/probe-storage.c
+++ b/hald/linux2/probing/probe-storage.c
@@ -352,8 +352,13 @@ main (int argc, char *argv[])
 		}
 
 		if (got_media) {
+			uint64_t size;
 			ret = 2;
 			libhal_device_set_property_bool (ctx, udi, "storage.removable.media_available", TRUE, &error);
+			if (ioctl (fd, BLKGETSIZE64, &size) == 0) {
+				dbg ("media size = %llu", size);
+				libhal_device_set_property_uint64 (ctx, udi, "storage.removable.media_size", size, &error);
+			}
 		} else {
 			libhal_device_set_property_bool (ctx, udi, "storage.removable.media_available", FALSE, &error);
 		}
@@ -365,6 +370,7 @@ main (int argc, char *argv[])
 		const gchar *partition;
 		const gchar *main_device;
 		size_t main_device_len;
+		uint64_t size;
 
 		dbg ("Checking for file system on %s", device_file);
 
@@ -385,6 +391,11 @@ main (int argc, char *argv[])
 		/* if we get to here, we have media */
 		libhal_device_set_property_bool (ctx, udi, "storage.removable.media_available", TRUE, &error);
 
+		if (ioctl (fd, BLKGETSIZE64, &size) != 0)
+			size = 0;
+		
+		libhal_device_set_property_uint64 (ctx, udi, "storage.removable.media_size", size, &error);
+
 		/* if the kernel has created partitions, we don't look for a filesystem */
 		main_device = strrchr (sysfs_path, '/');
 		if (main_device == NULL)
@@ -409,11 +420,6 @@ main (int argc, char *argv[])
 		/* probe for file system */
 		vid = volume_id_open_fd (fd);
 		if (vid != NULL) {
-			uint64_t size;
-
-			if (ioctl(vid->fd, BLKGETSIZE64, &size) != 0)
-				size = 0;
-
 			if (volume_id_probe_all (vid, 0, size) == 0) {
 				/* signal to hald that we've found something and a fakevolume
 				 * should be added - see hald/linux2/blockdev.c:add_blockdev_probing_helper_done()
diff --git a/hald/linux2/probing/probe-volume.c b/hald/linux2/probing/probe-volume.c
index 4244652..b484b61 100644
--- a/hald/linux2/probing/probe-volume.c
+++ b/hald/linux2/probing/probe-volume.c
@@ -103,9 +103,16 @@ strdup_valid_utf8 (const char *str)
 	 type == WIN98_EXTENDED_PARTITION ||	\
 	 type == LINUX_EXTENDED_PARTITION)
 
-static unsigned char *probe_msdos_part_table(int fd)
+struct msdos_part_entry {
+	uint8_t part_type;
+	uint64_t start;
+	uint64_t size;
+};
+
+static struct msdos_part_entry *
+probe_msdos_part_table(int fd)
 {
-	static unsigned char partition_id_index[256];
+	static struct msdos_part_entry partition_id_index[256];
 	unsigned int partition_count;
 	const uint8_t buf[BSIZE];
 	int i;
@@ -161,7 +168,10 @@ static unsigned char *probe_msdos_part_t
 		if (plen == 0)
 			continue;
 
-		partition_id_index[i] = part[i].sys_ind;
+		partition_id_index[i].part_type = part[i].sys_ind;
+		partition_id_index[i].start = poff;
+		partition_id_index[i].size = plen;
+		dbg ("part %d -> type=%d off=%lld size=%lld", i, part[i].sys_ind, poff, plen);
 
 		if (is_extended(part[i].sys_ind)) {
 			dbg("found extended partition at 0x%llx", (unsigned long long) poff);
@@ -178,6 +188,8 @@ static unsigned char *probe_msdos_part_t
 	limit = 255;
 	next = extended;
 	while (next != 0) {
+		uint64_t oldnext;
+
 		if (limit-- == 0) {
 			dbg("extended chain limit reached");
 			break;
@@ -195,6 +207,7 @@ static unsigned char *probe_msdos_part_t
 		if (memcmp(&buf[MSDOS_SIG_OFF], MSDOS_MAGIC, 2) != 0)
 			break;
 
+		oldnext = next;
 		next = 0;
 
 		part = (struct msdos_partition_entry*) &buf[MSDOS_PARTTABLE_OFFSET];
@@ -213,7 +226,10 @@ static unsigned char *probe_msdos_part_t
 				dbg("found 0x%x logical data partition at 0x%llx, len 0x%llx",
 					part[i].sys_ind, (unsigned long long) poff, (unsigned long long) plen);
 
-				partition_id_index[partition_count] = part[i].sys_ind;
+				partition_id_index[partition_count].part_type = part[i].sys_ind;
+				partition_id_index[partition_count].start = oldnext + poff;
+				partition_id_index[partition_count].size = plen;
+
 				partition_count++;
 			}
 		}
@@ -696,12 +712,38 @@ main (int argc, char *argv[])
 			} else {
 				libhal_changeset_set_property_string (changeset, "info.product", "Volume");
 			}
+
+			/* VOLUME_ID_UNUSED means vol_id didn't detect anything that it knows about - look if 
+			 * it's an extended msdos partition table 
+			 */
+			if (vid->usage_id == VOLUME_ID_UNUSED) {
+				unsigned char buf[2];
+
+				dbg ("looking whether partition is an extended msdos partition table", vid->usage_id);
+
+				/* TODO: Is it good enough to just look for this magic? Kay? */
+				lseek (fd, MSDOS_SIG_OFF, SEEK_SET);
+				if (read (fd, &buf, 2) != 2) {
+					dbg ("read failed (%s)", strerror (errno));
+				} else {
+					if (memcmp (buf, MSDOS_MAGIC, 2) == 0) {
+						dbg ("partition is an extended msdos partition table");
+
+						libhal_changeset_set_property_string (changeset, "volume.fsusage", "partitiontable");
+						libhal_changeset_set_property_string (changeset, "volume.fstype", "msdos_extended_partitiontable");
+						libhal_changeset_set_property_string (changeset, "volume.fsversion", "");
+						
+					}
+				}
+				
+			}
+
 			volume_id_close(vid);
 		}
 
 		/* get partition type number, if we find a msdos partition table */
-		if (partition_number_str != NULL) {
-			unsigned char *idx;
+		if (partition_number_str != NULL && partition_number <= 256 && partition_number > 0) {
+			struct msdos_part_entry *idx;
 			int fd;
 
 			if ((stordev_dev_file = libhal_device_get_property_string (
@@ -712,12 +754,20 @@ main (int argc, char *argv[])
 			if (fd >= 0) {
 				idx = probe_msdos_part_table(fd);
 				if (idx != NULL) {
+					uint64_t start;
+					uint64_t size;
 					unsigned char type;
 
-					type = idx[partition_number - 1];
+					type = idx[partition_number - 1].part_type;
+					start = idx[partition_number - 1].start;
+					size = idx[partition_number - 1].size;
 					if (type > 0) {
 						libhal_changeset_set_property_int (
 							changeset, "volume.partition.msdos_part_table_type", type);
+						libhal_changeset_set_property_uint64 (
+							changeset, "volume.partition.msdos_part_table_start", start);
+						libhal_changeset_set_property_uint64 (
+							changeset, "volume.partition.msdos_part_table_size", size);
 
 						/* NOTE: We trust the type from the partition table
 						 * if it explicitly got correct entries for RAID and
diff --git a/libhal-storage/libhal-storage.c b/libhal-storage/libhal-storage.c
index fb64c24..206ffd3 100644
--- a/libhal-storage/libhal-storage.c
+++ b/libhal-storage/libhal-storage.c
@@ -710,6 +710,7 @@ struct LibHalDrive_s {
 	dbus_bool_t no_partitions_hint;
 
 	dbus_uint64_t drive_size;
+	dbus_uint64_t drive_media_size;
 
 	LibHalContext *hal_ctx;
 
@@ -739,6 +740,8 @@ struct LibHalVolume_s {
 	unsigned int partition_number;
 
 	int msdos_part_table_type;
+	dbus_uint64_t msdos_part_table_start;
+	dbus_uint64_t msdos_part_table_size;
 	
 	dbus_bool_t is_disc;
 	LibHalVolumeDiscType disc_type;
@@ -935,6 +938,7 @@ libhal_drive_from_udi (LibHalContext *ha
 		LIBHAL_PROP_EXTRACT_BOOL   ("storage.hotpluggable",      drive->is_hotpluggable);
 		LIBHAL_PROP_EXTRACT_BOOL   ("storage.removable",         drive->is_removable);
 		LIBHAL_PROP_EXTRACT_BOOL   ("storage.removable.media_available", drive->is_media_detected);
+		LIBHAL_PROP_EXTRACT_UINT64 ("storage.removable.media_size", drive->drive_media_size); 
 		LIBHAL_PROP_EXTRACT_BOOL   ("storage.requires_eject",    drive->requires_eject);
 
 		LIBHAL_PROP_EXTRACT_STRING ("storage.physical_device",   drive->physical_device);
@@ -1113,6 +1117,8 @@ libhal_volume_from_udi (LibHalContext *h
 		LIBHAL_PROP_EXTRACT_UINT64 ("volume.partition.start", 		      vol->partition_start_offset); 
 		LIBHAL_PROP_EXTRACT_UINT64 ("volume.partition.media_size",            vol->partition_media_size); 
 		LIBHAL_PROP_EXTRACT_INT    ("volume.partition.msdos_part_table_type", vol->msdos_part_table_type);
+		LIBHAL_PROP_EXTRACT_UINT64 ("volume.partition.msdos_part_table_start", vol->msdos_part_table_start);
+		LIBHAL_PROP_EXTRACT_UINT64 ("volume.partition.msdos_part_table_size", vol->msdos_part_table_size);
 
 		LIBHAL_PROP_EXTRACT_INT    ("block.minor",               vol->device_minor);
 		LIBHAL_PROP_EXTRACT_INT    ("block.major",               vol->device_major);
@@ -1198,6 +1204,8 @@ libhal_volume_from_udi (LibHalContext *h
 			vol->fsusage = LIBHAL_VOLUME_USAGE_RAID_MEMBER;
 		} else if (strcmp (vol_fsusage_textual, "crypto") == 0) {
 			vol->fsusage = LIBHAL_VOLUME_USAGE_CRYPTO;
+		} else if (strcmp (vol_fsusage_textual, "other") == 0) {
+			vol->fsusage = LIBHAL_VOLUME_USAGE_OTHER;
 		} else {
 			vol->fsusage = LIBHAL_VOLUME_USAGE_UNKNOWN;
 		} 
@@ -1231,6 +1239,34 @@ libhal_volume_get_msdos_part_table_type 
 	return volume->msdos_part_table_type;
 }
 
+/** If the volume is on a drive with a MSDOS style partition table, return
+ *  the partition start offset according to the partition table.
+ *
+ *  @param  volume              Volume object
+ *  @return                     The partition start offset or -1 if volume isnt
+ *                              a partition or the media the volume stems from
+ *                              isn't partition with a MS DOS style table
+ */
+dbus_uint64_t
+libhal_volume_get_msdos_part_table_start (LibHalVolume *volume)
+{
+	return volume->msdos_part_table_start;
+}
+
+/** If the volume is on a drive with a MSDOS style partition table, return
+ *  the partition size according to the partition table.
+ *
+ *  @param  volume              Volume object
+ *  @return                     The partition size or -1 if volume is not
+ *                              a partition or the media the volume stems from
+ *                              isn't partition with a MS DOS style table
+ */
+dbus_uint64_t
+libhal_volume_get_msdos_part_table_size (LibHalVolume *volume)
+{
+	return volume->msdos_part_table_size;
+}
+
 /***********************************************************************/
 
 /** Get the drive object that either is (when given e.g. /dev/sdb) or contains
@@ -1383,6 +1419,12 @@ libhal_drive_get_size (LibHalDrive *driv
 	return drive->drive_size;
 }
 
+dbus_uint64_t
+libhal_drive_get_media_size (LibHalDrive *drive)
+{
+	return drive->drive_media_size;
+}
+
 LibHalDriveType
 libhal_drive_get_type (LibHalDrive *drive)
 {
diff --git a/libhal-storage/libhal-storage.h b/libhal-storage/libhal-storage.h
index a7537a4..0ce5f2d 100644
--- a/libhal-storage/libhal-storage.h
+++ b/libhal-storage/libhal-storage.h
@@ -196,6 +196,7 @@ dbus_bool_t          libhal_drive_is_hot
 dbus_bool_t          libhal_drive_uses_removable_media     (LibHalDrive      *drive);
 dbus_bool_t          libhal_drive_is_media_detected        (LibHalDrive      *drive);
 dbus_uint64_t        libhal_drive_get_size                 (LibHalDrive      *drive);
+dbus_uint64_t        libhal_drive_get_media_size           (LibHalDrive      *drive);
 dbus_bool_t          libhal_drive_no_partitions_hint       (LibHalDrive      *drive);
 dbus_bool_t          libhal_drive_requires_eject           (LibHalDrive      *drive);
 LibHalDriveType      libhal_drive_get_type                 (LibHalDrive      *drive);
@@ -247,7 +248,8 @@ typedef enum {
 	LIBHAL_VOLUME_USAGE_PARTITION_TABLE,
 	LIBHAL_VOLUME_USAGE_RAID_MEMBER,
 	LIBHAL_VOLUME_USAGE_CRYPTO,
-	LIBHAL_VOLUME_USAGE_UNKNOWN
+	LIBHAL_VOLUME_USAGE_UNKNOWN,
+	LIBHAL_VOLUME_USAGE_OTHER
 } LibHalVolumeUsage;
 
 typedef enum {
@@ -308,6 +310,8 @@ dbus_bool_t          libhal_volume_disc_
 LibHalVolumeDiscType libhal_volume_get_disc_type              (LibHalVolume     *volume);
 
 int               libhal_volume_get_msdos_part_table_type     (LibHalVolume     *volume);
+dbus_uint64_t     libhal_volume_get_msdos_part_table_start    (LibHalVolume     *volume);
+dbus_uint64_t     libhal_volume_get_msdos_part_table_size     (LibHalVolume     *volume);
 
 dbus_bool_t       libhal_volume_should_ignore 	              (LibHalVolume     *volume);
 



More information about the hal-commit mailing list