Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package parti for openSUSE:Factory checked 
in at 2023-03-21 17:43:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/parti (Old)
 and      /work/SRC/openSUSE:Factory/.parti.new.31432 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "parti"

Tue Mar 21 17:43:24 2023 rev:13 rq:1073369 version:2.3

Changes:
--------
--- /work/SRC/openSUSE:Factory/parti/parti.changes      2021-11-20 
02:39:53.860630183 +0100
+++ /work/SRC/openSUSE:Factory/.parti.new.31432/parti.changes   2023-03-21 
17:44:18.454627916 +0100
@@ -1,0 +2,7 @@
+Mon Mar 20 19:56:49 UTC 2023 - wfe...@opensuse.org
+
+- merge gh#wfeldt/parti#14
+- show boot info table information
+- 2.3
+
+--------------------------------------------------------------------

Old:
----
  parti-2.2.tar.xz

New:
----
  parti-2.3.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ parti.spec ++++++
--- /var/tmp/diff_new_pack.Ebza0C/_old  2023-03-21 17:44:19.062630824 +0100
+++ /var/tmp/diff_new_pack.Ebza0C/_new  2023-03-21 17:44:19.066630843 +0100
@@ -18,7 +18,7 @@
 
 
 Name:           parti
-Version:        2.2
+Version:        2.3
 Release:        0
 Summary:        Show partition table information
 License:        GPL-3.0

++++++ parti-2.2.tar.xz -> parti-2.3.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/parti-2.2/VERSION new/parti-2.3/VERSION
--- old/parti-2.2/VERSION       2021-11-18 13:58:47.000000000 +0100
+++ new/parti-2.3/VERSION       2023-03-20 20:56:49.000000000 +0100
@@ -1 +1 @@
-2.2
+2.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/parti-2.2/changelog new/parti-2.3/changelog
--- old/parti-2.2/changelog     2021-11-18 13:58:47.000000000 +0100
+++ new/parti-2.3/changelog     2023-03-20 20:56:49.000000000 +0100
@@ -1,3 +1,7 @@
+2023-03-20:    2.3
+       - merge gh#wfeldt/parti#14
+       - show boot info table information
+
 2021-11-18:    2.2
        - merge gh#wfeldt/parti#13
        - report also empty mbr partition tables
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/parti-2.2/disk.h new/parti-2.3/disk.h
--- old/parti-2.2/disk.h        2021-11-18 13:58:47.000000000 +0100
+++ new/parti-2.3/disk.h        2023-03-20 20:56:49.000000000 +0100
@@ -16,6 +16,8 @@
   uint64_t size_in_bytes;
   unsigned chunk_size;
   unsigned block_size;
+  unsigned grub_used:1;
+  unsigned isolinux_used:1;
   disk_data_t *data;
   json_object *json_disk;
   json_object *json_current;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/parti-2.2/eltorito.c new/parti-2.3/eltorito.c
--- old/parti-2.2/eltorito.c    2021-11-18 13:58:47.000000000 +0100
+++ new/parti-2.3/eltorito.c    2023-03-20 20:56:49.000000000 +0100
@@ -18,6 +18,8 @@
 // set to 0 or 2
 #define BLK_FIX                2
 
+static void dump_bootinfo(disk_t *disk, uint64_t sector);
+
 void dump_eltorito(disk_t *disk)
 {
   int i, j;
@@ -132,7 +134,7 @@
           le16toh(el->entry.size),
           BLK_FIX ? "" : "/4"
         );
-        if((s = iso_block_to_name(disk, le32toh(el->entry.start) << 2))) {
+        if((s = iso_block_to_name(disk, le32toh(el->entry.start) << 2, NULL))) 
{
           json_object_object_add(json_entry, "file_name", 
json_object_new_string(s));
           log_info(", \"%s\"", s);
         }
@@ -143,6 +145,7 @@
         disk->json_current = json_entry;
         unsigned old_block_size = disk->block_size;
         disk->block_size = 512;
+        dump_bootinfo(disk, le32toh(el->entry.start) << BLK_FIX);
         dump_fs(disk, 7, le32toh(el->entry.start) << BLK_FIX);
         disk->block_size = old_block_size;
         disk->json_current = disk->json_disk;
@@ -174,6 +177,74 @@
     }
   }
 }
