Source-Changes-HG archive

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

[src/trunk]: src/distrib/common/bootimage Add "live-image with a FAT partitio...



details:   https://anonhg.NetBSD.org/src/rev/5a7a5bfde443
branches:  trunk
changeset: 970348:5a7a5bfde443
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Mar 21 14:19:26 2020 +0000

description:
Add "live-image with a FAT partition for bootstrap files" support.

See PR/55075 for more details.

diffstat:

 distrib/common/bootimage/Makefile.bootimage  |  72 ++++++++++++++++++++++++++-
 distrib/common/bootimage/diskproto.mbrfat.in |  26 ++++++++++
 2 files changed, 93 insertions(+), 5 deletions(-)

diffs (210 lines):

diff -r 78194749a209 -r 5a7a5bfde443 distrib/common/bootimage/Makefile.bootimage
--- a/distrib/common/bootimage/Makefile.bootimage       Sat Mar 21 13:39:31 2020 +0000
+++ b/distrib/common/bootimage/Makefile.bootimage       Sat Mar 21 14:19:26 2020 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.bootimage,v 1.23 2019/11/21 22:29:03 joerg Exp $
+#      $NetBSD: Makefile.bootimage,v 1.24 2020/03/21 14:19:26 tsutsui Exp $
 #
 # Copyright (c) 2009, 2010, 2011 Izumi Tsutsui.  All rights reserved.
 #
@@ -63,6 +63,9 @@
 #      EFIMB
 #              EFI partition size in target image in MB
 #              (default: 128)
+#      FATMB
+#              FAT partition size in target image in MB
+#              (default: 0)
 #      KERN_SET
 #              kernel set name which should be extracted into image
 #              (default: kern-GENERIC)
@@ -123,6 +126,15 @@
 #      EFIBOOT
 #              EFI bootloader
 #              (default: empty)
+#      MBRFAT
+#              MBR partition type value for FAT
+#              (default: 6 ("16-bit FAT, more than 32M"))
+#      FATMAKEFSOPTIONS
+#              options passed to makefs(8) to create a FAT partition
+#              (default: -o fat_type=16)
+#      FATFILES
+#              list of additional files to be copied into FAT partition
+#              (default: empty)
 #
 
 .include <bsd.own.mk>          #
@@ -169,11 +181,13 @@
 EFIMB?=                128             # 128MB
 GPTSECTORS=    2048
 .endif
+FATMB?=                0
 
 # XXX: SWAPMB could be zero and expr(1) returns exit status 1 in that case
 IMAGESECTORS!= expr ${IMAGEMB} \* 1024 \* 1024 / 512
 SWAPSECTORS!=  expr ${SWAPMB} \* 1024 \* 1024 / 512 || true
 EFISECTORS!=   expr ${EFIMB} \* 1024 \* 1024 / 512 || true
+FATSECTORS!=   expr ${FATMB} \* 1024 \* 1024 / 512 || true
 
 .if ${USE_MBR} == "no" && ${USE_GPT} == "no"
 LABELSECTORS?= 0
@@ -184,7 +198,7 @@
 .endif
 
 FSSECTORS!=    expr ${IMAGESECTORS} - ${SWAPSECTORS} - ${LABELSECTORS} \
-                   - ${EFISECTORS} - ${GPTSECTORS}
+                   - ${EFISECTORS} - ${GPTSECTORS} - ${FATSECTORS}
 FSSIZE!=       expr ${FSSECTORS} \* 512
 
 # parameters for disklabel and MBR
@@ -196,10 +210,14 @@
 MBRSECTORS=    63
 MBRCYLINDERS!= expr ${IMAGESECTORS} / \( ${MBRHEADS} \* ${MBRSECTORS} \)
 MBRNETBSD=     169
+MBRFAT?=       6       # 16-bit FAT, more than 32M
 
