Source-Changes-HG archive

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

[src/netbsd-1-4]: src/sys/arch/mac68k/mac68k pullup 1.30->1.32 (scottr)



details:   https://anonhg.NetBSD.org/src/rev/2ade07a9a7cb
branches:  netbsd-1-4
changeset: 468628:2ade07a9a7cb
user:      perry <perry%NetBSD.org@localhost>
date:      Mon May 03 13:02:20 1999 +0000

description:
pullup 1.30->1.32 (scottr)

diffstat:

 sys/arch/mac68k/mac68k/disksubr.c |  408 ++++++++++++-------------------------
 1 files changed, 136 insertions(+), 272 deletions(-)

diffs (truncated from 567 to 300 lines):

diff -r 7862f03ac79f -r 2ade07a9a7cb sys/arch/mac68k/mac68k/disksubr.c
--- a/sys/arch/mac68k/mac68k/disksubr.c Mon May 03 12:59:52 1999 +0000
+++ b/sys/arch/mac68k/mac68k/disksubr.c Mon May 03 13:02:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disksubr.c,v 1.30 1999/01/30 17:34:31 scottr Exp $     */
+/*     $NetBSD: disksubr.c,v 1.30.4.1 1999/05/03 13:02:20 perry Exp $  */
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -90,7 +90,7 @@
 
 #define        b_cylin b_resid
 
-#define NUM_PARTS_PROBED 32
+#define NUM_PARTS 32
 
 #define ROOT_PART 1
 #define UFS_PART 2
@@ -105,14 +105,10 @@
 
 static int getFreeLabelEntry __P((struct disklabel *));
 static int whichType __P((struct part_map_entry *));