-#undef BLK_FIX
 
 
+static void dump_bootinfo(disk_t *disk, uint64_t sector)
+{
+  unsigned char buf[disk->block_size];
+  unsigned char pvd[disk->block_size];
+  unsigned char grub_info[disk->block_size];
+
+  if(disk->block_size < 0x200) return;
+
+  if(disk_read(disk, buf, sector, 1)) return;
+
+  unsigned bi_pvd = read_dword_le(buf + 8) << BLK_FIX;
+  unsigned bi_start = read_dword_le(buf + 12) << BLK_FIX;
+  unsigned bi_size = read_dword_le(buf + 16);
+  unsigned bi_crc = read_dword_le(buf + 20);
+
+  if((uint64_t) bi_pvd * disk->block_size > disk->size_in_bytes + 
disk->block_size) return;
+  if(disk_read(disk, pvd, bi_pvd, 1)) return;
+  if(memcmp(pvd, ISO_MAGIC, sizeof ISO_MAGIC - 1)) return;
+
+  unsigned file_size = -1u;
+  iso_block_to_name(disk, sector, &file_size);
+
+  unsigned crc = 0;
+
+  if(file_size == bi_size) {
+    for(unsigned u = 64, block_nr = sector; u < file_size; u += 4) {
+      if(u && !(u % disk->block_size)) {
+        if(disk_read(disk, buf, ++block_nr, 1)) break;
+      }
+      crc += read_dword_le(buf + u % disk->block_size);
+    }
+  }
+
+  uint64_t grub_lba = 0; 
+
+  if(disk->grub_used && !disk_read(disk, grub_info, sector + 4, 1)) {
+    grub_lba = read_qword_le(grub_info + 0x1f4);
+  }
+
+  log_info("       boot info table:\n");
+  log_info("         volume descriptor %u\n", bi_pvd);
+  log_info("         start %u (%s)\n", bi_start, bi_start == sector ? "ok" : 
"wrong");
+  log_info("         size %u (%s)\n", bi_size, bi_size == file_size ? "ok" : 
"wrong");
+  log_info("         crc 0x%08x (%s)\n", bi_crc, bi_crc == crc ? "ok" : 
"wrong");
+  if(disk->grub_used) {
+    log_info("         grub start %"PRIu64" (%s)\n", grub_lba, grub_lba == 
sector + 5 ? "ok" : "wrong");
+  }
+
+  json_object *json_fs = json_object_new_object();
+  json_object_object_add(disk->json_current, "boot_info_table", json_fs);
+
+  json_object_object_add(json_fs, "volume_descriptor_lba", 
json_object_new_int64(bi_pvd));
+  json_object_object_add(json_fs, "file_lba", json_object_new_int64(bi_start));
+  json_object_object_add(json_fs, "file_lba_ok", 
json_object_new_boolean(bi_start == sector));
+  json_object_object_add(json_fs, "file_size", json_object_new_int64(bi_size));
+  json_object_object_add(json_fs, "file_size_ok", 
json_object_new_boolean(bi_size == file_size));
+  if(disk->grub_used) {
+    json_object_object_add(json_fs, "grub_lba", 
json_object_new_int64(grub_lba));
+    json_object_object_add(json_fs, "grub_lba_ok", 
json_object_new_boolean(grub_lba == sector + 5));
+  }
+
+  json_object *json_crc = json_object_new_object();
+  json_object_object_add(json_fs, "crc", json_crc);
+  json_object_object_add(json_crc, "stored", json_object_new_format("0x%08x", 
bi_crc));
+  json_object_object_add(json_crc, "calculated", 
json_object_new_format("0x%08x", crc));
+  json_object_object_add(json_crc, "ok", json_object_new_boolean(bi_crc == 
crc));
+}
+
+#undef BLK_FIX
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/parti-2.2/filesystem.c new/parti-2.3/filesystem.c
--- old/parti-2.2/filesystem.c  2021-11-18 13:58:47.000000000 +0100
+++ new/parti-2.3/filesystem.c  2023-03-20 20:56:49.000000000 +0100
@@ -260,7 +260,7 @@
     log_info(", uuid \"%s\"", fs_detail.uuid);
   }
 
