Mykola Ivanets
2018-May-14 11:07 UTC
[Libguestfs] [PATCH libldm v4 0/3] Make libldm to parse and return volume GUID.
v2: wrap commit message, "PATCH libldm" prefix. v3: correctly initialize and free GLib resources. v4: gtk-doc is updated to reflect presence of new volume GUID field. The result of this patch might be used by libguestfs to return drive mappings for LDM volumes. Note, that "show volume" ldmtool command already returns hint which is a drive letter assigned by Windows to corresponding volume. But it is not reliable source of information. More over, in multiboot environment it will be unclear which drive letter belongs to which operating system. Volume GUID allows to overcome this shortcoming. Mykola Ivanets (3): Make libldm to parse and return volume GUID. gtk-doc: update documentation. Make git to ignore all test output files. docs/reference/ldmtool/ldmtool.xml | 7 ++++++ src/ldm.c | 29 ++++++++++++++++++++-- src/ldm.h | 10 ++++++++ src/ldmtool.c | 4 +++ test/.gitignore | 39 +++++++++++++++--------------- test/ldmread.c | 9 ++++--- 6 files changed, 74 insertions(+), 24 deletions(-) -- 2.17.0
Mykola Ivanets
2018-May-14 11:07 UTC
[Libguestfs] [PATCH libldm v4 1/3] Make libldm to parse and return volume GUID.
LDM volume GUID is a significant piece of information about LDM volume analogously to GPT disk/partition GUID. Windows use volume GUID to keeptrack of assigned drive letters, for example. We extract volume GUID while parsing volume VBLK in _parse_vblk_vol function. "show volume" ldmtool command returns extracted volume GUID alongside with other volume information. --- src/ldm.c | 29 +++++++++++++++++++++++++++-- src/ldm.h | 10 ++++++++++ src/ldmtool.c | 4 ++++ test/ldmread.c | 9 ++++++--- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/ldm.c b/src/ldm.c index 19a0663..5c570a5 100644 --- a/src/ldm.c +++ b/src/ldm.c @@ -469,6 +469,7 @@ struct _LDMVolumePrivate { guint32 id; gchar *name; + uuid_t guid; gchar *dgname; guint64 size; @@ -496,6 +497,7 @@ G_DEFINE_TYPE(LDMVolume, ldm_volume, G_TYPE_OBJECT) enum { PROP_LDM_VOLUME_PROP0, PROP_LDM_VOLUME_NAME, + PROP_LDM_VOLUME_GUID, PROP_LDM_VOLUME_TYPE, PROP_LDM_VOLUME_SIZE, PROP_LDM_VOLUME_PART_TYPE, @@ -514,6 +516,14 @@ ldm_volume_get_property(GObject * const o, const guint property_id, case PROP_LDM_VOLUME_NAME: g_value_set_string(value, priv->name); break; + case PROP_LDM_VOLUME_GUID: + { + char guid_str[37]; + uuid_unparse(priv->guid, guid_str); + g_value_set_string(value, guid_str); + } + break; + case PROP_LDM_VOLUME_TYPE: g_value_set_enum(value, priv->type); break; @@ -535,6 +545,7 @@ ldm_volume_get_property(GObject * const o, const guint property_id, } EXPORT_PROP_STRING(volume, LDMVolume, name) +EXPORT_PROP_GUID(volume, LDMVolume) EXPORT_PROP_SCALAR(volume, LDMVolume, size, guint64) EXPORT_PROP_SCALAR(volume, LDMVolume, part_type, guint8) EXPORT_PROP_STRING(volume, LDMVolume, hint) @@ -593,6 +604,20 @@ ldm_volume_class_init(LDMVolumeClass * const klass) ) ); + /** + * LDMVolume:guid: + * + * The GUID of the volume. + */ + g_object_class_install_property( + object_class, + PROP_LDM_VOLUME_GUID, + g_param_spec_string( + "guid", "GUID", "The GUID of the volume", + NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS + ) + ); + /** * LDMVolume:type: * @@ -1514,8 +1539,8 @@ _parse_vblk_vol(const guint8 revision, const guint16 flags, vol->part_type = *((uint8_t *)vblk); vblk++; - /* Volume id */ - vblk += 16; + /* Volume GUID */ + memcpy(&vol->guid, vblk, 16); vblk += 16; if (flags & 0x08) vol->id1 = _parse_var_string(&vblk); if (flags & 0x20) vol->id2 = _parse_var_string(&vblk); diff --git a/src/ldm.h b/src/ldm.h index af0726e..280fbfb 100644 --- a/src/ldm.h +++ b/src/ldm.h @@ -369,6 +369,16 @@ GArray *ldm_volume_get_partitions(LDMVolume *o); */ gchar *ldm_volume_get_name(const LDMVolume *o); +/** + * ldm_volume_get_guid: + * @o: An #LDMVolume + * + * Get the Windows-assigned GUID of a volume. + * + * Returns: (transfer full): The string representation of the GUID + */ +gchar *ldm_volume_get_guid(const LDMVolume *o); + /** * ldm_volume_get_voltype: * @o: An #LDMVolume diff --git a/src/ldmtool.c b/src/ldmtool.c index 4899539..9686778 100644 --- a/src/ldmtool.c +++ b/src/ldmtool.c @@ -279,6 +279,7 @@ show_volume(LDM *const ldm, const gint argc, gchar ** const argv, LDMVolume * const vol = g_array_index(volumes, LDMVolume *, i); gchar *name = ldm_volume_get_name(vol); + gchar* guid = ldm_volume_get_guid(vol); LDMVolumeType type = ldm_volume_get_voltype(vol); guint64 size = ldm_volume_get_size(vol); guint64 chunk_size = ldm_volume_get_chunk_size(vol); @@ -294,6 +295,8 @@ show_volume(LDM *const ldm, const gint argc, gchar ** const argv, json_builder_set_member_name(jb, "name"); json_builder_add_string_value(jb, name); + json_builder_set_member_name(jb, "guid"); + json_builder_add_string_value(jb, guid); json_builder_set_member_name(jb, "type"); json_builder_add_string_value(jb, type_v->value_nick); json_builder_set_member_name(jb, "size"); @@ -323,6 +326,7 @@ show_volume(LDM *const ldm, const gint argc, gchar ** const argv, } g_free(name); + g_free(guid); g_free(hint); if (found) break; diff --git a/test/ldmread.c b/test/ldmread.c index 85b539e..bc4d0c5 100644 --- a/test/ldmread.c +++ b/test/ldmread.c @@ -73,6 +73,7 @@ int main(int argc, const char *argv[]) { gchar *name; + gchar *guid; LDMVolumeType type; guint64 size; guint32 part_type; @@ -80,15 +81,16 @@ int main(int argc, const char *argv[]) guint64 chunk_size; g_object_get(vol, "name", &name, "type", &type, - "size", &size, "part-type", &part_type, - "hint", &hint, "chunk-size", &chunk_size, - NULL); + "guid", &guid, "size", &size, + "part-type", &part_type, "hint", &hint, + "chunk-size", &chunk_size, NULL); GEnumValue * const type_v g_enum_get_value(g_type_class_peek(LDM_TYPE_VOLUME_TYPE), type); printf(" Volume: %s\n", name); + printf(" GUID: %s\n", guid); printf(" Type: %s\n", type_v->value_nick); printf(" Size: %lu\n", size); printf(" Part Type: %hhu\n", part_type); @@ -96,6 +98,7 @@ int main(int argc, const char *argv[]) printf(" Chunk Size: %lu\n", chunk_size); g_free(name); + g_free(guid); g_free(hint); } -- 2.17.0
Mykola Ivanets
2018-May-14 11:07 UTC
[Libguestfs] [PATCH libldm v4 2/3] gtk-doc: update documentation.
gtk-doc is updated to reflect presence of new volume GUID field. --- docs/reference/ldmtool/ldmtool.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/reference/ldmtool/ldmtool.xml b/docs/reference/ldmtool/ldmtool.xml index 0f2b934..ec52633 100644 --- a/docs/reference/ldmtool/ldmtool.xml +++ b/docs/reference/ldmtool/ldmtool.xml @@ -254,6 +254,12 @@ <para>The name of the volume</para> </listitem> </varlistentry> + <varlistentry> + <term>guid</term> + <listitem> + <para>The Windows-assigned GUID of the volume</para> + </listitem> + </varlistentry> <varlistentry> <term>type</term> <listitem> @@ -568,6 +574,7 @@ ldm> show diskgroup 06495a84-fbfd-11e1-8cf9-52540061f5db ldm> show volume 06495a84-fbfd-11e1-8cf9-52540061f5db Volume1 { "name" : "Volume1", + "guid" : "c08309e9-1d30-43e5-8dc3-fcec8be76fcc", "type" : "spanned", "size" : 129024, "chunk-size" : 0, -- 2.17.0
Mykola Ivanets
2018-May-14 11:07 UTC
[Libguestfs] [PATCH libldm v4 3/3] Make git to ignore all test output files.
All files generted after running "make check" are added into .gitignore. --- test/.gitignore | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/test/.gitignore b/test/.gitignore index 8ee133a..7e62d30 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -1,19 +1,20 @@ -2003R2_MIRRORED -2003R2_MIRRORED_partial_1 -2003R2_MIRRORED_partial_2 -2003R2_RAID5 -2003R2_RAID5_partial_1 -2003R2_RAID5_partial_2 -2003R2_RAID5_partial_3 -2003R2_SIMPLE -2003R2_SPANNED -2003R2_STRIPED -2008R2_MIRRORED -2008R2_MIRRORED_partial_1 -2008R2_MIRRORED_partial_2 -2008R2_RAID5 -2008R2_RAID5_partial_1 -2008R2_RAID5_partial_2 -2008R2_RAID5_partial_3 -2008R2_SPANNED -2008R2_STRIPED +2003R2_MIRRORED* +2003R2_MIRRORED_partial_1* +2003R2_MIRRORED_partial_2* +2003R2_RAID5* +2003R2_RAID5_partial_1* +2003R2_RAID5_partial_2* +2003R2_RAID5_partial_3* +2003R2_SIMPLE* +2003R2_SPANNED* +2003R2_STRIPED* +2008R2_MIRRORED* +2008R2_MIRRORED_partial_1* +2008R2_MIRRORED_partial_2* +2008R2_RAID5* +2008R2_RAID5_partial_1* +2008R2_RAID5_partial_2* +2008R2_RAID5_partial_3* +2008R2_SPANNED* +2008R2_STRIPED* +test-suite.log -- 2.17.0
Possibly Parallel Threads
- [PATCH libldm v3 0/2] Make libldm to parse and return volume GUID.
- [PATCH libldm 00/12] New API: an ability to retrieve created device-mapper devices back after they have been created.
- [PATCH 0/1] libldm: Make libldm to parse and return volume GUID.
- [PATCH libldm v2 0/1] Make libldm to parse and return volume GUID.
- [PATCH 0/2] Two build fixes for libldm