Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst/arch/mac68k Finish conversion to generic pa...



details:   https://anonhg.NetBSD.org/src/rev/e7d903ba8719
branches:  trunk
changeset: 744679:e7d903ba8719
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Feb 10 16:08:58 2020 +0000

description:
Finish conversion to generic partitioning backend

diffstat:

 usr.sbin/sysinst/arch/mac68k/md.c |  116 +++++++++++++++----------------------
 1 files changed, 47 insertions(+), 69 deletions(-)

diffs (166 lines):

diff -r c4fc38ff2d9b -r e7d903ba8719 usr.sbin/sysinst/arch/mac68k/md.c
--- a/usr.sbin/sysinst/arch/mac68k/md.c Mon Feb 10 15:30:33 2020 +0000
+++ b/usr.sbin/sysinst/arch/mac68k/md.c Mon Feb 10 16:08:58 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: md.c,v 1.8 2019/07/13 17:13:38 martin Exp $ */
+/*     $NetBSD: md.c,v 1.9 2020/02/10 16:08:58 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -247,12 +247,13 @@
 bool
 md_make_bsd_partitions(struct install_partition_desc *install)
 {
-       int rv;
-#if 0  // XXX
-       FILE *f;
-       int i, j, pl;
+       int i, j, rv;
        EBZB *bzb;
-#endif
+       struct disk_part_info info;
+       uint fs_type;
+       const char *mountpoint;
+       part_id pid;
+       size_t ndx;
 
        /*
         * Scan for any problems and report them before continuing.
@@ -272,16 +273,10 @@
                break;
        }
 
-#if 0  // XXX
-       /* Build standard partitions */
-       memset(&pm->bsdlabel, 0, sizeof pm->bsdlabel);
+       /* Start with empty fake disklabel partitions */
+       pm->parts->pscheme->delete_all_partitions(pm->parts);
 
        /*
-        * The mac68k port has a predefined partition for "c" which
-        *  is the size of the disk, everything else is unused.
-        */
-       pm->bsdlabel[RAW_PART].pi_size = pm->dlsize;
-       /*
         * Now, scan through the Disk Partition Map and transfer the
         *  information into the incore disklabel.
         */
@@ -289,80 +284,63 @@
            j = map.mblk[i];
            bzb = (EBZB *)&map.blk[j].pmBootArgs[0];
            if (bzb->flags.part) {
-               pl = bzb->flags.part - 'a';
+               mountpoint = NULL;
+               fs_type = FS_UNUSED;
                switch (whichType(&map.blk[j])) {
                    case HFS_PART:
-                       pm->bsdlabel[pl].pi_fstype = FS_HFS;
-                       strcpy (pm->bsdlabel[pl].pi_mount, (char *)bzb->mount_point);
+                       fs_type = FS_HFS;
+                       mountpoint = (const char*)bzb->mount_point;
                        break;
                    case ROOT_PART:
                    case UFS_PART:
-                       pm->bsdlabel[pl].pi_fstype = FS_BSDFFS;
-                       strcpy (pm->bsdlabel[pl].pi_mount, (char *)bzb->mount_point);
-                       pm->bsdlabel[pl].pi_flags |= PIF_NEWFS | PIF_MOUNT;
+                       fs_type = FS_BSDFFS;
+                       mountpoint = (const char*)bzb->mount_point;
                        break;
                    case SWAP_PART:
-                       pm->bsdlabel[pl].pi_fstype = FS_SWAP;
+                       fs_type = FS_SWAP;
                        break;
                    case SCRATCH_PART:
-                       pm->bsdlabel[pl].pi_fstype = FS_OTHER;
-                       strcpy (pm->bsdlabel[pl].pi_mount, (char *)bzb->mount_point);
+                       fs_type = FS_OTHER;
+                       mountpoint = (const char*)bzb->mount_point;
+                       break;
                    default:
-                       break;
+                       continue;
                }
-               if (pm->bsdlabel[pl].pi_fstype != FS_UNUSED) {
-                   pm->bsdlabel[pl].pi_size = map.blk[j].pmPartBlkCnt;
-                   pm->bsdlabel[pl].pi_offset = map.blk[j].pmPyPartStart;
-                   if (pm->bsdlabel[pl].pi_fstype != FS_SWAP) {
-                       pm->bsdlabel[pl].pi_frag = 8;
-                       pm->bsdlabel[pl].pi_fsize = 1024;
-                   }
+               if (fs_type != FS_UNUSED) {
+                       memset(&info, 0, sizeof info);
+                       info.start = map.blk[j].pmPyPartStart;
+                       info.size = map.blk[j].pmPartBlkCnt;
+                       info.fs_type = fs_type;
+                       info.last_mounted = mountpoint;
+                       info.nat_type = pm->parts->pscheme->get_fs_part_type(
+                           PT_root, fs_type, 0);
+                       pid = pm->parts->pscheme->add_outer_partition(pm->parts,
+                           &info, NULL);
+                       if (pid == NO_PART)
+                               return false;
                }
            }
        }
 
        /* Disk name  - don't bother asking, just use the physical name*/