-BSDPARTSECTORS!= expr ${IMAGESECTORS} - ${LABELSECTORS} - ${EFISECTORS} - ${GPTSECTORS}
-FSOFFSET!=     expr ${LABELSECTORS} + ${EFISECTORS}
-SWAPOFFSET!=   expr ${LABELSECTORS} + ${FSSECTORS} + ${EFISECTORS}
+BSDPARTSECTORS!= expr ${IMAGESECTORS} - ${LABELSECTORS} \
+                   - ${EFISECTORS} - ${GPTSECTORS} - ${FATSECTORS}
+FSOFFSET!=     expr ${LABELSECTORS} + ${EFISECTORS} + ${FATSECTORS}
+SWAPOFFSET!=   expr ${LABELSECTORS} + ${FSSECTORS} \
+                   + ${EFISECTORS} + ${FATSECTORS}
+FATOFFSET=     ${LABELSECTORS}
 
 # parameters for sunlabel
 FSCYLINDERS!=  expr ${FSSECTORS} / \( ${HEADS} \* ${SECTORS} \)
@@ -227,6 +245,7 @@
 SPEC_IN?=      ${DISTRIBDIR}/common/bootimage/spec.in
 
 IMGMAKEFSOPTIONS?=     -o bsize=16384,fsize=2048,density=8192
+FATMAKEFSOPTIONS?=     -o fat_type=16
 
 WORKDIR?=       work
 WORKSPEC?=      work.spec
@@ -267,6 +286,8 @@
 WORKLABEL?=    work.diskproto
 WORKIMG?=      work.img
 EFIWORKDIR?=   work.efidir
+WORKFAT?=      work.fat
+WORKFATDIR?=   work.fatdir
 
 .if ${USE_GPT} != "no"
 ${WORKFSTAB}: ${WORKMBR}
@@ -388,6 +409,9 @@
 .if ${USE_GPT} != "no"
 TARGET_BLOCKS+=        ${WORKEFI}
 .endif
+.if ${FATSECTORS} != 0
+TARGET_BLOCKS+=        ${WORKFAT}
+.endif
 TARGET_BLOCKS+=         ${TARGETFS}
 .if ${SWAPSECTORS} != 0
 TARGET_BLOCKS+=        ${WORKSWAP}
@@ -398,6 +422,7 @@
 
 CLEANFILES+=   ${WORKMBR} ${WORKMBRTRUNC} ${WORKSWAP}
 CLEANFILES+=   ${WORKEFI} ${WORKGPT}
+CLEANFILES+=   ${WORKFAT}
 CLEANFILES+=   ${WORKLABEL}.tmp ${WORKLABEL}
 CLEANFILES+=   ${WORKIMG} ${IMGBASE}.img
 
@@ -423,6 +448,8 @@
            -e "s/@@SWAPSECTORS@@/${SWAPSECTORS}/"                      \
            -e "s/@@SWAPOFFSET@@/${SWAPOFFSET}/"                        \
            -e "s/@@BSDPARTSECTORS@@/${BSDPARTSECTORS}/"                \
+           -e "s/@@FATSECTORS@@/${FATSECTORS}/"                        \
+           -e "s/@@FATOFFSET@@/${FATOFFSET}/"                          \
            < ${DISKPROTO_IN} > ${WORKLABEL}.tmp
        mv ${WORKLABEL}.tmp ${WORKLABEL}
 
@@ -439,6 +466,26 @@
            -t msdos -o F=32,c=1                                        \
            ${WORKEFI} ${EFIWORKDIR}
 
