Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/sysinst Some fixes for the do_install() function:



details:   https://anonhg.NetBSD.org/src/rev/40f3e1745874
branches:  trunk
changeset: 471724:40f3e1745874
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Fri Apr 09 10:24:38 1999 +0000

description:
Some fixes for the do_install() function:
- Make all the functions called from do_install() return an error code,
  so that we can abort install if something went wrong.
- Add a 'errstr' argument to run_prog(), which if not NULL is displayed
  with msg_printf() and followed by process_menu(MENU_ok) if the command fail.
  Used to warn the user that the current action is aborted.
- in a few places use msg_display() or msg_printf() rather than printf.
  It seems that stdout/stderr are not always pointing to the active curses
  window.
- garbage-collecd unused messages, add a few new one (error handling).
XXX only tested on i386. Other md parts should be tested as well.

diffstat:

 distrib/utils/sysinst/arch/alpha/md.c       |  18 +++++---
 distrib/utils/sysinst/arch/arm32/md.c       |  23 ++++++----
 distrib/utils/sysinst/arch/bebox/md.c       |  31 +++++++++-----
 distrib/utils/sysinst/arch/bebox/msg.md.eng |   5 +-
 distrib/utils/sysinst/arch/i386/md.c        |  60 ++++++++++++++++++----------
 distrib/utils/sysinst/arch/i386/menus.md.fr |   4 +-
 distrib/utils/sysinst/arch/i386/msg.md.eng  |   5 +-
 distrib/utils/sysinst/arch/i386/msg.md.fr   |  10 ++-
 distrib/utils/sysinst/arch/mac68k/md.c      |  31 ++++++++------
 distrib/utils/sysinst/arch/macppc/md.c      |  17 ++++---
 distrib/utils/sysinst/arch/pc532/md.c       |  14 ++++--
 distrib/utils/sysinst/arch/pmax/md.c        |  23 ++++++----
 distrib/utils/sysinst/arch/sparc/md.c       |  21 +++++----
 distrib/utils/sysinst/arch/vax/md.c         |  18 ++++----
 distrib/utils/sysinst/defs.h                |  21 ++++-----
 distrib/utils/sysinst/disks.c               |  46 ++++++++++++++--------
 distrib/utils/sysinst/install.c             |  29 +++++++++----
 distrib/utils/sysinst/label.c               |   6 +-
 distrib/utils/sysinst/main.c                |   4 +-
 distrib/utils/sysinst/menus.mi.eng          |   8 +-
 distrib/utils/sysinst/menus.mi.fr           |  10 +++-
 distrib/utils/sysinst/msg.mi.eng            |  14 ++++-
 distrib/utils/sysinst/msg.mi.fr             |  14 ++++-
 distrib/utils/sysinst/net.c                 |  34 ++++++++++-----
 distrib/utils/sysinst/run.c                 |  13 +++--
 distrib/utils/sysinst/target.c              |  24 +++++-----
 distrib/utils/sysinst/util.c                |  33 ++++++++-------
 27 files changed, 324 insertions(+), 212 deletions(-)

diffs (truncated from 1549 to 300 lines):

diff -r 864706f22a86 -r 40f3e1745874 distrib/utils/sysinst/arch/alpha/md.c
--- a/distrib/utils/sysinst/arch/alpha/md.c     Fri Apr 09 10:06:18 1999 +0000
+++ b/distrib/utils/sysinst/arch/alpha/md.c     Fri Apr 09 10:24:38 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.9 1999/03/31 00:44:49 fvdl Exp $      */
+/*     $NetBSD: md.c,v 1.10 1999/04/09 10:24:40 bouyer Exp $   */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -109,15 +109,17 @@
 /*
  * hook called before writing new disklabel.
  */
-void   md_pre_disklabel (void)
+int    md_pre_disklabel (void)
 {
+       return 0;
 }
 
 /*
  * hook called after writing disklabel to new target disk.
  */
-void   md_post_disklabel (void)
+int    md_post_disklabel (void)
 {
+       return 0;
 }
 
 /*
@@ -129,7 +131,7 @@
  *
  * On the Alpha, we use this opportunity to install the boot blocks.
  */
-void   md_post_newfs (void)
+int    md_post_newfs (void)
 {
 
        const char *bootfile = target_expand("/boot");  /*XXX*/
@@ -138,9 +140,10 @@
        cp_to_target("/usr/mdec/boot", "/boot");
        run_prog(0, 0, "/usr/mdec/installboot %s %s /dev/r%sc",
            bootfile,  "/usr/mdec/bootxx", diskdev);
+       return 0;
 }
 
