summaryrefslogtreecommitdiff
path: root/extras/ata_id
diff options
context:
space:
mode:
authorDavid Zeuthen <david@fubar.dk>2009-02-17 14:15:17 -0500
committerKay Sievers <kay@linux-v6qv.(none)>2009-02-17 21:45:43 +0100
commitad88f9409a546ed3f1d69df66040a8f19b6eeafb (patch)
tree98e2fb3060ba0a95edbfe6451fbc219358f00691 /extras/ata_id
parentdc9aa5e941a0aabde9d8ee225a0c5508fa5f83a1 (diff)
*_id: add model/vendor enc strings
So ID_MODEL and ID_VENDOR are pretty useful keys. However since we fix them up (removing leading/trailing whitespace, converts spaces to underscores) for use in device naming etc. we also force these fixups on the desktop shell. And this looks pretty ugly. The attached patch introduces the ID_MODEL_ENC and ID_VENDOR_ENC keys that contains the encoded version of the raw strings obtained. It's pretty similar in spirit to ID_FS_LABEL and its cousin ID_FS_LABEL_ENC. With this patch a desktop shell can fix up these strings as it sees fit. Note that some fixup is still needed though, for example # /lib/udev/ata_id --export /dev/sda |grep ID_MODEL ID_MODEL=INTEL_SSDSA2MH080G1GC ID_MODEL_ENC=INTEL\x20SSDSA2MH080G1GC\x20\x20\x20\x20\x20\x20\x20\x20 \x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 Note the trailing and leading whitespace. Anyway with the attached patch the desktop shell should be able to display "INTEL SSDSA2MH080G1GC" rather than "INTEL_SSDSA2MH080G1GC" to the user.
Diffstat (limited to 'extras/ata_id')
-rw-r--r--extras/ata_id/ata_id.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/extras/ata_id/ata_id.c b/extras/ata_id/ata_id.c
index 6f2e28baa3..dd28d91f4a 100644
--- a/extras/ata_id/ata_id.c
+++ b/extras/ata_id/ata_id.c
@@ -49,6 +49,7 @@ int main(int argc, char *argv[])
struct udev *udev;
struct hd_driveid id;
char model[41];
+ char model_enc[256];
char serial[21];
char revision[9];
const char *node = NULL;
@@ -114,6 +115,9 @@ int main(int argc, char *argv[])
goto close;
}
+ memcpy (model, id.model, 40);
+ model[40] = '\0';
+ udev_util_encode_string(model, model_enc, sizeof(model_enc));
udev_util_replace_whitespace((char *) id.model, model, 40);
udev_util_replace_chars(model, NULL);
udev_util_replace_whitespace((char *) id.serial_no, serial, 20);
@@ -145,6 +149,7 @@ int main(int argc, char *argv[])
printf("ID_TYPE=disk\n");
}
printf("ID_MODEL=%s\n", model);
+ printf("ID_MODEL_ENC=%s\n", model_enc);
printf("ID_SERIAL=%s\n", serial);
printf("ID_REVISION=%s\n", revision);
printf("ID_BUS=ata\n");