Source-Changes-D archive

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

UFS2 root support on sysinst (Re: CVS commit: src/distrib/alpha/instkernel/ramdisk)



I wrote on source-changes-d@:

> dholland-sourcechanges%netbsd.org@localhost wrote:
> 
> > On Sat, Apr 04, 2009 at 11:24:07PM +0000, Izumi Tsutsui wrote:
> >  > Log Message:
> >  > Also put bootxx_ffsv2 into installation ramdisk.
 :
> For bootxx_ffsv2, I'll move md_bootxx_name() and related stuff
> from md.c to MI disks.c or bsddisklabel.c with some MD macros.

The attached is a dumb patch to handle UFS2 root in sysinst:
- reject UFS2 for rootfs on ports !HAVE_UFS2_BOOT
- add a MI function to get bootxx name from root file system type
  and remove md_bootxx_name() from arch/i386/md.c
  (so that alpha can use bootxx_ffsv2 for UFS2 as well as x86)

Tested on i386 and alpha with FFSv1 and FFSv2, and also
tested on vax without HAVE_UFS2_BOOT (and it rejects UFS2 root).

Concerns:
- not sure which ports actually support UFS2 boot
  (some ports don't read a kernel from root)
- no translations for a new message
- conditional messages should be .ifdef'ed out?

Comments?

---
Index: bsddisklabel.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/bsddisklabel.c,v
retrieving revision 1.50
diff -u -r1.50 bsddisklabel.c
--- bsddisklabel.c      5 Apr 2009 00:50:51 -0000       1.50
+++ bsddisklabel.c      5 Apr 2009 05:02:10 -0000
@@ -56,6 +56,8 @@
 #include "msg_defs.h"
 #include "menu_defs.h"
 
+static int check_partitions(void);
+
 /* For the current state of this file blame abs%NetBSD.org@localhost */
 /* Even though he wasn't the last to hack it, but he did admit doing so :-) */
 
@@ -704,7 +706,7 @@
                msg_display(MSG_abort);
                return 0;
        }
-       if (md_check_partitions() == 0)
+       if (check_partitions() == 0)
                goto edit_check;
 
        /* Disk name */
@@ -716,3 +718,41 @@
        /* Everything looks OK. */
        return (1);
 }
+
+/*
+ * check that there is at least a / somewhere.
+ */
+static int
+check_partitions(void)
+{
+#ifdef HAVE_BOOTXX_xFS
+       int rv;
+       char *bootxx;
+#endif
+#ifndef HAVE_UFS2_BOOT
+       int fstype;
+#endif
+
+#ifdef HAVE_BOOTXX_xFS
+       /* check if we have boot code for the root partition type */
+       bootxx = bootxx_name();
+       if (bootxx != NULL) {
+               rv = access(bootxx, R_OK);
+               free(bootxx);
+       }
+       if (bootxx == NULL || rv != 0) {
+               process_menu(MENU_ok, deconst(MSG_No_Bootcode));
+               return 0;
+       }
+#endif
+#ifndef HAVE_UFS2_BOOT
+       fstype = bsdlabel[rootpart].pi_fstype;
+       if (fstype == FS_BSDFFS &&
+           (bsdlabel[rootpart].pi_flags & PIF_FFSv2) != 0) {
+               process_menu(MENU_ok, deconst(MSG_cannot_ufs2_root));
+               return 0;
+       }
+#endif
+
+       return md_check_partitions();
+}
Index: defs.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/defs.h,v
retrieving revision 1.141
diff -u -r1.141 defs.h
--- defs.h      5 Apr 2009 02:18:41 -0000       1.141
+++ defs.h      5 Apr 2009 05:02:10 -0000
@@ -339,6 +339,7 @@
 int    mount_disks(void);
 int    set_swap(const char *, partinfo *);
 int    check_swap(const char *, int);
+char   *bootxx_name(void);
 
 /* from disks_lfs.c */
 int    fs_is_lfs(void *);
Index: disks.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/disks.c,v
retrieving revision 1.103
diff -u -r1.103 disks.c
--- disks.c     23 Feb 2009 23:12:24 -0000      1.103
+++ disks.c     5 Apr 2009 05:02:10 -0000
@@ -823,3 +823,49 @@
        rval = -1;
        goto done;
 }