-void   md_copy_filesystem (void)
+int    md_copy_filesystem (void)
 {
        if (target_already_root()) {
                return;
@@ -148,10 +151,11 @@
 
        /* Copy the instbin(s) to the disk */
        printf ("%s", msg_string(MSG_dotar));
-       run_prog(0, 0, "pax -X -r -w -pe / /mnt");
+       if (run_prog(0, 0, "pax -X -r -w -pe / /mnt") != 0)
+               return 1;
 
        /* Copy next-stage profile into target /.profile. */
-       cp_to_target ("/tmp/.hdprofile", "/.profile");
+       return cp_to_target ("/tmp/.hdprofile", "/.profile");
 }
 
 int md_make_bsd_partitions (void)
diff -r 864706f22a86 -r 40f3e1745874 distrib/utils/sysinst/arch/arm32/md.c
--- a/distrib/utils/sysinst/arch/arm32/md.c     Fri Apr 09 10:06:18 1999 +0000
+++ b/distrib/utils/sysinst/arch/arm32/md.c     Fri Apr 09 10:24:38 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.15 1999/03/31 00:44:49 fvdl Exp $     */
+/*     $NetBSD: md.c,v 1.16 1999/04/09 10:24:40 bouyer Exp $   */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -268,15 +268,17 @@
        return 1;
 }
 
-void   md_pre_disklabel (void)
+int    md_pre_disklabel (void)
 {
+       return 0;
 }
 
-void   md_post_disklabel (void)
+int    md_post_disklabel (void)
 {
+       return 0;
 }
 
-void   md_post_newfs (void)
+int    md_post_newfs (void)
 {
 #if 0
        /* XXX boot blocks ... */
@@ -284,21 +286,24 @@
        run_prog(0, 1, "/sbin/disklabel -B %s /dev/r%sc",
            "-b /usr/mdec/rzboot -s /usr/mdec/bootrz", diskdev);
 #endif
+       return 0;
 }
 
-void   md_copy_filesystem (void)
+int    md_copy_filesystem (void)
 {
        if (target_already_root()) {
-               return;
+               return 0;
        }
 
        /* Copy the instbin(s) to the disk */
        printf("%s", msg_string(MSG_dotar));
-       run_prog(0, 1, "pax -X -r -w -pe / /mnt");
+       if (run_prog(0, 1, "pax -X -r -w -pe / /mnt") != 0)
+               return 1;
 
        /* Copy next-stage install profile into target /.profile. */
-       cp_to_target("/tmp/.hdprofile", "/.profile");
-       cp_to_target("/usr/share/misc/termcap", "/.termcap");
+       if (cp_to_target("/tmp/.hdprofile", "/.profile") != 0)
+               return 1;
+       return cp_to_target("/usr/share/misc/termcap", "/.termcap");
 }
 
 int md_make_bsd_partitions (void)
diff -r 864706f22a86 -r 40f3e1745874 distrib/utils/sysinst/arch/bebox/md.c
--- a/distrib/utils/sysinst/arch/bebox/md.c     Fri Apr 09 10:06:18 1999 +0000
+++ b/distrib/utils/sysinst/arch/bebox/md.c     Fri Apr 09 10:24:38 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.7 1999/03/31 00:44:49 fvdl Exp $ */
+/*     $NetBSD: md.c,v 1.8 1999/04/09 10:24:40 bouyer Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -62,44 +62,53 @@
        return edit_mbr();
 }
 
-void md_pre_disklabel()
+int md_pre_disklabel()
 {
        printf ("%s", msg_string (MSG_dofdisk));
 
        /* write edited MBR onto disk. */
-       write_mbr(diskdev, mbr, sizeof mbr);
+       if (write_mbr(diskdev, mbr, sizeof mbr) != 0) {
+               msg_display(MSG_wmbrfail);
+               process_menu(MENU_ok);
+               return 1;
+       }
+       return 0;
 }
 
-void md_post_disklabel(void)
+int md_post_disklabel(void)
 {
        /* Sector forwarding / badblocks ... */
        if (*doessf) {
                printf ("%s", msg_string (MSG_dobad144));
-               run_prog(0, 1, "/usr/sbin/bad144 %s 0", diskdev);
+               return run_prog(0, 1, "/usr/sbin/bad144 %s 0", diskdev);
        }
+       return 0;
 }
 
-void md_post_newfs(void)
+int md_post_newfs(void)
 {
        /* boot blocks ... */
        printf (msg_string(MSG_dobootblks), diskdev);
        run_prog (0, 1, "/usr/mdec/installboot -v /usr/mdec/biosboot.sym "
                  "/dev/r%sa", diskdev);
+       return 0;
 }
 
