hdt: Make the menu and cli use the new disk interfaces
authorPierre-Alexandre Meyer <pierre@mouraf.org>
Wed, 5 Aug 2009 22:11:01 +0000 (15:11 -0700)
committerPierre-Alexandre Meyer <pierre@mouraf.org>
Wed, 5 Aug 2009 22:11:01 +0000 (15:11 -0700)
The disklib interfaces have changed (errno_disk introduced). Update
these changes in hdt (nobody else use them).

Misc: fix get_error declaration.

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

index 5eb54e0..f9e319c 100644 (file)
@@ -9,5 +9,5 @@
 
 #ifndef _ERROR_H_
 #define _ERROR_H_
-void get_error(const int, char**);
+void get_error(void*);
 #endif /* _UTIL_H_ */
index 8e07ed0..197d170 100644 (file)
@@ -31,6 +31,7 @@
 #include <stdlib.h>
 #include <errno.h>
 
+#include <disk/errno_disk.h>
 #include <disk/geom.h>
 #include <disk/read.h>
 #include <disk/error.h>
@@ -64,7 +65,7 @@ static void show_partition_information(struct driveinfo *drive_info,
        char size[8];
        char *parttype;
        int error = 0;
-       char *error_buffer;
+       char error_buffer[MAX_DISK_ERRNO];
        unsigned int start, end;
 
        int i = nb_partitions_seen;
@@ -86,10 +87,10 @@ static void show_partition_information(struct driveinfo *drive_info,
                    ptab->ostype, parttype);
 
        /* Extra info */
-       if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab, &error)) {
+       if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab)) {
                more_printf("%s", " (Swsusp sig. detected)");
        } else if (error) {
-               get_error(error, &error_buffer);
+               get_error(&error_buffer);
                more_printf("%s\n", error_buffer);
                free(error_buffer);
        }
@@ -117,8 +118,7 @@ void main_show_disk(int argc, char **argv,
 
        int i = drive - 0x80;
        struct driveinfo *d = &hardware->disk_info[i];
-       int error;
-       char *error_buffer;
+       char error_buffer[MAX_DISK_ERRNO];
        char disk_size[8];
 
        detect_disks(hardware);
@@ -144,16 +144,10 @@ void main_show_disk(int argc, char **argv,
                remove_spaces(d->edd_params.interface_type));
 
        more_printf("   #  B       Start         End    Size Id Type\n");
-       error = 0;
-       if (parse_partition_table(d, &show_partition_information, &error)) {
-               if (error) {
-                       more_printf("I/O error: ");
-                       get_error(error, &error_buffer);
-                       more_printf("%s\n", error_buffer);
-                       free(error_buffer);
-               } else
-                       more_printf("An unknown error occured.\n");
-               return;
+       if (parse_partition_table(d, &show_partition_information) == -1) {
+               get_error(&error_buffer);
+               more_printf("%s\n", error_buffer);
+               free(error_buffer);
        }
 }
 
index 7e60b06..4915050 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include <stdlib.h>
+#include <disk/errno_disk.h>
 #include <disk/geom.h>
 #include <disk/read.h>
 #include <disk/partition.h>
@@ -85,8 +86,7 @@ static void compute_partition_information(struct driveinfo *drive_info,
 {
         char size[8];
         char *parttype;
-        int error = 0;
-        char *error_buffer;
+        char error_buffer[MAX_DISK_ERRNO];
         unsigned int start, end;
        char buffer[SUBMENULEN+1];
        char statbuffer[STATLEN+1];
@@ -155,16 +155,15 @@ static void compute_partition_information(struct driveinfo *drive_info,
        free(parttype);
 
         /* Extra info */
-        if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab, &error)) {
+        if (ptab->ostype == 0x82 && swsusp_check(drive_info, ptab) != -1) {
                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 if (error) {
-                get_error(error, &error_buffer);
+        } 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);
-                free(error_buffer);
         }
 
 }
@@ -224,23 +223,14 @@ static int compute_disk_module(struct s_my_menu *menu, int nb_sub_disk_menu,
   add_sep();
   dn=disk_number;
 
-  int error;
-  parse_partition_table(&d[disk_number], &show_partition_information, &error);
-  if (parse_partition_table(&d[disk_number], &compute_partition_information, &error)) {
-        if (error) {
-          char *error_buffer;
-           get_error(error, &error_buffer);
-          snprintf(buffer, sizeof buffer, "I/O error   : %s", error_buffer);
-          snprintf(statbuffer, sizeof statbuffer, "I/O error   : %s", error_buffer);
-          add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
-          menu[nb_sub_disk_menu].items_count++;
-           free(error_buffer);
-        } else {
-          snprintf(buffer, sizeof buffer, "An unknown error occured");
-          snprintf(statbuffer, sizeof statbuffer, "An unknown error occured");
-          add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
-          menu[nb_sub_disk_menu].items_count++;
-        }
+  parse_partition_table(&d[disk_number], &show_partition_information);
+  if (parse_partition_table(&d[disk_number], &compute_partition_information) == -1) {
+       char error_buffer[MAX_DISK_ERRNO];
+       get_error(&error_buffer);
+       snprintf(buffer, sizeof buffer, "I/O error   : %s", error_buffer);
+       snprintf(statbuffer, sizeof statbuffer, "I/O error   : %s", error_buffer);
+       add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
+       menu[nb_sub_disk_menu].items_count++;
   }
 
   return 0;