Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/dkwedge Look at the bzb flags to mark partition as s...



details:   https://anonhg.NetBSD.org/src/rev/19639d7451bf
branches:  trunk
changeset: 335796:19639d7451bf
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jan 24 02:58:56 2015 +0000

description:
Look at the bzb flags to mark partition as swap. Requested by John D. Baker.
XXX: Pullup-7

diffstat:

 sys/dev/dkwedge/dkwedge_apple.c |  28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diffs (65 lines):

diff -r 2a4a944d6b12 -r 19639d7451bf sys/dev/dkwedge/dkwedge_apple.c
--- a/sys/dev/dkwedge/dkwedge_apple.c   Sat Jan 24 00:27:31 2015 +0000
+++ b/sys/dev/dkwedge/dkwedge_apple.c   Sat Jan 24 02:58:56 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dkwedge_apple.c,v 1.1 2012/04/07 05:36:10 christos Exp $       */
+/*     $NetBSD: dkwedge_apple.c,v 1.2 2015/01/24 02:58:56 christos Exp $       */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dkwedge_apple.c,v 1.1 2012/04/07 05:36:10 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dkwedge_apple.c,v 1.2 2015/01/24 02:58:56 christos Exp $");
 
 #include <sys/param.h>
 #ifdef _KERNEL
@@ -106,6 +106,18 @@
        SWAP32(pmBootCksum);
 }
 
+static void
+swap_apple_blockzeroblock(struct apple_blockzeroblock *ap)
+{
+        SWAP32(bzbMagic);
+        SWAP16(bzbBadBlockInode);
+        SWAP16(bzbFlags);
+        SWAP16(bzbReserved);
+        SWAP32(bzbCreationTime);
+        SWAP32(bzbMountTime);
+        SWAP32(bzbUMountTime);
+}
+
 #undef SWAP16
 #undef SWAP32
 
@@ -137,6 +149,8 @@
        uint32_t blocksize, offset, rsize;
        struct apple_drvr_map *am;
        struct apple_part_map_entry *ae;
+       struct apple_blockzeroblock ab;
+       const char *ptype;
 
        buf = DKW_MALLOC(ASIZE);
        if ((error = dkwedge_read(pdk, vp, 0, buf, ASIZE)) != 0) {
@@ -193,9 +207,17 @@
                if (i == __arraycount(map))
                        continue;
 
+               ptype = map[i].type;
+               memcpy(&ab, ae->pmBootArgs, sizeof(ab));
+               swap_apple_blockzeroblock(&ab);
+               if (ab.bzbMagic == APPLE_BZB_MAGIC) {
+                       if (ab.bzbType == APPLE_BZB_TYPESWAP)
+                               ptype = DKW_PTYPE_SWAP;
+               }
+
                struct dkwedge_info dkw;
 
-               strcpy(dkw.dkw_ptype, map[i].type);
+               strcpy(dkw.dkw_ptype, ptype);
                strcpy(dkw.dkw_parent, pdk->dk_name);
                dkw.dkw_offset = ae->pmPyPartStart;
                dkw.dkw_size = ae->pmPartBlkCnt;



Home | Main Index | Thread Index | Old Index