-void md_copy_filesystem (void)
+int md_copy_filesystem (void)
 {
        if (target_already_root()) {
-               return;
+               return 0;
        }
 
        /* Copy the instbin(s) to the disk */
        printf ("%s", msg_string(MSG_dotar));
-       run_prog (0, 1, "pax -X -r -w -pe / /mnt");
+       if (run_prog (0, 1, "pax -X -r -w -pe / /mnt") != 0)
+               return 1;
 
        /* Copy next-stage install profile into target /.profile. */
-       cp_to_target ("/tmp/.hdprofile", "/.profile");
-       cp_to_target ("/usr/share/misc/termcap", "/.termcap");
+       if (cp_to_target ("/tmp/.hdprofile", "/.profile")!= 0)
+               return 1;
+       return cp_to_target ("/usr/share/misc/termcap", "/.termcap");
 }
 
 
diff -r 864706f22a86 -r 40f3e1745874 distrib/utils/sysinst/arch/bebox/msg.md.eng
--- a/distrib/utils/sysinst/arch/bebox/msg.md.eng       Fri Apr 09 10:06:18 1999 +0000
+++ b/distrib/utils/sysinst/arch/bebox/msg.md.eng       Fri Apr 09 10:24:38 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.md.eng,v 1.1 1998/11/19 08:58:07 sakamoto Exp $    */
+/*     $NetBSD: msg.md.eng,v 1.2 1999/04/09 10:24:40 bouyer Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -209,3 +209,6 @@
 ends beyond the 1024 BIOS cylinder boundary. To be sure that the system
 can be booted at all times, the entire root partition must lie below that
 limit. You can either: }
+
+message wmbrfail
+{Rewrite of MBR failed. I can't continue.}
diff -r 864706f22a86 -r 40f3e1745874 distrib/utils/sysinst/arch/i386/md.c
--- a/distrib/utils/sysinst/arch/i386/md.c      Fri Apr 09 10:06:18 1999 +0000
+++ b/distrib/utils/sysinst/arch/i386/md.c      Fri Apr 09 10:24:38 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.21 1999/03/31 00:44:49 fvdl Exp $ */
+/*     $NetBSD: md.c,v 1.22 1999/04/09 10:24:40 bouyer Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -119,48 +119,64 @@
        return (cc + MBR_MAGICOFF);
 }
 
-void
+int
 md_pre_disklabel()
 {
-       printf("%s", msg_string (MSG_dofdisk));
+       msg_display(MSG_dofdisk);
 
        /* write edited MBR onto disk. */
-       write_mbr(diskdev, mbr, sizeof mbr);
+       if (write_mbr(diskdev, mbr, sizeof mbr) != 0) {
+               msg_display(MSG_wmbrfail);
+               process_menu(MENU_ok);
+               return 1;
+       }
+       return 0;
 }
 
-void
+int
 md_post_disklabel(void)
 {
        /* Sector forwarding / badblocks ... */
        if (*doessf) {
-               printf("%s", msg_string(MSG_dobad144));
-               run_prog(0, 1, "/usr/sbin/bad144 %s 0", diskdev);
+               msg_display(MSG_dobad144);
+               return run_prog(0, 1, NULL, "/usr/sbin/bad144 %s 0", diskdev);
        }
+       return 0;
 }
 
-void
+int
 md_post_newfs(void)
 {
        /* boot blocks ... */
-       printf(msg_string(MSG_dobootblks), diskdev);
-       run_prog(0, 1, "/usr/mdec/installboot -v /usr/mdec/biosboot.sym "
+       msg_display(MSG_dobootblks, diskdev);
+       run_prog(0, 1, NULL, "/usr/mdec/installboot -v /usr/mdec/biosboot.sym "
                  "/dev/r%sa", diskdev);
+       /* Failing to install boot block is not a fatal error ... */
+       return 0;
 }
 
-void
+int
 md_copy_filesystem(void)
 {
        if (target_already_root()) {
-               return;
+               return 0;
        }
 
        /* Copy the instbin(s) to the disk */
-       printf("%s", msg_string(MSG_dotar));
-       run_prog(0, 0, "pax -X -r -w -pe / /mnt");
+       msg_display(MSG_dotar);
+       if (run_prog(0, 0, NULL, "pax -X -r -w -pe / /mnt") != 0)
+               goto err;
 
        /* Copy next-stage install profile into target /.profile. */
-       cp_to_target("/tmp/.hdprofile", "/.profile");
-       cp_to_target("/usr/share/misc/termcap", "/.termcap");
+       if (cp_to_target("/tmp/.hdprofile", "/.profile") != 0)
+               goto err;
+       if (cp_to_target("/usr/share/misc/termcap", "/.termcap") != 0)
+               goto err;
+       return 0;
+err:
+       msg_display(MSG_dotarfail);
+       process_menu(MENU_ok);
+       return 1;
 }



Home | Main Index | Thread Index | Old Index