-  if((s = iso_block_to_name(disk, (sector * disk->block_size) >> 9))) {
+  if((s = iso_block_to_name(disk, (sector * disk->block_size) >> 9, NULL))) {
     json_object_object_add(json_fs, "file_name", json_object_new_string(s));
     log_info(", \"%s\"", s);
   }
@@ -275,7 +275,7 @@
 /*
  * block is in 512 byte units
  */
-char *iso_block_to_name(disk_t *disk, unsigned block)
+char *iso_block_to_name(disk_t *disk, unsigned block, unsigned *len)
 {
   static char *buf = NULL;
   file_start_t *fs;
@@ -288,6 +288,7 @@
   }
 
   if(fs) {
+    if(len) *len = fs->len;
     if(block == fs->block) {
       name = fs->name;
     }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/parti-2.2/filesystem.h new/parti-2.3/filesystem.h
--- old/parti-2.2/filesystem.h  2021-11-18 13:58:47.000000000 +0100
+++ new/parti-2.3/filesystem.h  2023-03-20 20:56:49.000000000 +0100
@@ -1,2 +1,2 @@
 int dump_fs(disk_t *disk, int indent, uint64_t sector);
-char *iso_block_to_name(disk_t *disk, unsigned block);
+char *iso_block_to_name(disk_t *disk, unsigned block, unsigned *len);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/parti-2.2/ptable_mbr.c new/parti-2.3/ptable_mbr.c
--- old/parti-2.2/ptable_mbr.c  2021-11-18 13:58:47.000000000 +0100
+++ new/parti-2.3/ptable_mbr.c  2023-03-20 20:56:49.000000000 +0100
@@ -301,19 +301,37 @@
 
   json_object_object_add(json_mbr, "id", json_object_new_format("0x%08x", id));
 
-  if(memmem(buf, disk->block_size, "isolinux.bin", sizeof "isolinux.bin" - 1)) 
{
+  // 32 or 64 bit?
+  //
+  // Tools that write the value claim 64 bit.
+  // isolinux actually uses 32 bit when loading.
+  // And no Legacy BIOS handles 64 bit correctly anyway.
+  uint64_t bi_start = le64toh(*(uint64_t *) (buf + 0x1b0));
+
+  if(bi_start) {
     char *s;
-    unsigned start = le32toh(*(uint32_t *) (buf + 0x1b0));
-    log_info("  isolinux: %u", start);
-    if((s = iso_block_to_name(disk, start))) {
+    char *bi_type = "bootinfo";
+    if(memmem(buf, disk->block_size, "isolinux.bin", sizeof "isolinux.bin" - 
1)) {
+      bi_type = "isolinux";
+      disk->isolinux_used = 1;
+    }
+    else if(memmem(buf, disk->block_size, "GRUB", sizeof "GRUB" - 1)) {
+      bi_type = "grub";
+      disk->grub_used = 1;
+      // grub stores offset to image + 4 blocks
+      bi_start -= 4;
+    }
+
+    log_info("  %s: %"PRIu64, bi_type, bi_start);
+    if((s = iso_block_to_name(disk, bi_start, NULL))) {
       log_info(", \"%s\"", s);
     }
     log_info("\n");
 
     json_object *json_isolinux = json_object_new_object();
-    json_object_object_add(json_mbr, "isolinux", json_isolinux);
+    json_object_object_add(json_mbr, bi_type, json_isolinux);
 
-    json_object_object_add(json_isolinux, "first_lba", 
json_object_new_int64(start));
+    json_object_object_add(json_isolinux, "first_lba", 
json_object_new_int64(bi_start));
     if(s) json_object_object_add(json_isolinux, "file_name", 
json_object_new_string(s));
   }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/parti-2.2/zipl.c new/parti-2.3/zipl.c
--- old/parti-2.2/zipl.c        2021-11-18 13:58:47.000000000 +0100
+++ new/parti-2.3/zipl.c        2023-03-20 20:56:49.000000000 +0100
@@ -69,7 +69,7 @@
             len2
           );
           if(size2 != disk->block_size || opt.show.raw) log_info(", blksize 
%d", size2);
-          if((s = iso_block_to_name(disk, start2))) {
+          if((s = iso_block_to_name(disk, start2, NULL))) {
             log_info(", \"%s\"", s);
           }
           log_info("\n");
@@ -170,7 +170,7 @@
 
   log_info("  program table: %llu", (unsigned long long) pt_sec);
   if(size != disk->block_size || opt.show.raw) log_info(", blksize %u", size);
-  if((s = iso_block_to_name(disk, pt_sec))) {
+  if((s = iso_block_to_name(disk, pt_sec, NULL))) {
     log_info(", \"%s\"", s);
   }
   log_info("\n");

Reply via email to