hdt: Fix disk menu to use the new disklib interfaces
authorPierre-Alexandre Meyer <pierre@mouraf.org>
Wed, 5 Aug 2009 22:59:57 +0000 (15:59 -0700)
committerPierre-Alexandre Meyer <pierre@mouraf.org>
Wed, 5 Aug 2009 22:59:57 +0000 (15:59 -0700)
Adapt the disk menu to use the new disklib interfaces. This fixes bugs related
to the display of partition numbering and swsusp signature.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
com32/hdt/hdt-cli.h
com32/hdt/hdt-common.h
com32/hdt/hdt-menu-disk.c

index 651575d..47137cc 100644 (file)
@@ -40,9 +40,6 @@
 # define dprintf(f, ...) ((void)0)
 #endif
 
-/* Declare a variable or data structure as unused. */
-#define __unused __attribute__ (( unused ))
-
 #define MAX_LINE_SIZE 256
 
 #define CLI_SPACE " "
index 5118dd6..2b67f9c 100644 (file)
@@ -40,6 +40,9 @@
 #include "../lib/sys/vesa/vesa.h"
 #include <vpd/vpd.h>
 
+/* Declare a variable or data structure as unused. */
+#define __unused __attribute__ (( unused ))
+
 /* This two values are used for switching for the menu to the CLI mode */
 #define HDT_SWITCH_TO_CLI "hdt_switch_to_cli"
 #define HDT_RETURN_TO_CLI 100
index 4915050..05aef70 100644 (file)
 static int dn;
 
 static void show_partition_information(struct driveinfo *drive_info,
-                                       struct part_entry *ptab,
-                                       struct part_entry *ptab_root,
-                                       int offset_root, int data_partitions_seen,
-                                       int ebr_seen)
+                                       struct part_entry *ptab __unused,
+                                       int partition_offset __unused,
+                                       int nb_partitions_seen)
 {
        char menu_title[MENULEN + 1];
        char menu_title_ref[MENULEN + 1];
-       /* Useless code to prevent warnings */
-       ptab=ptab; ptab_root=ptab_root;offset_root=offset_root;
-
-        int i = 1 + ebr_seen * 4 + data_partitions_seen;
 
        memset(menu_title,0,sizeof menu_title);
        memset(menu_title_ref,0,sizeof menu_title_ref);
-       snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d", 
-                       drive_info[dn].disk, i);
-       snprintf(menu_title, sizeof menu_title, "Partition %d", i);
+       snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d",
+                       drive_info[dn].disk, nb_partitions_seen);
+       snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen);
 
        add_item(menu_title, "Partition information (start, end, length, type, ...)",
                        OPT_SUBMENU, menu_title_ref, 0);
-
 }
 /**
  * compute_partition_information - print information about a partition
@@ -79,34 +73,30 @@ static void show_partition_information(struct driveinfo *drive_info,
  *  at the MBR... but still not absolute!
  **/
 static void compute_partition_information(struct driveinfo *drive_info,
-                                       struct part_entry *ptab,
-                                       struct part_entry *ptab_root,
-                                       int offset_root, int data_partitions_seen,
-                                       int ebr_seen)
+                                          struct part_entry *ptab,
+                                          int partition_offset,
+                                          int nb_partitions_seen)
 {
         char size[8];
         char *parttype;
-        char error_buffer[MAX_DISK_ERRNO];
         unsigned int start, end;
        char buffer[SUBMENULEN+1];
        char statbuffer[STATLEN+1];
        char menu_title[MENULEN + 1];
        char menu_title_ref[MENULEN + 1];
 
-        int i = 1 + ebr_seen * 4 + data_partitions_seen;
-
        memset(buffer,0,sizeof buffer);
        memset(statbuffer,0,sizeof statbuffer);
        memset(menu_title,0,sizeof menu_title);
        memset(menu_title_ref,0,sizeof menu_title_ref);
-       snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d", drive_info[dn].disk, i);
-       snprintf(menu_title, sizeof menu_title, "Partition %d", i);
+       snprintf(menu_title_ref, sizeof menu_title_ref, "disk_%x_part_%d", drive_info[dn].disk, nb_partitions_seen);
+       snprintf(menu_title, sizeof menu_title, "Partition %d", nb_partitions_seen);
 
        add_named_menu(menu_title_ref,menu_title,-1);
        set_menu_pos(SUBMENU_Y,SUBMENU_X);
 
-       start = ptab->start_lba + ptab_root->start_lba + offset_root;
-        end = (ptab->start_lba + ptab_root->start_lba) + ptab->length + offset_root;
+       start = partition_offset;
+       end = start + ptab->length;
 
         if (ptab->length > 0)
                 sectors_to_size(ptab->length, size);
@@ -159,13 +149,7 @@ static void compute_partition_information(struct driveinfo *drive_info,
                snprintf(buffer, sizeof buffer, "%s","Swsusp sig  : detected");
                snprintf(statbuffer, sizeof statbuffer, "%s","Swsusp sig  : detected");
                add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
-        } else {
-                get_error(&error_buffer);
-               snprintf(buffer, sizeof buffer, "%s",error_buffer);
-               snprintf(statbuffer, sizeof statbuffer, "%s",error_buffer);
-               add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
         }
-
 }
 
 /* Compute the disk submenu */