Add udisks_ata_identify_get_word() utility function
authorDavid Zeuthen <zeuthen@gmail.com>
Mon, 5 Nov 2012 18:29:14 +0000 (13:29 -0500)
committerDavid Zeuthen <zeuthen@gmail.com>
Mon, 5 Nov 2012 18:29:14 +0000 (13:29 -0500)
Signed-off-by: David Zeuthen <zeuthen@gmail.com>
doc/udisks2-sections.txt
src/udisksdaemonutil.c
src/udisksdaemonutil.h

index 082671c..ce8eb85 100644 (file)
@@ -383,6 +383,7 @@ udisks_daemon_util_hexdump_debug
 udisks_daemon_util_file_set_contents
 udisks_daemon_util_on_same_seat
 udisks_daemon_util_get_free_mdraid_device
+udisks_ata_identify_get_word
 </SECTION>
 
 <SECTION>
index dc72acc..4a9baf3 100644 (file)
@@ -1417,3 +1417,32 @@ udisks_daemon_util_get_free_mdraid_device (void)
  out:
   return ret;
 }
+
+
+/**
+ * udisks_ata_identify_get_word:
+ * @identify_data: (allow-none): A 512-byte array containing ATA IDENTIFY or ATA IDENTIFY PACKET DEVICE data or %NULL.
+ * @word_number: The word number to get - must be less than 256.
+ *
+ * Gets a <quote>word</quote> from position @word_number from
+ * @identify_data.
+ *
+ * Returns: The word at the specified position or 0 if @identify_data is %NULL.
+ */
+guint16
+udisks_ata_identify_get_word (const guchar *identify_data, guint word_number)
+{
+  const guint16 *words = (const guint16 *) identify_data;
+  guint16 ret = 0;
+
+  g_return_val_if_fail (word_number < 256, 0);
+
+  if (identify_data == NULL)
+    goto out;
+
+  ret = GUINT16_FROM_LE (words[word_number]);
+
+ out:
+  return ret;
+}
+
index 617c19e..1f2fac1 100644 (file)
@@ -93,6 +93,8 @@ gboolean udisks_daemon_util_on_same_seat (UDisksDaemon          *daemon,
 
 gchar *udisks_daemon_util_get_free_mdraid_device (void);
 
+guint16 udisks_ata_identify_get_word (const guchar *identify_data, guint word_number);
+
 G_END_DECLS
 
 #endif /* __UDISKS_DAEMON_UTIL_H__ */