+
+#ifdef HAVE_BOOTXX_xFS
+char *
+bootxx_name(void)
+{
+       int fstype;
+       const char *bootxxname;
+       char *bootxx;
+
+       /* check we have boot code for the root partition type */
+       fstype = bsdlabel[rootpart].pi_fstype;
+       switch (fstype) {
+#if defined(BOOTXX_FFSV1) || defined(BOOTXX_FFSV2)
+       case FS_BSDFFS:
+               if (bsdlabel[rootpart].pi_flags & PIF_FFSv2) {
+#ifdef BOOTXX_FFSV2
+                       bootxxname = BOOTXX_FFSV2;
+#else
+                       bootxxname = NULL;
+#endif
+               } else {
+#ifdef BOOTXX_FFSV1
+                       bootxxname = BOOTXX_FFSV1;
+#else
+                       bootxxname = NULL;
+#endif
+               }
+               break;
+#endif
+#ifdef BOOTXX_LFS
+       case FS_BSDLFS:
+               bootxxname = BOOTXX_LFS;
+               break;
+#endif
+       default:
+               bootxxname = NULL;
+               break;
+       }
+
+       if (bootxxname == NULL)
+               return NULL;
+
+       asprintf(&bootxx, "%s/%s", BOOTXXDIR, bootxxname);
+       return bootxx;
+}
+#endif
Index: msg.mi.de
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.de,v
retrieving revision 1.47
diff -u -r1.47 msg.mi.de
--- msg.mi.de   28 Jan 2009 16:31:49 -0000      1.47
+++ msg.mi.de   5 Apr 2009 05:02:10 -0000
@@ -845,6 +845,13 @@
 message partitions_overlap
 {Die Partitionen %c und %c ^[,A|berlappen sich.}
 
+message No_Bootcode
+{Kein Bootcode f^[,A|r die Rootpartition vorhanden}
+
+message cannot_ufs2_root
+{Sorry, the root file system can't be FFSv2 due to lack of bootloader support
+on this port.}
+
 message edit_partitions_again
 {
 
Index: msg.mi.en
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.en,v
retrieving revision 1.152
diff -u -r1.152 msg.mi.en
--- msg.mi.en   21 Dec 2008 11:02:42 -0000      1.152
+++ msg.mi.en   5 Apr 2009 05:02:10 -0000
@@ -787,6 +787,13 @@
 message partitions_overlap
 {partitions %c and %c overlap.}
 
+message No_Bootcode
+{No bootcode for root partition}
+
+message cannot_ufs2_root
+{Sorry, the root file system can't be FFSv2 due to lack of bootloader support
+on this port.}
+
 message edit_partitions_again
 {
 
Index: msg.mi.es
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.es,v
retrieving revision 1.24
diff -u -r1.24 msg.mi.es
--- msg.mi.es   28 Jan 2009 16:31:49 -0000      1.24
+++ msg.mi.es   5 Apr 2009 05:02:10 -0000
@@ -812,6 +812,13 @@
 message partitions_overlap
 {las particiones %c y %c se solapan.}
 
+message No_Bootcode
+{No hay c^[,Asdigo de arranque para la partici^[,Asn root}
+
+message cannot_ufs2_root
+{Sorry, the root file system can't be FFSv2 due to lack of bootloader support
+on this port.}
+
 message edit_partitions_again
 {
 
Index: msg.mi.fr
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.fr,v
retrieving revision 1.104
diff -u -r1.104 msg.mi.fr
--- msg.mi.fr   28 Jan 2009 16:31:49 -0000      1.104
+++ msg.mi.fr   5 Apr 2009 05:02:11 -0000
@@ -865,6 +865,13 @@
 message partitions_overlap
 {Les partitions %c et %c se recouvrent.}
 
+message No_Bootcode
+{Pas de programme de d^[,Aimarrage pour la partition racine}
+
+message cannot_ufs2_root
+{Sorry, the root file system can't be FFSv2 due to lack of bootloader support
+on this port.}
+
 message edit_partitions_again
 {
 Vous pouvez ^[,Aiditer la table de partitions ^[,A` la main, ou abandonner et
Index: msg.mi.pl
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/msg.mi.pl,v
retrieving revision 1.63
diff -u -r1.63 msg.mi.pl
--- msg.mi.pl   28 Jan 2009 16:31:49 -0000      1.63
+++ msg.mi.pl   5 Apr 2009 05:02:11 -0000
@@ -785,6 +785,13 @@
 message partitions_overlap
 {partycje %c i %c pokrycia.}
 
+message No_Bootcode
+{No bootcode for root partition}
+
+message cannot_ufs2_root
+{Sorry, the root file system can't be FFSv2 due to lack of bootloader support
+on this port.}
+
 message edit_partitions_again
 {
 
Index: arch/acorn32/md.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/acorn32/md.h,v
retrieving revision 1.18
diff -u -r1.18 md.h
--- arch/acorn32/md.h   4 Feb 2008 08:42:41 -0000       1.18
+++ arch/acorn32/md.h   5 Apr 2009 05:02:11 -0000
@@ -48,6 +48,9 @@
 #define        PART_USR        PART_E
 #define        PART_FIRST_FREE PART_F
 
+/* have support for booting from UFS2 */
+#define        HAVE_UFS2_BOOT
+
 /*
  *  Default filesets to fetch and install during installation
  *  or upgrade. The standard sets are:
Index: arch/alpha/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/alpha/md.c,v
retrieving revision 1.45
diff -u -r1.45 md.c
--- arch/alpha/md.c     7 Oct 2008 09:58:14 -0000       1.45
+++ arch/alpha/md.c     5 Apr 2009 05:02:11 -0000
@@ -126,12 +126,13 @@
 int
 md_post_newfs(void)
 {
+       char *bootxx;
 
        printf (msg_string(MSG_dobootblks), diskdev);
        cp_to_target("/usr/mdec/boot", "/boot");
-       if (run_program(RUN_DISPLAY | RUN_NO_CLEAR,
-           "/usr/sbin/installboot /dev/r%sc /usr/mdec/bootxx_ffs",
-           diskdev))
+       bootxx = bootxx_name();
+       if (bootxx == NULL || run_program(RUN_DISPLAY | RUN_NO_CLEAR,
+           "/usr/sbin/installboot /dev/r%sc %s", diskdev, bootxx))
                process_menu(MENU_ok,
                         deconst("Warning: disk is probably not bootable"));
 
Index: arch/alpha/md.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/alpha/md.h,v
retrieving revision 1.21
diff -u -r1.21 md.h
--- arch/alpha/md.h     26 Feb 2006 10:25:52 -0000      1.21
+++ arch/alpha/md.h     5 Apr 2009 05:02:11 -0000
@@ -52,6 +52,15 @@
 #define XNEEDMB 50     /* XXXTHORPEJ */
 #define DEFROOTSIZE    128
 
+/* have support for booting from UFS2 */
+#define        HAVE_UFS2_BOOT
+
+/* have file system specific primary boot loader */
+#define        HAVE_BOOTXX_xFS
+#define        BOOTXXDIR       "/usr/mdec"
+#define        BOOTXX_FFSV1    "bootxx_ffs"
+#define        BOOTXX_FFSV2    "bootxx_ffsv2"
+
 /*
  * Default filesets to fetch and install during installation
  * or upgrade.
Index: arch/amd64/md.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/amd64/md.h,v
retrieving revision 1.24
diff -u -r1.24 md.h
--- arch/amd64/md.h     5 Apr 2009 00:50:52 -0000       1.24
+++ arch/amd64/md.h     5 Apr 2009 05:02:11 -0000
@@ -53,12 +53,20 @@
 #define        DEFUSRSIZE      0
 #define        DEFSWAPSIZE     (-1)
 
+/* Megs required for a full X installation. */
+#define XNEEDMB 50
+
 /* use UFS2 by default for ffs */
 #define        DEFAULT_UFS2
+
+/* have support for booting form UFS2 */
 #define        HAVE_UFS2_BOOT
 
-/* Megs required for a full X installation. */
-#define XNEEDMB 50
+/* have file system specific primary boot loader */
+#define        HAVE_BOOTXX_xFS
+#define        BOOTXXDIR       "/usr/mdec"
+#define        BOOTXX_FFSV1    "bootxx_ffsv1"
+#define        BOOTXX_FFSV2    "bootxx_ffsv2"
 
 
 /*
Index: arch/arc/md.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/arc/md.h,v
retrieving revision 1.14
diff -u -r1.14 md.h
--- arch/arc/md.h       2 Feb 2008 04:20:02 -0000       1.14
+++ arch/arc/md.h       5 Apr 2009 05:02:11 -0000
@@ -75,6 +75,9 @@
 /* Megs required for a full X installation. */
 #define XNEEDMB 100
 
+/* have support for booting from UFS2 */
+#define        HAVE_UFS2_BOOT
+
 
 /*
  *  Default filesets to fetch and install during installation
Index: arch/cobalt/md.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/cobalt/md.h,v
retrieving revision 1.1
diff -u -r1.1 md.h
--- arch/cobalt/md.h    2 Feb 2008 09:14:32 -0000       1.1
+++ arch/cobalt/md.h    5 Apr 2009 05:02:11 -0000
@@ -75,6 +75,9 @@
 /* Megs required for a full X installation. */
 #define XNEEDMB 100
 
+/* have support for booting from UFS2 */
+#define        HAVE_UFS2_BOOT
+
 
 /*
  *  Default filesets to fetch and install during installation
Index: arch/i386/md.c
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/i386/md.c,v
retrieving revision 1.120
diff -u -r1.120 md.c
--- arch/i386/md.c      4 Apr 2009 11:03:24 -0000       1.120
+++ arch/i386/md.c      5 Apr 2009 05:02:11 -0000
@@ -68,7 +68,6 @@
 static void md_upgrade_mbrtype(void);
 static int md_read_bootcode(const char *, struct mbr_sector *);
 static unsigned int get_bootmodel(void);
-static char *md_bootxx_name(void);
 
 
 int
@@ -342,7 +341,7 @@
 
        snprintf(bootxx, sizeof bootxx, "/dev/r%s%c", diskdev, 'a' + rootpart);
        td = open(bootxx, O_RDWR, 0);
-       bootxx_filename = md_bootxx_name();
+       bootxx_filename = bootxx_name();
        if (bootxx_filename != NULL) {
                sd = open(bootxx_filename, O_RDONLY);
                free(bootxx_filename);
@@ -406,7 +405,7 @@
        char *bootxx;
 
        /* check we have boot code for the root partition type */
-       bootxx = md_bootxx_name();
+       bootxx = bootxx_name();
        rval = access(bootxx, R_OK);
        free(bootxx);
        if (rval == 0)
@@ -614,32 +613,6 @@
        set_kernel_set(get_bootmodel());
 }
 
-static char *
-md_bootxx_name(void)
-{
-       int fstype;
-       const char *bootfs = 0;
-       char *bootxx;
-
-       /* check we have boot code for the root partition type */
-       fstype = bsdlabel[rootpart].pi_fstype;
-       if (fstype == FS_BSDFFS)
-               if (bsdlabel[rootpart].pi_flags & PIF_FFSv2)
-                       bootfs = "ffsv2";
-               else
-                       bootfs = "ffsv1";
-       else if (fstype == FS_BSDLFS)
-                       bootfs = "lfsv2";
-       else
-               bootfs = mountnames[fstype];
-
-       if (bootfs == NULL)
-               return NULL;
-
-       asprintf(&bootxx, "/usr/mdec/bootxx_%s", bootfs);
-       return bootxx;
-}
-
 int
 md_post_extract(void)
 {
Index: arch/i386/md.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/i386/md.h,v
retrieving revision 1.65
diff -u -r1.65 md.h
--- arch/i386/md.h      5 Apr 2009 00:50:52 -0000       1.65
+++ arch/i386/md.h      5 Apr 2009 05:02:11 -0000
@@ -54,12 +54,20 @@
 #define        DEFSWAPSIZE     (-1)
 #define        DEFROOTSIZE     32
 
+/* Megs required for a full X installation. */
+#define XNEEDMB 50
+
 /* use UFS2 by default for ffs */
 #define        DEFAULT_UFS2
+
+/* have support for booting from UFS2 */
 #define        HAVE_UFS2_BOOT
 
-/* Megs required for a full X installation. */
-#define XNEEDMB 50
+/* have file system specific primary boot loader */
+#define        HAVE_BOOTXX_xFS
+#define        BOOTXXDIR       "/usr/mdec"
+#define        BOOTXX_FFSV1    "bootxx_ffsv1"
+#define        BOOTXX_FFSV2    "bootxx_ffsv2"
 
 /*
  *  Default filesets to fetch and install during installation
Index: arch/i386/msg.md.de
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/i386/msg.md.de,v
retrieving revision 1.15
diff -u -r1.15 msg.md.de
--- arch/i386/msg.md.de 30 Apr 2008 15:29:11 -0000      1.15
+++ arch/i386/msg.md.de 5 Apr 2009 05:02:11 -0000
@@ -74,8 +74,6 @@
 message serial_baud_rate       {Serielle baud Rate}
 message Use_existing_bootblocks        {Vorhandene Bootbl^[,Avcke benutzen}
 
-message No_Bootcode            {Kein Bootcode f^[,A|r die Rootpartition 
vorhanden}
-
 message dobootblks
 {Installiere die Bootbl^[,Avcke auf %s ...
 }
Index: arch/i386/msg.md.en
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/i386/msg.md.en,v
retrieving revision 1.57
diff -u -r1.57 msg.md.en
--- arch/i386/msg.md.en 30 Apr 2008 15:29:11 -0000      1.57
+++ arch/i386/msg.md.en 5 Apr 2009 05:02:11 -0000
@@ -73,8 +73,6 @@
 message serial_baud_rate       {Set serial baud rate}
 message Use_existing_bootblocks        {Use existing bootblocks}
 
-message No_Bootcode            {No bootcode for root partition}
-
 message dobootblks
 {Installing boot blocks on %s....
 }
Index: arch/i386/msg.md.es
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/i386/msg.md.es,v
retrieving revision 1.10
diff -u -r1.10 msg.md.es
--- arch/i386/msg.md.es 30 Apr 2008 15:29:11 -0000      1.10
+++ arch/i386/msg.md.es 5 Apr 2009 05:02:11 -0000
@@ -73,8 +73,6 @@
 message serial_baud_rate       {Baudios puerto serie}
 message Use_existing_bootblocks        {Usar bootblocks existente}
 
-message No_Bootcode            {No hay c^[,Asdigo de arranque para la 
partici^[,Asn root}
-
 message dobootblks
 {Instalando bloques de arranque en %s....
 }
Index: arch/i386/msg.md.fr
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/i386/msg.md.fr,v
retrieving revision 1.47
diff -u -r1.47 msg.md.fr
--- arch/i386/msg.md.fr 30 Apr 2008 15:29:11 -0000      1.47
+++ arch/i386/msg.md.fr 5 Apr 2009 05:02:11 -0000
@@ -69,8 +69,6 @@
 message serial_baud_rate       {Vitesse du port s^[,Airie}
 message Use_existing_bootblocks        {Conserver le programme de 
d^[,Aimarrage existant}
 
-message No_Bootcode            {Pas de programme de d^[,Aimarrage pour la 
partition racine}
-
 message dobootblks
 {Installation programme de d^[,Aimarrage sur %s ...
 }
Index: arch/i386/msg.md.pl
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/i386/msg.md.pl,v
retrieving revision 1.30
diff -u -r1.30 msg.md.pl
--- arch/i386/msg.md.pl 30 Apr 2008 15:29:11 -0000      1.30
+++ arch/i386/msg.md.pl 5 Apr 2009 05:02:11 -0000
@@ -71,8 +71,6 @@
 message serial_baud_rate       {Serial baud rate}
 message Use_existing_bootblocks        {Use existing bootblocks}
 
-message No_Bootcode            {No bootcode for root partition}
-
 message dobootblks
 {Instalowanie bootblokow na %s....
 }
Index: arch/macppc/md.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/macppc/md.h,v
retrieving revision 1.16
diff -u -r1.16 md.h
--- arch/macppc/md.h    26 Feb 2006 10:25:53 -0000      1.16
+++ arch/macppc/md.h    5 Apr 2009 05:02:11 -0000
@@ -51,6 +51,9 @@
 /* Megs required for a full X installation. */
 #define XNEEDMB 35     /* XXXTHORPEJ */
 
+/* have support for booting from UFS2 */
+#define        HAVE_UFS2_BOOT
+
 /*
  * Default filesets to fetch and install during installation
  * or upgrade.
Index: arch/sgimips/md.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/sgimips/md.h,v
retrieving revision 1.23
diff -u -r1.23 md.h
--- arch/sgimips/md.h   12 Nov 2007 15:07:36 -0000      1.23
+++ arch/sgimips/md.h   5 Apr 2009 05:02:11 -0000
@@ -58,6 +58,9 @@
 #define DEFUSRSIZE     120     /* Default /usr size, if /home */
 #define XNEEDMB                100     /* Extra megs for full X installation */
 
+/* have support for booting from UFS2 */
+#define        HAVE_UFS2_BOOT
+
 /*
  * Machine-specific command to write a new label to a disk.
  * If not defined, we assume the port does not support disklabels and
Index: arch/sparc/md.h
===================================================================
RCS file: /cvsroot/src/distrib/utils/sysinst/arch/sparc/md.h,v
retrieving revision 1.23
diff -u -r1.23 md.h
--- arch/sparc/md.h     11 Aug 2006 13:35:54 -0000      1.23
+++ arch/sparc/md.h     5 Apr 2009 05:02:11 -0000
@@ -56,6 +56,9 @@
 #define DEFUSRSIZE     100     /* Default /usr size, if /home */
 #define XNEEDMB                35      /* Extra megs for full X installation */
 
+/* have support for booting from UFS2 */
+#define        HAVE_UFS2_BOOT
+
 /*
  * Default filesets to fetch and install during installation
  * or upgrade.
---
Izumi Tsutsui


Home | Main Index | Thread Index | Old Index