[gnome-boxes] installer-media: Fetch original volume ID from udev
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] installer-media: Fetch original volume ID from udev
- Date: Tue, 19 Feb 2013 20:33:58 +0000 (UTC)
commit 43cc58069cb6c06b872de6f12d2d2831263ed02b
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Feb 19 03:47:29 2013 +0200
installer-media: Fetch original volume ID from udev
udev replaces spaces (' ') with underscores ('_') in 'ID_FS_LABEL'
property. Since there is no way to know if an underscore was
originally a space or not in the source volume ID, we better use
'ID_FS_LABEL_ENC' instead. In that property spaces are escaped by '\x20'
and hence we can be much more certain about it being originally a space.
https://bugzilla.gnome.org/show_bug.cgi?id=694141
src/installer-media.vala | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/src/installer-media.vala b/src/installer-media.vala
index 278d4da..23dc996 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -146,7 +146,7 @@ private class Boxes.InstallerMedia : GLib.Object {
if (!device.get_property_as_boolean ("OSINFO_BOOTABLE"))
throw new OSDatabaseError.NON_BOOTABLE ("Media %s is not bootable.", device_file);
- label = device.get_property ("ID_FS_LABEL");
+ label = get_decoded_udev_property (device, "ID_FS_LABEL_ENC");
var os_id = device.get_property ("OSINFO_INSTALLER") ?? device.get_property ("OSINFO_LIVE");
@@ -159,6 +159,25 @@ private class Boxes.InstallerMedia : GLib.Object {
}
}
+ private string? get_decoded_udev_property (GUdev.Device device, string property_name) {
+ var encoded = device.get_property (property_name);
+
+ var decoded = "";
+ for (var i = 0; i < encoded.length; ) {
+ uint8 x;
+
+ if (encoded[i:encoded.length].scanf ("\\x%02x", out x) > 0) {
+ decoded += ((char) x).to_string ();
+ i += 4;
+ } else {
+ decoded += encoded[i].to_string ();
+ i++;
+ }
+ }
+
+ return decoded;
+ }
+
private void setup_label (string? label = null) {
if (label != null)
this.label = label;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]