-static void fixPartTable __P((struct part_map_entry *, long, char *, int *));
-static void setRoot __P((struct part_map_entry *, struct disklabel *, int));
-static void setSwap __P((struct part_map_entry *, struct disklabel *, int));
-static void setUfs __P((struct part_map_entry *, struct disklabel *, int));
-static void setHfs __P((struct part_map_entry *, struct disklabel *, int));
-static void setScratch __P((struct part_map_entry *, struct disklabel *, int));
-static int getNamedType
-__P((struct part_map_entry *, int, struct disklabel *, int, int, int *));
+static void setpartition __P((struct part_map_entry *,
+               struct partition *, int));
+static int getNamedType __P((struct part_map_entry *, int,
+               struct disklabel *, int, int, int *));
 static char *read_mac_label __P((dev_t, void (*)(struct buf *),
                struct disklabel *, struct cpu_disklabel *));
 static char *read_dos_label __P((dev_t, void (*)(struct buf *),
@@ -122,7 +118,7 @@
  * Find an entry in the disk label that is unused and return it
  * or -1 if no entry
  */
-static int 
+static int
 getFreeLabelEntry(lp)
        struct disklabel *lp;
 {
@@ -140,190 +136,63 @@
 /*
  * figure out what the type of the given part is and return it
  */
-static int 
+static int
 whichType(part)
        struct part_map_entry *part;
 {
        struct blockzeroblock *bzb;
+       char typestr[32], *s;
+       int type;
 
-       if (part->pmPartType[0] == '\0')
+       if (part->pmSig != PART_ENTRY_MAGIC || part->pmPartType[0] == '\0')
                return 0;
 
-       if (strcmp(PART_TYPE_DRIVER, (char *)part->pmPartType) == 0)
-               return 0;
-       if (strcmp(PART_TYPE_DRIVER43, (char *)part->pmPartType) == 0)
-               return 0;
-       if (strcmp(PART_TYPE_DRIVERATA, (char *)part->pmPartType) == 0)
-               return 0;
-       if (strcmp(PART_TYPE_FWB_COMPONENT, (char *)part->pmPartType) == 0)
-               return 0;
-       if (strcmp(PART_TYPE_PARTMAP, (char *)part->pmPartType) == 0)
-               return 0;
-       if (strcmp(PART_TYPE_UNIX, (char *)part->pmPartType) == 0) {
+       strncpy(typestr, (char *)part->pmPartType, sizeof(typestr));
+       typestr[sizeof(typestr) - 1] = '\0';
+       for (s = typestr; *s; s++)
+               if ((*s >= 'a') && (*s <= 'z'))
+                       *s = (*s - 'a' + 'A');
+
+       if (strcmp(PART_TYPE_DRIVER, typestr) == 0 ||
+           strcmp(PART_TYPE_DRIVER43, typestr) == 0 ||
+           strcmp(PART_TYPE_DRIVERATA, typestr) == 0 ||
+           strcmp(PART_TYPE_FWB_COMPONENT, typestr) == 0 ||
+           strcmp(PART_TYPE_PARTMAP, typestr) == 0)
+               type = 0;
+       else if (strcmp(PART_TYPE_UNIX, typestr) == 0) {
                /* unix part, swap, root, usr */
                bzb = (struct blockzeroblock *)(&part->pmBootArgs);
                if (bzb->bzbMagic != BZB_MAGIC)
-                       return 0;
-
-               if (bzb->bzbFlags & BZB_ROOTFS)
-                       return ROOT_PART;
-
-               if (bzb->bzbFlags & BZB_USRFS)
-                       return UFS_PART;
+                       type = 0;
+               else if (bzb->bzbFlags & BZB_ROOTFS)
+                       type = ROOT_PART;
+               else if (bzb->bzbFlags & BZB_USRFS)
+                       type = UFS_PART;
+               else if (bzb->bzbType == BZB_TYPESWAP)
+                       type = SWAP_PART;
+               else
+                       type = SCRATCH_PART;
+       } else if (strcmp(PART_TYPE_MAC, typestr) == 0)
+               type = HFS_PART;
+       else
+               type = SCRATCH_PART;    /* no known type */
 
-               if (bzb->bzbType == BZB_TYPESWAP)
-                       return SWAP_PART;
-
-               return SCRATCH_PART;
-       }
-       if (strcmp(PART_TYPE_MAC, (char *)part->pmPartType) == 0)
-               return HFS_PART;
-/*
-       if (strcmp(PART_SCRATCH, (char *)part->pmPartType) == 0)
-               return SCRATCH_PART;
-*/
-       return SCRATCH_PART;    /* no known type, but label it, anyway */
+       return type;
 }
 
-/*
- * Take part table in crappy form, place it in a structure we can depend
- * upon.  Make sure names are NUL terminated.  Capitalize the names
- * of part types.
- */
 static void
-fixPartTable(partTable, size, base, num)
-       struct part_map_entry *partTable;
-       long size;
-       char *base;
-       int *num;
+setpartition(part, pp, fstype)
+       struct part_map_entry *part;
+       struct partition *pp;
 {
-       int i = 0;
-       struct part_map_entry *pmap;
-       char *s;
-
-       for (i = 0; i < NUM_PARTS_PROBED; i++) {
-               pmap = (struct part_map_entry *)((i * size) + base);
-
-               if (pmap->pmSig != PART_ENTRY_MAGIC) { /* this is not valid */
-                       pmap->pmPartType[0] = '\0';
-                       break;
-               }
-
-               (*num)++;
-
-               pmap->pmPartName[31] = '\0';
-               pmap->pmPartType[31] = '\0';
-
-               for (s = pmap->pmPartType; *s; s++)
-                       if ((*s >= 'a') && (*s <= 'z'))
-                               *s = (*s - 'a' + 'A');
-
-               partTable[i] = *pmap;
-       }
-}
-
-static void 
-setRoot(part, lp, slot)
-       struct part_map_entry *part;
-       struct disklabel *lp;
-       int slot;
-{
-       lp->d_partitions[slot].p_size = part->pmPartBlkCnt;
-       lp->d_partitions[slot].p_offset = part->pmPyPartStart;
-       lp->d_partitions[slot].p_fstype = FS_BSDFFS;
-
-#if PRINT_DISKLABELS
-       printf("%c: Root '%s' at %d size %d\n", slot + 'a',
-           part->pmPartName,
-           part->pmPyPartStart,
-           part->pmPartBlkCnt);
-#endif
+       pp->p_size = part->pmPartBlkCnt;
+       pp->p_offset = part->pmPyPartStart;
+       pp->p_fstype = fstype;
 
        part->pmPartType[0] = '\0';
 }
 
-static void 
-setSwap(part, lp, slot)
-       struct part_map_entry *part;
-       struct disklabel *lp;
-       int slot;
-{
-       lp->d_partitions[slot].p_size = part->pmPartBlkCnt;
-       lp->d_partitions[slot].p_offset = part->pmPyPartStart;
-       lp->d_partitions[slot].p_fstype = FS_SWAP;
-
-#if PRINT_DISKLABELS
-       printf("%c: Swap '%s' at %d size %d\n", slot + 'a',
-           part->pmPartName,
-           part->pmPyPartStart,
-           part->pmPartBlkCnt);
-#endif
-
-       part->pmPartType[0] = '\0';
-}
-
-static void 
-setUfs(part, lp, slot)
-       struct part_map_entry *part;
-       struct disklabel *lp;
-       int slot;
-{
-       lp->d_partitions[slot].p_size = part->pmPartBlkCnt;
-       lp->d_partitions[slot].p_offset = part->pmPyPartStart;
-       lp->d_partitions[slot].p_fstype = FS_BSDFFS;
-
-#if PRINT_DISKLABELS
-       printf("%c: Usr '%s' at %d size %d\n", slot + 'a',
-           part->pmPartName,
-           part->pmPyPartStart,
-           part->pmPartBlkCnt);
-#endif
-
-       part->pmPartType[0] = '\0';
-}
-
-static void 
-setHfs(part, lp, slot)
-       struct part_map_entry *part;
-       struct disklabel *lp;
-       int slot;
-{
-       lp->d_partitions[slot].p_size = part->pmPartBlkCnt;
-       lp->d_partitions[slot].p_offset = part->pmPyPartStart;
-       lp->d_partitions[slot].p_fstype = FS_HFS;
-
-#if PRINT_DISKLABELS
-       printf("%c: HFS_PART '%s' at %d size %d\n", slot + 'a',
-           part->pmPartName,
-           part->pmPyPartStart,
-           part->pmPartBlkCnt);
-#endif
-
-       part->pmPartType[0] = '\0';
-}
-
-static void 
-setScratch(part, lp, slot)
-       struct part_map_entry *part;
-       struct disklabel *lp;
-       int slot;
-{
-       lp->d_partitions[slot].p_size = part->pmPartBlkCnt;
-       lp->d_partitions[slot].p_offset = part->pmPyPartStart;
-       lp->d_partitions[slot].p_fstype = FS_OTHER;
-
-#if PRINT_DISKLABELS
-       printf("%c: Other (%s) '%s' at %d size %d\n", slot + 'a',
-           part->pmPartType,
-           part->pmPartName,
-           part->pmPyPartStart,
-           part->pmPartBlkCnt);
-#endif
-
-       part->pmPartType[0] = '\0';
-}
-
-static int 
+static int
 getNamedType(part, num_parts, lp, type, alt, maxslot)
        struct part_map_entry *part;
        int num_parts;
@@ -335,35 +204,31 @@
        int i = 0;
 
        for (i = 0; i < num_parts; i++) {
-               if (whichType(&(part[i])) == type) {
-                       switch (type) {
-                       case ROOT_PART:
-                               bzb = (struct blockzeroblock *)
-                                   (&part[i].pmBootArgs);
-                               if (alt >= 0 && alt != bzb->bzbCluster)
-                                       goto skip;
-                               setRoot(&(part[i]), lp, 0);
-                               break;
-                       case UFS_PART:
-                               bzb = (struct blockzeroblock *)
-                                   (&part[i].pmBootArgs);
-                               if (alt >= 0 && alt != bzb->bzbCluster)
-                                       goto skip;
-                               setUfs(&(part[i]), lp, 6);
-                               if (*maxslot < 6) *maxslot = 6;
-                               break;
-                       case SWAP_PART:
-                               setSwap(&(part[i]), lp, 1);
-                               if (*maxslot < 1) *maxslot = 1;
-                               break;



Home | Main Index | Thread Index | Old Index