Source-Changes-HG archive

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

[src/netbsd-8]: src/usr.sbin/sysinst Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/544b9e011d29
branches:  netbsd-8
changeset: 435008:544b9e011d29
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Tue Jun 05 08:12:54 2018 +0000

description:
Pull up following revision(s) (requested by martin in ticket #860):
        usr.sbin/sysinst/msg.mi.de: revision 1.7
        usr.sbin/sysinst/arch/i386/md.c: revision 1.10
        usr.sbin/sysinst/msg.mi.fr: revision 1.10
        usr.sbin/sysinst/arch/i386/md.c: revision 1.11
        usr.sbin/sysinst/menus.mi: revision 1.13
        usr.sbin/sysinst/arch/i386/md.c: revision 1.9
        usr.sbin/sysinst/msg.mi.es: revision 1.7
        usr.sbin/sysinst/msg.mi.en: revision 1.11
        usr.sbin/sysinst/mbr.c: revision 1.6
        usr.sbin/sysinst/disks.c: revision 1.15
        usr.sbin/sysinst/bsddisklabel.c: revision 1.4
        usr.sbin/sysinst/disks.c: revision 1.16
        usr.sbin/sysinst/msg.mi.pl: revision 1.9
        usr.sbin/sysinst/defs.h: revision 1.11
Add an option to install onto a pre-configured wedge.
Greatly simmplifies (U)EFI setups (but does not fully automate them yet).
In the generated /etc/fstab, do not use the (temporary, during sysinst)
path name for the file in the comment, but instead the one it will
have on the target system.
Reorder fetch options: http before ftp
Default console device and speed to that used by syinst
add missing brace.

diffstat:

 usr.sbin/sysinst/arch/i386/md.c |   36 +++-
 usr.sbin/sysinst/bsddisklabel.c |    5 +-
 usr.sbin/sysinst/defs.h         |    3 +-
 usr.sbin/sysinst/disks.c        |  288 ++++++++++++++++++++++++++++++++++-----
 usr.sbin/sysinst/mbr.c          |    7 +-
 usr.sbin/sysinst/menus.mi       |    4 +-
 usr.sbin/sysinst/msg.mi.de      |   13 +-
 usr.sbin/sysinst/msg.mi.en      |   10 +-
 usr.sbin/sysinst/msg.mi.es      |   12 +-
 usr.sbin/sysinst/msg.mi.fr      |   12 +-
 usr.sbin/sysinst/msg.mi.pl      |   12 +-
 11 files changed, 339 insertions(+), 63 deletions(-)

diffs (truncated from 708 to 300 lines):

diff -r d058e17deab0 -r 544b9e011d29 usr.sbin/sysinst/arch/i386/md.c
--- a/usr.sbin/sysinst/arch/i386/md.c   Tue Jun 05 08:04:34 2018 +0000
+++ b/usr.sbin/sysinst/arch/i386/md.c   Tue Jun 05 08:12:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.6.8.1 2018/04/12 13:54:11 martin Exp $ */
+/*     $NetBSD: md.c,v 1.6.8.2 2018/06/05 08:12:54 bouyer Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -322,7 +322,7 @@
         * Too hard to double check, so just 'know' the device numbers.
         */
        len = sizeof condev;
-       if (sysctl(conmib, nelem(conmib), &condev, &len, NULL, 0) != -1
+       if (sysctl(conmib, __arraycount(conmib), &condev, &len, NULL, 0) != -1
            && (condev & ~3) == 0x800) {
                /* Motherboard serial port */
                boottype.bp_consdev = (condev & 3) + 1;
@@ -331,18 +331,36 @@
                        boottype.bp_conspeed = t.c_ispeed;
        }
 
-       process_menu(MENU_getboottype, &boottype);
-       msg_display(MSG_dobootblks, pm->diskdev);
-       if (boottype.bp_consdev == ~0u)
-               /* Use existing bootblocks */
-               return 0;
+       if (pm == NULL || !pm->no_part) {
+               /*
+                * Get console device, should either be ttyE0 or tty0n.
+                * Too hard to double check, so just 'know' the device numbers.
+                */
+               len = sizeof condev;
+               if (sysctl(conmib, nelem(conmib), &condev, &len, NULL, 0) != -1
+                   && (condev & ~3) == 0x800) {
+                       /* Motherboard serial port */
+                       boottype.bp_consdev = (condev & 3) + 1;
+                       /* Defaulting the baud rate to that of stdin should suffice */
+                       if (tcgetattr(0, &t) != -1)
+                               boottype.bp_conspeed = t.c_ispeed;
+               }
+
+               process_menu(MENU_getboottype, &boottype);
+               msg_display(MSG_dobootblks, pm->diskdev);
+               if (boottype.bp_consdev == ~0u)
+                       /* Use existing bootblocks */
+                       return 0;
+       }
 
        ret = cp_to_target("/usr/mdec/boot", "/boot");
        if (ret)
                return ret;
+       if (pm && pm->no_part)
+               return 0;
 
-        bootxx_filename = bootxx_name();                                                 
-        if (bootxx_filename != NULL) {                                                   
+        bootxx_filename = bootxx_name();
+        if (bootxx_filename != NULL) {
                snprintf(boot_options, sizeof boot_options,
                    "console=%s,speed=%u", consoles[boottype.bp_consdev],
                    boottype.bp_conspeed);
diff -r d058e17deab0 -r 544b9e011d29 usr.sbin/sysinst/bsddisklabel.c
--- a/usr.sbin/sysinst/bsddisklabel.c   Tue Jun 05 08:04:34 2018 +0000
+++ b/usr.sbin/sysinst/bsddisklabel.c   Tue Jun 05 08:12:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bsddisklabel.c,v 1.2 2014/08/03 16:09:38 martin Exp $  */
+/*     $NetBSD: bsddisklabel.c,v 1.2.20.1 2018/06/05 08:12:54 bouyer Exp $     */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -566,6 +566,9 @@
        int no_swap = 0, valid_part = -1;
        partinfo *p, savedlabel[MAXPARTITIONS];
 
+       if (pm && pm->no_part)
+               return 1;
+
        memcpy(&savedlabel, &pm->bsdlabel, sizeof savedlabel);
 
        /*
diff -r d058e17deab0 -r 544b9e011d29 usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h   Tue Jun 05 08:04:34 2018 +0000
+++ b/usr.sbin/sysinst/defs.h   Tue Jun 05 08:12:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.9 2015/05/11 13:07:57 martin Exp $  */
+/*     $NetBSD: defs.h,v 1.9.8.1 2018/06/05 08:12:54 bouyer Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -300,6 +300,7 @@
     partinfo bsdlabel[MAXPARTITIONS]; /* What we want it to look like */
     int gpt;
     int no_mbr; /* set for raid (etc) */
+    int no_part;       /* can not be partitioned, e.g. dk0 */
     int rootpart; /* partition we install into */
     const char *disktype; /* ST506, SCSI, ... */
     const char *doessf;
diff -r d058e17deab0 -r 544b9e011d29 usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c  Tue Jun 05 08:04:34 2018 +0000
+++ b/usr.sbin/sysinst/disks.c  Tue Jun 05 08:12:54 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disks.c,v 1.13.6.1 2018/05/07 04:03:20 snj Exp $ */
+/*     $NetBSD: disks.c,v 1.13.6.2 2018/06/05 08:12:54 bouyer Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -68,7 +68,7 @@
 struct disk_desc {
        char    dd_name[SSTRSIZE];
        char    dd_descr[70];
-       uint    dd_no_mbr;
+       bool    dd_no_mbr, dd_no_part;
        uint    dd_cyl;
        uint    dd_head;
        uint    dd_sec;
@@ -104,7 +104,7 @@
 #ifdef USE_SYSVBFS
 static int foundsysvbfs(struct data *, size_t);
 #endif
-static int fsck_preen(const char *, int, const char *);
+static int fsck_preen(const char *, int, const char *, bool silent);
 static void fixsb(const char *, const char *, char);
 static bool is_gpt(const char *);
 static int incoregpt(pm_devs_t *, partinfo *);
@@ -113,7 +113,8 @@
 #define DISK_NAMES "wd", "sd", "ld", "raid"
 #endif
 
-static const char *disk_names[] = { DISK_NAMES, "vnd", "cgd", NULL };
+static const char *disk_names[] = { DISK_NAMES,
+                                   "vnd", "cgd", "dk:no_part", NULL };
 
 static bool tmpfs_on_var_shm(void);
 
@@ -396,8 +397,118 @@
        return cdrom_devices[0];
 }
 
+static void
+get_wedge_descr(struct disk_desc *dd)
+{
+       struct dkwedge_info dkw;
+       char buf[MAXPATHLEN];
+       int fd;
+
+       fd = opendisk(dd->dd_name, O_RDONLY, buf, sizeof(buf), 0);
+       if (fd == -1)
+               return;
+
+       if (ioctl(fd, DIOCGWEDGEINFO, &dkw) == 0) {
+               fprintf(stderr, "device %s\n", dd->dd_name);
+               sprintf(dd->dd_descr, "%s (%s@%s)",
+                   dkw.dkw_wname, dkw.dkw_devname, dkw.dkw_parent);
+       }
+       close(fd);
+}
+
+static bool
+get_name_and_parent(const char *dev, char *name, char *parent)
+{
+       struct dkwedge_info dkw;
+       char buf[MAXPATHLEN];
+       int fd;
+       bool res = false;
+
+       fd = opendisk(dev, O_RDONLY, buf, sizeof(buf), 0);
+       if (fd == -1)
+               return false;
+
+       if (ioctl(fd, DIOCGWEDGEINFO, &dkw) == 0) {
+               strcpy(name, (const char *)dkw.dkw_wname);
+               strcpy(parent, dkw.dkw_parent);
+               res = true;
+       }
+       close(fd);
+       return res;
+}
+
+static bool
+find_swap_part_on(const char *dev, char *swap_name)
+{
+       struct dkwedge_info *dkw;
+       struct dkwedge_list dkwl;
+       char buf[MAXPATHLEN];
+       size_t bufsize;
+       int fd;
+       u_int i;
+       bool res = false;
+
+       dkw = NULL;
+       dkwl.dkwl_buf = dkw;
+       dkwl.dkwl_bufsize = 0;
+
+       fd = opendisk(dev, O_RDONLY, buf, sizeof(buf), 0);
+       if (fd == -1)
+               return false;
+
+       for (;;) {
+               if (ioctl(fd, DIOCLWEDGES, &dkwl) == -1) {
+                       dkwl.dkwl_ncopied = 0;
+                       break;
+               }
+               if (dkwl.dkwl_nwedges == dkwl.dkwl_ncopied)
+                       break;
+               bufsize = dkwl.dkwl_nwedges * sizeof(*dkw);
+               if (dkwl.dkwl_bufsize < bufsize) {
+                       dkw = realloc(dkwl.dkwl_buf, bufsize);
+                       if (dkw == NULL)
+                               break;
+                       dkwl.dkwl_buf = dkw;
+                       dkwl.dkwl_bufsize = bufsize;
+               }
+       }
+
+       for (i = 0; i < dkwl.dkwl_nwedges; i++) {
+               res = strcmp(dkw[i].dkw_ptype, DKW_PTYPE_SWAP) == 0;
+               if (res) {
+                       strcpy(swap_name, (const char*)dkw[i].dkw_wname);
+                       break;
+               }
+       }
+
+       close(fd);
+
+       return res;
+}
+
+static bool
+is_ffs_wedge(const char *dev)
+{
+       struct dkwedge_info dkw;
+       char buf[MAXPATHLEN];
+       int fd;
+       bool res;
+
+       fd = opendisk(dev, O_RDONLY, buf, sizeof(buf), 0);
+       if (fd == -1)
+               return false;
+
+       if (ioctl(fd, DIOCGWEDGEINFO, &dkw) == -1)
+               return false;
+
+       res = strcmp(dkw.dkw_ptype, DKW_PTYPE_FFS) == 0;
+       close(fd);
+
+       return res;
+}
+
 static int
-get_disks(struct disk_desc *dd)
+get_disks(struct disk_desc *dd, bool with_non_partitionable)
 {
        const char **xd;
        char *cp;
@@ -412,18 +523,33 @@
                for (i = 0; i < MAX_DISKS; i++) {
                        strlcpy(dd->dd_name, *xd, sizeof dd->dd_name - 2);
                        cp = strchr(dd->dd_name, ':');
-                       if (cp != NULL)
+                       if (cp != NULL) {
                                dd->dd_no_mbr = !strcmp(cp, ":no_mbr");
-                       else {
-                               dd->dd_no_mbr = 0;
+                               dd->dd_no_part = !strcmp(cp, ":no_part");
+                       } else {
+                               dd->dd_no_mbr = false;
+                               dd->dd_no_part = false;
                                cp = strchr(dd->dd_name, 0);
                        }
+                       if (dd->dd_no_part && !with_non_partitionable)
+                               continue;
 
                        snprintf(cp, 2 + 1, "%d", i);
                        if (!get_geom(dd->dd_name, &l)) {
                                if (errno == ENOENT)
                                        break;
-                               continue;
+                               if (errno != ENOTTY || !dd->dd_no_part)
+                                       /*
+                                        * Allow plain partitions,
+                                        * like already existing wedges
+                                        * (like dk0) if marked as
+                                        * non-partitioning device.
+                                        * For all other cases, continue
+                                        * with the next disk.
+                                        */
+                                       continue;
+                               if (!is_ffs_wedge(dd->dd_name))
+                                       continue;
                        }
 
                        /*
@@ -433,12 +559,17 @@
                        if (is_active_rootpart(dd->dd_name, 0))
                                continue;
 
-                       dd->dd_cyl = l.d_ncylinders;
-                       dd->dd_head = l.d_ntracks;
-                       dd->dd_sec = l.d_nsectors;



Home | Main Index | Thread Index | Old Index