]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
New -t luks_uuid
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 22 Apr 2011 21:51:16 +0000 (23:51 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 22 Apr 2011 21:51:16 +0000 (23:51 +0200)
grub-core/disk/luks.c
include/grub/emu/hostdisk.h
util/grub-probe.c

index ce1f1bfc6e0e0be7e33ea0f9bf93a6184d95ba97..997e2eb3072cb3eeccb8c68887881765db454bb0 100644 (file)
@@ -893,6 +893,13 @@ grub_util_luks_print_ciphers (grub_disk_t disk)
   if (dev->essiv_hash)
     grub_printf ("%s ", dev->essiv_hash->modname);
 }
+
+void
+grub_util_luks_print_uuid (grub_disk_t disk)
+{
+  grub_luks_t dev = (grub_luks_t) disk->data;
+  grub_printf ("%s ", dev->uuid);
+}
 #endif
 
 static void
index 2be24cc3fc2407c9e3aec7020dc401628d883982..7541308e6af7d94fcd87289acf4da5052e08a6ae 100644 (file)
@@ -37,5 +37,6 @@ ssize_t grub_util_fd_read (int fd, char *buf, size_t len);
 grub_err_t
 grub_luks_cheat_mount (const char *sourcedev, const char *cheat);
 void grub_util_luks_print_ciphers (grub_disk_t disk);
+void grub_util_luks_print_uuid (grub_disk_t disk);
 
 #endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */
index 68d9b06f1d2e45f769eb393f11775979cee9af32..21fc21b025993f21c6c723074bf53b27629ff2ec 100644 (file)
@@ -55,6 +55,7 @@ enum {
   PRINT_DEVICE,
   PRINT_PARTMAP,
   PRINT_ABSTRACTION,
+  PRINT_LUKS_UUID
 };
 
 int print = PRINT_FS;
@@ -88,6 +89,27 @@ probe_partmap (grub_disk_t disk)
     }
 }
 
+static void
+probe_luks_uuid (grub_disk_t disk)
+{
+  grub_disk_memberlist_t list = NULL, tmp;
+
+  /* In case of LVM/RAID, check the member devices as well.  */
+  if (disk->dev->memberlist)
+    {
+      list = disk->dev->memberlist (disk);
+    }
+  while (list)
+    {
+      probe_luks_uuid (list->disk);
+      tmp = list->next;
+      free (list);
+      list = tmp;
+    }
+  if (disk->dev->id == GRUB_DISK_DEVICE_LUKS_ID)
+    grub_util_luks_print_uuid (disk);
+}
+
 static int
 probe_raid_level (grub_disk_t disk)
 {
@@ -194,6 +216,13 @@ probe (const char *path, char *device_name)
       goto end;
     }
 
+  if (print == PRINT_LUKS_UUID)
+    {
+      probe_luks_uuid (dev->disk);
+      printf ("\n");
+      goto end;
+    }
+
   if (print == PRINT_PARTMAP)
     {
       /* Check if dev->disk itself is contained in a partmap.  */
@@ -267,8 +296,8 @@ Probe device information for a given path (or device, if the -d option is given)
 \n\
   -d, --device              given argument is a system device, not a path\n\
   -m, --device-map=FILE     use FILE as the device map [default=%s]\n\
-  -t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction)\n\
-                            print filesystem module, GRUB drive, system device, partition map module or abstraction module [default=fs]\n\
+  -t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction|luks_uuid)\n\
+                            print filesystem module, GRUB drive, system device, partition map module, abstraction module or LUKS UUID [default=fs]\n\
   -h, --help                display this message and exit\n\
   -V, --version             print version information and exit\n\
   -v, --verbose             print verbose messages\n\
@@ -326,6 +355,8 @@ main (int argc, char *argv[])
              print = PRINT_PARTMAP;
            else if (!strcmp (optarg, "abstraction"))
              print = PRINT_ABSTRACTION;
+           else if (!strcmp (optarg, "luks_uuid"))
+             print = PRINT_LUKS_UUID;
            else
              usage (1);
            break;