-       strcpy (pm->bsddiskname, pm->diskdev);
+       pm->parts->pscheme->set_disk_pack_name(pm->parts, pm->diskdev);
+
+       /* Write the converted partitions */
+       if (!pm->parts->pscheme->write_to_disk(pm->parts))
+               return false;
 
-#ifdef DEBUG
-       f = fopen ("/tmp/disktab", "w");
-#else
-       f = fopen ("/etc/disktab", "w");
-#endif
-       if (f == NULL) {
-               endwin();
-               (void) fprintf (stderr, "Could not open /etc/disktab");
-               exit (1);
+       /* now convert to install info */
+       if (!install_desc_from_parts(install, pm->parts))
+               return false;
+
+       /* set newfs flag for all FFS partitions */
+       for (ndx = 0; ndx < install->num; ndx++) {
+               if (install->infos[ndx].fs_type == FS_BSDFFS &&
+                   install->infos[ndx].size > 0 &&
+                   (install->infos[ndx].instflags & PUIINST_MOUNT))
+                       install->infos[ndx].instflags |= PUIINST_NEWFS;
        }
-       (void)fprintf (f, "%s|NetBSD installation generated:\\\n", pm->bsddiskname);
-       (void)fprintf (f, "\t:dt=%s:ty=winchester:\\\n", pm->disktype);
-       (void)fprintf (f, "\t:nc#%d:nt#%d:ns#%d:\\\n", pm->dlcyl, pm->dlhead, pm->dlsec);
-       (void)fprintf (f, "\t:sc#%d:su#%" PRIu32 ":\\\n", pm->dlhead*pm->dlsec, (uint32_t)pm->dlsize);
-       (void)fprintf (f, "\t:se#%d:%s\\\n", blk_size, pm->doessf);
-       for (i=0; i<8; i++) {
-               if (pm->bsdlabel[i].pi_fstype == FS_HFS)
-                   (void)fprintf (f, "\t:p%c#%d:o%c#%d:t%c=macos:",
-                              'a'+i, pm->bsdlabel[i].pi_size,
-                              'a'+i, pm->bsdlabel[i].pi_offset,
-                              'a'+i);
-               else
-                   (void)fprintf (f, "\t:p%c#%d:o%c#%d:t%c=%s:",
-                              'a'+i, pm->bsdlabel[i].pi_size,
-                              'a'+i, pm->bsdlabel[i].pi_offset,
-                              'a'+i, getfslabelname(pm->bsdlabel[i].pi_fstype));
-               if (pm->bsdlabel[i].pi_fstype == FS_BSDFFS)
-                       (void)fprintf (f, "b%c#%d:f%c#%d",
-                          'a'+i, pm->bsdlabel[i].pi_fsize * pm->bsdlabel[i].pi_frag,
-                          'a'+i, pm->bsdlabel[i].pi_fsize);
-               if (i < 7)
-                       (void)fprintf (f, "\\\n");
-               else
-                       (void)fprintf (f, "\n");
-       }
-       fclose (f);
-#endif
 
-       /* Everything looks OK. */
        return true;
 }
 



Home | Main Index | Thread Index | Old Index