Source-Changes-HG archive

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

[src/netbsd-1-4]: src/distrib/utils/sysinst/arch/sparc Pull up revisions 1.15...



details:   https://anonhg.NetBSD.org/src/rev/357446056d82
branches:  netbsd-1-4
changeset: 469975:357446056d82
user:      he <he%NetBSD.org@localhost>
date:      Sat Jan 08 16:27:53 2000 +0000

description:
Pull up revisions 1.15-1.17 (requested by abs):
  Add sanity to partition handling.  Symlink netbsd.GENERIC to netbsd
  (while kern.tgz still contains netbsd.GENERIC).  Makes sysinst work
  on the sparc.  Fixes PR#7741 and a few more problems.

diffstat:

 distrib/utils/sysinst/arch/sparc/md.c |  249 +++++++++++++++++++++------------
 1 files changed, 155 insertions(+), 94 deletions(-)

diffs (truncated from 460 to 300 lines):

diff -r 6955dcf992cc -r 357446056d82 distrib/utils/sysinst/arch/sparc/md.c
--- a/distrib/utils/sysinst/arch/sparc/md.c     Sat Jan 08 16:17:50 2000 +0000
+++ b/distrib/utils/sysinst/arch/sparc/md.c     Sat Jan 08 16:27:53 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.8.2.3 1999/06/24 22:56:33 cgd Exp $   */
+/*     $NetBSD: md.c,v 1.8.2.4 2000/01/08 16:27:53 he Exp $    */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -26,19 +26,20 @@
  * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
+ * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 /* changes from the i386 version made by mrg */
 
 /* md.c -- sparc machine specific routines */
+/* This file is in close sync with pmax, vax, and x68k md.c */
 
 #include <sys/types.h>
 #include <sys/disklabel.h>
@@ -58,28 +59,40 @@
 /*
  * Symbolic names for disk partitions.
  */
-#define        PART_ROOT       A
-#define        PART_RAW        C
-#define        PART_USR        G
+#define PART_ROOT      A
+#define PART_SWAP      B
+#define PART_RAW       C
+#define PART_USR       G       /* Can be after PART_FIRST_FREE */
+#define PART_FIRST_FREE        D
+#define PART_LAST      H
+
+#define DEFSWAPRAM     32      /* Assume at least this RAM for swap calc */
+#define DEFROOTSIZE    32      /* Default root size */
+#define STDNEEDMB      110     /* Min space for non X install */
 
 int
-md_get_info()
+md_get_info(void)
 {
        struct disklabel disklabel;
        int fd;
        char devname[100];
 
-       snprintf (devname, 100, "/dev/r%sc", diskdev);
+       snprintf(devname, 100, "/dev/r%sc", diskdev);
 
-       fd = open (devname, O_RDONLY, 0);
+       fd = open(devname, O_RDONLY, 0);
        if (fd < 0) {
+               if (logging)
+                       (void)fprintf(log, "Can't open %s\n", devname);
                endwin();
-               fprintf (stderr, "Can't open %s\n", devname);
+               fprintf(stderr, "Can't open %s\n", devname);
                exit(1);
        }
        if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
+               if (logging)
+                       (void)fprintf(log, "Can't read disklabel on %s.\n",
+                               devname);
                endwin();
-               fprintf (stderr, "Can't read disklabel on %s.\n", devname);
+               fprintf(stderr, "Can't read disklabel on %s.\n", devname);
                close(fd);
                exit(1);
        }
@@ -93,7 +106,7 @@
 
        /*
         * Compute whole disk size. Take max of (dlcyl*dlhead*dlsec)
-        * and secperunit,  just in case the disk is already labelled.  
+        * and secperunit,  just in case the disk is already labelled.
         * (If our new label's RAW_PART size ends up smaller than the
         * in-core RAW_PART size  value, updating the label will fail.)
         */
@@ -102,7 +115,7 @@
                dlsize = disklabel.d_secperunit;
 
        /* Compute minimum NetBSD partition sizes (in sectors). */
-       minfsdmb = (80 + 4*rammb) * (MEG / sectorsize);
+       minfsdmb = STDNEEDMB * (MEG / sectorsize);
 
        return 1;
 }
@@ -111,7 +124,7 @@
  * hook called before writing new disklabel.
  */
 int