+${WORKFAT}: ${TARGETFS} ${FATFILES}
+       @echo create FAT partition for bootstrap files...
+       @${MKDIR} ${MKDIRPERM} ${WORKFATDIR}
+.if defined(FATFILES)
+       @echo Copying files for FAT partition...
+.for f in ${FATFILES}
+       @if [ ! -f ${f} ]; then                                         \
+               echo "${f} in FATFILES not found, aborting";            \
+               false;                                                  \
+       fi
+       ${INSTALL} ${COPY} -m 0644 ${f} ${WORKFATDIR}
+.endfor
+.endif
+       ${RM} -f ${WORKFAT}
+       ${TOOL_MAKEFS} -M ${FATMB}m -m ${FATMB}m                        \
+           ${MAKEFS_TIMESTAMP}                                         \
+           -t msdos                                                    \
+           ${FATMAKEFSOPTIONS}                                         \
+           ${WORKFAT} ${WORKFATDIR}
+
 ${WORKMBR}:
 .if ${USE_GPT} != "no"
        @echo creating GPT header and partition entries...
@@ -453,10 +500,24 @@
 .elif ${USE_MBR} != "no"
        @echo creating MBR labels...
        ${DD} if=/dev/zero of=${WORKMBR} seek=$$((${IMAGESECTORS} - 1)) count=1
+.  if ${FATSECTORS} != 0
+       # create BSD partition
+       ${TOOL_FDISK} -f -i -u \
+           -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS}                \
+           -1 -a -s ${MBRNETBSD}/${FSOFFSET}/${BSDPARTSECTORS}         \
+           -F ${WORKMBR}
+       # create FAT partition
+       ${TOOL_FDISK} -f -u \
+           -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS}                \
+           -0 -s ${MBRFAT}/${FATOFFSET}/${FATSECTORS}                  \
+           -F ${WORKMBR}
+.  else
+       # create BSD partition
        ${TOOL_FDISK} -f -i -u \
            -b ${MBRCYLINDERS}/${MBRHEADS}/${MBRSECTORS}                \
            -0 -a -s ${MBRNETBSD}/${FSOFFSET}/${BSDPARTSECTORS}         \
            -F ${WORKMBR}
+.  endif
 .  if empty(MBR_BOOTCODE)
        @if [ -f ${WORKDIR}/usr/mdec/${MBR_DEFAULT_BOOTCODE} ]; then    \
                echo ${TOOL_FDISK} -f                                   \
@@ -520,6 +581,7 @@
        fi      # XXX
        ${RM} -fr ${WORKDIR}
        ${RM} -fr ${EFIWORKDIR}
+       ${RM} -fr ${WORKFATDIR}
 
 prepare_md_post: .PHONY
 image_md_post: .PHONY
diff -r 78194749a209 -r 5a7a5bfde443 distrib/common/bootimage/diskproto.mbrfat.in
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/common/bootimage/diskproto.mbrfat.in      Sat Mar 21 14:19:26 2020 +0000
@@ -0,0 +1,26 @@
+# $NetBSD: diskproto.mbrfat.in,v 1.1 2020/03/21 14:19:27 tsutsui Exp $
+type: ESDI
+disk: image
+label: 
+flags:
+bytes/sector: 512
+sectors/track: @@SECTORS@@
+tracks/cylinder: @@HEADS@@
+sectors/cylinder: @@SECPERCYLINDERS@@
+cylinders: @@CYLINDERS@@
+total sectors: @@IMAGESECTORS@@
+rpm: 3600
+interleave: 1
+trackskew: 0
+cylinderskew: 0
+headswitch: 0           # microseconds
+track-to-track seek: 0  # microseconds
+drivedata: 0 
+
+8 partitions:
+#        size    offset     fstype [fsize bsize cpg/sgs]
+a:    @@FSSECTORS@@ @@FSOFFSET@@ 4.2BSD 1024 8192 16
+b:    @@SWAPSECTORS@@ @@SWAPOFFSET@@ swap
+c:    @@BSDPARTSECTORS@@ @@FSOFFSET@@ unused 0 0
+d:    @@IMAGESECTORS@@ 0 unused 0 0
+e:    @@FATSECTORS@@ @@FATOFFSET@@ MSDOS



Home | Main Index | Thread Index | Old Index