-md_pre_disklabel()
+md_pre_disklabel(void)
 {
        return 0;
 }
@@ -119,7 +132,8 @@
 /*
  * hook called after writing disklabel to new target disk.
  */
-int    md_post_disklabel (void)
+int
+md_post_disklabel(void)
 {
        return 0;
 }
@@ -127,15 +141,23 @@
 /*
  * MD hook called after upgrade() or install() has finished setting
  * up the target disk but immediately before the user is given the
- * ``disks are now set up'' message that, if power fails, they can
+ * ``disks are now set up'' message, so that if power fails, they can
  * continue installation by booting the target disk and doing an
  * `upgrade'.
  *
  * On the sparc, we use this opportunity to install the boot blocks.
  */
 int
-md_post_newfs()
+md_post_newfs(void)
 {
+       /*
+        * Create a symlink of netbsd to netbsd.GENERIC
+        * XXX This is... less than ideal... but there is no md hook between
+        * get_and_unpack_sets() and sanity_check(), and we do not want to
+        * change kern.tgz until we replace the miniroot install
+        */
+       symlink("netbsd.GENERIC",target_expand("/netbsd"));
+
        /* boot blocks ... */
        msg_display(MSG_dobootblks, diskdev);
        return (run_prog(0, 1, NULL, "/sbin/disklabel -W %s", diskdev) ||
@@ -146,13 +168,16 @@
  * some ports use this to copy the MD filesystem, we do not.
  */
 int
-md_copy_filesystem()
+md_copy_filesystem(void)
 {
        return 0;
 }
 
+/*
+ * md back-end code for menu-driven BSD disklabel editor.
+ */
 int
-md_make_bsd_partitions()
+md_make_bsd_partitions(void)
 {
        int i, part;
        int remain;
@@ -160,7 +185,7 @@
        int maxpart = getmaxpartitions();
 
        /*
-        * Initialize global variables that track  space used on this disk.
+        * Initialize global variables that track space used on this disk.
         * Standard 4.3BSD 8-partition labels always cover whole disk.
         */
        ptsize = dlsize - ptstart;
@@ -169,11 +194,11 @@
        fsdmb = fsdsize / MEG;
 
        /* Ask for layout type -- standard or special */
-       msg_display (MSG_layout,
-                       (1.0*fsptsize*sectorsize)/MEG,
-                       (1.0*minfsdmb*sectorsize)/MEG,
-                       (1.0*minfsdmb*sectorsize)/MEG+rammb+XNEEDMB);
-       process_menu (MENU_layout);
+       msg_display(MSG_layout,
+                   (1.0*fsptsize*sectorsize)/MEG,
+                   (1.0*minfsdmb*sectorsize)/MEG,
+                   (1.0*minfsdmb*sectorsize)/MEG+rammb+XNEEDMB);
+       process_menu(MENU_layout);
 
        if (layoutkind == 3) {
                ask_sizemult();
@@ -186,21 +211,20 @@
        /* Build standard partitions */
        emptylabel(bsdlabel);
 
-       /* Partitions C is predefined (whole  disk). */
+       /* Partitions C is predefined (whole disk). */
        bsdlabel[C].pi_fstype = FS_UNUSED;
        bsdlabel[C].pi_offset = 0;
        bsdlabel[C].pi_size = dlsize;
-       
+
        /* Standard fstypes */
        bsdlabel[A].pi_fstype = FS_BSDFFS;
-       bsdlabel[B].pi_fstype = FS_SWAP;
+       bsdlabel[B].pi_fstype = FS_UNUSED;
        /* Conventionally, C is whole disk. */
        bsdlabel[D].pi_fstype = FS_UNUSED;      /* fill out below */
        bsdlabel[E].pi_fstype = FS_UNUSED;
        bsdlabel[F].pi_fstype = FS_UNUSED;
        bsdlabel[G].pi_fstype = FS_UNUSED;
        bsdlabel[H].pi_fstype = FS_UNUSED;
-       part = D;
 
 
        switch (layoutkind) {
@@ -209,22 +233,23 @@
                partstart = ptstart;
 
                /* Root */
-               /* By convention, NetBSD/sparc uses a 328Mbyte root */
-               partsize= NUMSEC(32, MEG/sectorsize, dlcylsize);
-               bsdlabel[A].pi_offset = partstart;
-               bsdlabel[A].pi_size = partsize;
-               bsdlabel[A].pi_bsize = 8192;
-               bsdlabel[A].pi_fsize = 1024;
-               strcpy (fsmount[A], "/");
+               partsize = NUMSEC(DEFROOTSIZE, MEG/sectorsize, dlcylsize);
+               bsdlabel[PART_ROOT].pi_offset = partstart;
+               bsdlabel[PART_ROOT].pi_size = partsize;
+               bsdlabel[PART_ROOT].pi_bsize = 8192;
+               bsdlabel[PART_ROOT].pi_fsize = 1024;
+               strcpy(fsmount[PART_ROOT], "/");
                partstart += partsize;
 
                /* swap */
-               i = NUMSEC(layoutkind * 2 * (rammb < 32 ? 32 : rammb),
+               i = NUMSEC(layoutkind * 2 *
+                          (rammb < DEFSWAPRAM ? DEFSWAPRAM : rammb),
                           MEG/sectorsize, dlcylsize) + partstart;
-               partsize = NUMSEC (i/(MEG/sectorsize)+1, MEG/sectorsize,
+               partsize = NUMSEC(i/(MEG/sectorsize)+1, MEG/sectorsize,
                           dlcylsize) - partstart;
-               bsdlabel[B].pi_offset = partstart;
-               bsdlabel[B].pi_size = partsize;
+               bsdlabel[PART_SWAP].pi_fstype = FS_SWAP;
+               bsdlabel[PART_SWAP].pi_offset = partstart;
+               bsdlabel[PART_SWAP].pi_size = partsize;
                partstart += partsize;
 
                /* /usr */
@@ -234,7 +259,7 @@
                bsdlabel[PART_USR].pi_size = partsize;
                bsdlabel[PART_USR].pi_bsize = 8192;
                bsdlabel[PART_USR].pi_fsize = 1024;
-               strcpy (fsmount[PART_USR], "/usr");
+               strcpy(fsmount[PART_USR], "/usr");
 
                break;
 
@@ -243,62 +268,83 @@
                /* root */
                partstart = ptstart;
                remain = fsdsize - partstart;
-               /* By convention, NetBSD/sparc uses a 32Mbyte root */
-               partsize = NUMSEC (32, MEG/sectorsize, dlcylsize);
-               snprintf (isize, 20, "%d", partsize/sizemult);
-               msg_prompt (MSG_askfsroot, isize, isize, 20,
+               partsize = NUMSEC(DEFROOTSIZE, MEG/sectorsize, dlcylsize);
+               snprintf(isize, 20, "%d", partsize/sizemult);
+               msg_prompt(MSG_askfsroot, isize, isize, 20,
                            remain/sizemult, multname);
                partsize = NUMSEC(atoi(isize),sizemult, dlcylsize);
-               bsdlabel[A].pi_offset = partstart;
-               bsdlabel[A].pi_size = partsize;
-               bsdlabel[A].pi_bsize = 8192;
-               bsdlabel[A].pi_fsize = 1024;
-               strcpy (fsmount[A], "/");
+               /* If less than a 'unit' left, also use it */
+               if (remain - partsize < sizemult)
+                       partsize = remain;
+               bsdlabel[PART_ROOT].pi_offset = partstart;
+               bsdlabel[PART_ROOT].pi_size = partsize;
+               bsdlabel[PART_ROOT].pi_bsize = 8192;
+               bsdlabel[PART_ROOT].pi_fsize = 1024;
+               strcpy(fsmount[PART_ROOT], "/");
                partstart += partsize;
-               
+
                /* swap */
                remain = fsdsize - partstart;
-               i = NUMSEC(2 * (rammb < 32 ? 32 : rammb),
-                          MEG/sectorsize, dlcylsize) + partstart;
-               partsize = NUMSEC (i/(MEG/sectorsize)+1, MEG/sectorsize,
-                          dlcylsize) - partstart;
-               snprintf (isize, 20, "%d", partsize/sizemult);
-               msg_prompt_add (MSG_askfsswap, isize, isize, 20,
-                           remain/sizemult, multname);
-               partsize = NUMSEC(atoi(isize),sizemult, dlcylsize);
-               bsdlabel[B].pi_offset = partstart;



Home | Main Index | Thread Index | Old Index