slitaz-forge diff mirror/floppies/builder/bootloader @ rev 384
2014
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Jan 04 14:12:10 2014 +0000 (2014-01-04) |
parents | dea449c5be89 |
children | 3f69f6b3ee85 |
line diff
1.1 --- a/mirror/floppies/builder/bootloader Thu Apr 12 13:38:03 2012 +0200 1.2 +++ b/mirror/floppies/builder/bootloader Sat Jan 04 14:12:10 2014 +0000 1.3 @@ -9,187 +9,274 @@ 1.4 usage() 1.5 { 1.6 cat <<EOT 1.7 -Usage: $0 bzImage [--prefix image_prefix] [--cmdline 'args'] 1.8 +Usage: $0 bzImage [--prefix image_prefix] [--info file ] 1.9 + [--format 1200|1440|1680|1920|2880|... ] [--mem mb] 1.10 [--rdev device] [--video mode] [--flags rootflags] [--tracks cnt] 1.11 - [--format 1440|1680|1920|2880 ] [--initrd initrdfile]... 1.12 + [--cmdline 'args'] [--dont-edit-cmdline] [--no-syssize-fix] 1.13 + [--address-initrd address] [--initrd initrdfile]... 1.14 1.15 -Default values: --format 1440 --tracks 80 --prefix floppy. 1.16 +Default values: --format 1440 --tracks 80 --rdev /dev/fd0 --prefix floppy. --mem 16 1.17 1.18 Example: 1.19 -$0 /boot/vmlinuz-2.6.30.6 --rdev /dev/ram0 --video -3 --cmdline 'rw lang=fr_FR kmap=fr-latin1 laptop autologin' --initrd /boot/rootfs.gz --initrd ./myconfig.gz 1.20 +$0 /boot/bzImage --rdev /dev/ram0 --video -3 --cmdline 'rw lang=fr_FR kmap=fr-latin1 laptop autologin' --initrd /boot/rootfs.gz --initrd ./myconfig.gz 1.21 EOT 1.22 exit 1 1.23 } 1.24 1.25 KERNEL="" 1.26 INITRD="" 1.27 +ADRSRD="" 1.28 CMDLINE="" 1.29 PREFIX="floppy." 1.30 FORMAT="1440" 1.31 RDEV="" 1.32 VIDEO="" 1.33 FLAGS="" 1.34 -TRACKS="" 1.35 +TRACKS="80" 1.36 +MEM="16" 1.37 +NOEDIT="" 1.38 +NOSYSSIZEFIX="" 1.39 +INFOFILE="" 1.40 DEBUG="" 1.41 while [ -n "$1" ]; do 1.42 - case "$1" in 1.43 - --c*|-c*) CMDLINE="$2"; shift;; 1.44 - --i*|-i*) INITRD="$INITRD $2"; shift;; 1.45 - --p*|-p*) PREFIX="$2"; shift;; 1.46 - --fo*|-f*) FORMAT="$2"; shift;; 1.47 - --fl*) FLAGS="$2"; shift;; # 1 read-only, 0 read-write 1.48 - --r*|-r*) RDEV="$2"; shift;; # /dev/??? 1.49 - --v*|-v*) VIDEO="$2"; shift;; # -3 .. n 1.50 - --t*|-t*) TRACKS="$2"; shift;; # likely 81 .. 84 1.51 - --debug) DEBUG="1";; 1.52 + case "${1/--/-}" in 1.53 + -c*) CMDLINE="$2"; shift;; 1.54 + -inf*) INFOFILE="$2"; shift;; 1.55 + -i*) INITRD="$INITRD $2"; shift;; 1.56 + -a*) ADRSRD="$2"; shift;; 1.57 + -h*) HEAP="$2"; shift;; 1.58 + -l*) LOADERTYPE="$2"; shift;; 1.59 + -p*) PREFIX="$2"; shift;; 1.60 + -fl*)FLAGS="$2"; shift;; # 1 read-only, 0 read-write 1.61 + -f*) FORMAT="$2"; shift;; 1.62 + -m*) MEM="$(echo $2 | sed 's/[^0-9]//g')"; shift;; 1.63 + -r*) RDEV="$2"; shift;; 1.64 + -v*) VIDEO="$2"; shift;; # -3 .. n 1.65 + -t*) TRACKS="$2"; shift;; # likely 81 .. 84 1.66 + -n*) NOSYSSIZEFIX="1";; 1.67 + -debug) DEBUG="1";; 1.68 + -d*) NOEDIT="1";; 1.69 *) KERNEL="$1";; 1.70 esac 1.71 shift 1.72 done 1.73 [ -n "$KERNEL" -a -f "$KERNEL" ] || usage 1.74 -if [ -n "$TRACKS" ]; then 1.75 - if [ $(( $FORMAT % $TRACKS )) -ne 0 ]; then 1.76 - echo "Invalid track count for format $FORMAT." 1.77 - usage 1.78 - fi 1.79 +while [ -L "$KERNEL" ]; do KERNEL="$(readlink "$KERNEL")"; done 1.80 +if [ $(( $FORMAT % $TRACKS )) -ne 0 ]; then 1.81 + echo "Invalid track count for format $FORMAT." 1.82 + usage 1.83 fi 1.84 +[ 0$MEM -lt 4 ] && MEM=4 1.85 +[ $MEM -gt 16 ] && MEM=16 1.86 1.87 -# write a 16 bits data 1.88 -# usage: store16 offset data16 file 1.89 -store16() 1.90 +ddq() { dd $@ 2> /dev/null; } 1.91 + 1.92 +patch() 1.93 { 1.94 - echo $(( $2 + 0x10000 )) | \ 1.95 - awk '{ printf "\\\\x%02X\\\\x%02X",$1%256,($1/256)%256 }' | \ 1.96 - xargs echo -en | \ 1.97 - dd bs=2 conv=notrunc of=$3 seek=$(( $1 / 2 )) 2> /dev/null 1.98 - [ -n "$DEBUG" ] && printf "store16(%04X) = %04X\n" $1 $2 1>&2 1.99 + echo -en $(echo ":$2" | sed 's/:/\\x/g') | \ 1.100 + ddq bs=1 conv=notrunc of=$3 seek=$((0x$1)) 1.101 + [ -n "$DEBUG" ] && echo "patch $1 $2 $4" 1>&2 1.102 } 1.103 1.104 -# write a 32 bits data 1.105 -# usage: storelong offset data32 file 1.106 -storelong() 1.107 +# usage: store bits offset data file 1.108 +store() 1.109 { 1.110 - echo $2 | awk '{ printf "\\\\x%02X\\\\x%02X\\\\x%02X\\\\x%02X", 1.111 - $1%256,($1/256)%256,($1/256/256)%256,($1/256/256/256)%256 }' | \ 1.112 - xargs echo -en | \ 1.113 - dd bs=4 conv=notrunc of=$3 seek=$(( $1 / 4 )) 2> /dev/null 1.114 - [ -n "$DEBUG" ] && printf "storelong(%04X) = %08X\n" $1 $2 1>&2 1.115 + n=$3; for i in $(seq 8 8 $1); do 1.116 + printf '\\\\x%02X' $(($n & 255)) 1.117 + n=$(($n >> 8)) 1.118 + done | xargs echo -en | ddq bs=1 conv=notrunc of=$4 seek=$(($2)) 1.119 + [ -n "$DEBUG" ] && printf "store%d(%03X) = %0$(($1/4))X %s\n" $1 $2 $3 "$5" 1>&2 1.120 } 1.121 1.122 -# read a 32 bits data 1.123 # usage: getlong offset file 1.124 getlong() 1.125 { 1.126 - dd if=$2 bs=1 skip=$(( $1 )) count=4 2> /dev/null | \ 1.127 - hexdump -e '"" 1/4 "%d" "\n"' 1.128 + ddq if=$2 bs=1 skip=$(($1)) count=4 | hexdump -e '"" 1/4 "%d" "\n"' 1.129 +} 1.130 + 1.131 +error() 1.132 +{ 1.133 + echo $@ 1>&2 1.134 + rm -f $bs 1.135 + exit 1 1.136 } 1.137 1.138 floppyset() 1.139 { 1.140 # bzImage offsets 1.141 - CylinderCount=496 1.142 SetupSzOfs=497 1.143 FlagsOfs=498 1.144 - SyssizeOfs=500 1.145 VideoModeOfs=506 1.146 RootDevOfs=508 1.147 - CodeAdrOfs=0x214 1.148 + Magic=0x202 1.149 RamfsAdrOfs=0x218 1.150 RamfsLenOfs=0x21C 1.151 - ArgPtrOfs=0x228 1.152 1.153 # boot+setup address 1.154 SetupBase=0x90000 1.155 1.156 - stacktop=0x9E00 1.157 - 1.158 bs=/tmp/bs$$ 1.159 1.160 # Get and patch boot sector 1.161 - # See http://hg.slitaz.org/wok/raw-file/711d076b277c/linux/stuff/linux-header-2.6.34.u 1.162 - dd if=$KERNEL bs=512 count=1 of=$bs 2> /dev/null 1.163 - uudecode <<EOT | dd of=$bs conv=notrunc 2> /dev/null 1.164 + # See http://hg.slitaz.org/wok/raw-file/66e38bd6a132/linux/stuff/linux-header.u 1.165 + [ -n "$DEBUG" ] && echo "Read bootsector..." 1>&2 1.166 + ddq if=$KERNEL bs=512 count=1 of=$bs 1.167 + 1.168 + [ $(( $(getlong 0x1FE $bs) & 0xFFFF )) -eq 43605 ] || 1.169 + error "Not bootable" 1.170 + 1.171 + uudecode <<EOT | ddq of=$bs conv=notrunc 1.172 begin-base64 644 - 1.173 -/L+6nWgAkAcGF4n8McC5HQDzq1sfD6mg8X1ABlfFd3ixBvOlZWaPR3gGH8ZF 1.174 -+D/6l1hB6DQBvgACA3QO6HYBWwseKAJ0LFNH6AoBXuhmAbAgzRCwCM0QTuhl 1.175 -ATwIdAOIBK05NigCdPDoPgE8CnXgiHz+ieb/TBD/TBi/9AGBTRz/gMdFMACc 1.176 -sBCxBUi0k4lEHLABiUQUmGaY0+BIZgMFZtPoaAAQB7+AACn4nHMCAccx21BW 1.177 -6J4AXrkAgLSH/kQczRVYnXfcoRoCvxwCsQk4RBxyuJPNE+oAACCQsEYoyL7b 1.178 -AejSAF3rI4D5E3IEOMF3a4D+AnIEOOZ3bGCB/QAGdCoGUlFTlrQCULEGtQTB 1.179 -xQSwDyHoBJAnFEAn6IwA/s117LAgzRDitOiWAJjNE2FSUCjIdwKwAZg5+HIC 1.180 -ifhQtALNE5VeWFpyoJVBjuGAxwJPdFFOdfSM4ZU4wXVFiMj+xrEBOOZ1O4j0 1.181 -/sW2AID9UHIwOi7wAXIqtQBgvt4B/kQMU+gxAFvoOAB1FlKYzRO4AQLNE1rQ 1.182 -1Dpk/nXqRgjkdeVh64sWB7AxLAO0DrsHAM0QPA1088OwDejv/6wIwHX4w79s 1.183 -BLFbZQINuA0BZToNdArNFnT0mM0Wju9Hw1g6AEluc2VydCBkaXNrIDEuBw0A 1.184 -AA== 1.185 +/L+4nWgAkBeJ/BYHMcC5HgDzq1sfD6Gg8X1AxXd4BlexBvOlFh9kZo9HeMZF 1.186 ++D/6l1hB6DwBvgACgUwQIIDGRCWbA3QO6GoBWwseKAJ0LFNH6AYBXuhaAbAg 1.187 +zRCwCM0QTuhZATwIdAOIBK05NigCdPDoMgE8CnXgiHz+W4nm/0gQxkAVk4Dz 1.188 +CHX0u/QBoRUCsQVmix9mS2bT60NoAAgHv4AAiXwTiUQbAfjR7yn7nHMCAd9Q 1.189 +V1ZTMdvongBbXlmGzbSHFgfNFVidd9ChGQK7HAKxCTlEG3K6l80T6gAAIJCw 1.190 +RijIvtgB6MoAXesjgPkTcgQ4wXdrgP4CcgQ45ndsYIH9AAZ0KgZSUVOWtAJQ 1.191 +sQa1BMHFBLAPIegEkCcUQCfohAD+zXXssCDNEOK06I4AmM0TYVJQKMh3ArAB 1.192 +mDn4cgKJ+FC0As0TlV5YWnKglUGO6YDHAk90S0519IzplTjBdT+IyP7GsQE4 1.193 +5nU1iPT+xYD9ULYAdSq1AGC+2wH+RAxT6C8AW+g2AHUWUpjNE7gBAs0TWtDU 1.194 +OmT+depGCOR15WHrkbAxLAO0DrsHAM0QPA1088OwDejv/6wIwHX4w79sBLFb 1.195 +ZAINuA0BZDoNdArNFnT0mM0WjudHw1g6AEluc2VydCBkaXNrIDEHDQA= 1.196 ==== 1.197 EOT 1.198 + # Get setup 1.199 + setupsz=$(( $(getlong $SetupSzOfs $bs) & 0xFF )) 1.200 + if [ $setupsz -eq 0 ]; then 1.201 + setupsz=4 1.202 + store 8 $SetupSzOfs $setupsz $bs "setup size $setupsz" 1.203 + fi 1.204 + [ -n "$DEBUG" ] && echo "Read setup ($setupsz sectors) ..." 1>&2 1.205 + ddq if=$KERNEL bs=512 skip=1 count=$setupsz >> $bs 1.206 1.207 - # Get setup 1.208 - setupsz=$(getlong $SetupSzOfs $bs) 1.209 - setupszb=$(( $setupsz & 255 )) 1.210 - dd if=$KERNEL bs=512 skip=1 count=$setupszb 2> /dev/null >> $bs 1.211 + Version=$(( $(getlong 0x206 $bs) & 0xFFFF )) 1.212 + [ $(getlong $Magic $bs) -ne 1400005704 ] && Version=0 1.213 + feature="" 1.214 + while read prot kern info ; do 1.215 + [ $Version -lt $((0x$prot)) ] && continue 1.216 + feature="features $prot starting from kernel $kern " 1.217 + done <<EOT 1.218 +200 1.3.73 kernel_version, bzImage, initrd, loadflags/type_of_loader 1.219 +201 1.3.76 heap_end_ptr 1.220 +202 2.4.0 new cmdline 1.221 +204 2.6.14 long syssize 1.222 +EOT 1.223 + [ -n "$DEBUG" ] && printf "Protocol %X $feature\n" $Version 1>&2 1.224 + 1.225 + # Old kernels need bootsector patches to disable rescent features 1.226 + while read minversion maxversion offset bytes rem; do 1.227 + [ $Version -gt $(( 0x$maxversion )) ] && continue 1.228 + [ $Version -lt $(( 0x$minversion )) ] && continue 1.229 + patch $offset $bytes $bs "$rem" 1.230 + done <<EOT 1.231 +000 1FF 08D B8:00:01 force zImage (movw \$0x100, %ax) 1.232 +000 1FF 0CB EB:0B skip initrd code 1.233 +000 201 01E EB:1E:00:00:00:00 room for the cmdline magic 1.234 +000 201 036 BE:00:00:E8:76:01:EB:0A:06:57:B1:06:F3:A5:EB:DE code in cmdline magic moved 1.235 +000 1FF 039 90:90:90 no kernel version 1.236 +000 201 04B 22:00 old cmdline ptr 1 1.237 +000 201 06D 22:00 old cmdline ptr 2 1.238 +000 203 1F6 00:00 syssize32 1.239 +200 FFF 210 FF type_of_loader=FF 1.240 +201 FFF 224 00:9B heap_end_ptr 1.241 +EOT 1.242 + if [ $Version -lt 514 ]; then 1.243 + version_string=$((0x200 + ($(getlong 0x20E $bs) & 65535) )) 1.244 + store 16 0x0037 $version_string $bs version_string 1.245 + fi 1.246 + if [ $Version -ge 512 -a $(getlong 0x214 $bs) -ge $((0x100000)) ]; then 1.247 + patch 211 81 $bs loadflags=can_use_heap+loadhigh 1.248 + patch 09D 10 $bs LOADSEG=0x1000 1.249 + patch 0A0 00:01 $bs LOADSZ=0x10000 1.250 + fi 1.251 + [ -n "$CMDLINE" ] || patch 04D EB $bs "No cmdline" 1.252 + [ -n "$NOEDIT" ] && patch 059 0D:46:EB:14 $bs 'mov CR,%al ; inc %si; jmp putal' 1.253 + [ 1$TRACKS -ne 180 ] && store 8 0x171 $TRACKS $bs TRACKS 1.254 + 1.255 + [ -n "$FLAGS" ] && store 16 $FlagsOfs $FLAGS $bs FLAGS 1.256 + [ -n "$VIDEO" ] && store 16 $VideoModeOfs $VIDEO $bs VIDEO 1.257 + [ -n "$RDEV" ] || case "$FORMAT" in 1.258 + 1200) RDEV=0x0208 ;; 1.259 + 1440) RDEV=0x021C ;; 1.260 + 2880) RDEV=0x0220 ;; 1.261 + *) RDEV=0x0200 ;; 1.262 + esac 1.263 + while [ -L "$RDEV" ]; do RDEV="$(readlink "$RDEV")"; done 1.264 + [ -b "$RDEV" ] && RDEV=$(stat -c '0x%02t%02T' $RDEV 2> /dev/null) 1.265 + store 16 $RootDevOfs $RDEV $bs RDEV 1.266 1.267 - if [ -n "$TRACKS" ]; then 1.268 - [ -n "$DEBUG" ] && echo -n "--tracks " 1>&2 1.269 - n=$(getlong $CylinderCount $bs) 1.270 - store16 $CylinderCount $(( ($n & -256) + $TRACKS )) $bs 1.271 - fi 1.272 - if [ -n "$FLAGS" ]; then 1.273 - [ -n "$DEBUG" ] && echo -n "--flags " 1>&2 1.274 - store16 $FlagsOfs $FLAGS $bs 1.275 - fi 1.276 - if [ -n "$VIDEO" ]; then 1.277 - [ -n "$DEBUG" ] && echo -n "--video " 1>&2 1.278 - store16 $VideoModeOfs $VIDEO $bs 1.279 - fi 1.280 - if [ -n "$RDEV" ]; then 1.281 - if [ "$(dirname $RDEV)" == "/dev" -a -b $RDEV ]; then 1.282 - [ -n "$DEBUG" ] && echo -n "--rdev " 1>&2 1.283 - RDEV=$(stat -c '0x%02t%02T' $RDEV 2> /dev/null) 1.284 - store16 $RootDevOfs $RDEV $bs 1.285 + [ $FORMAT -lt 1440 ] && store 8 0xEF 16 $bs 1.2M 1.286 + [ $FORMAT -lt 1200 ] && store 8 0xEF 10 $bs 720K 1.287 + [ $FORMAT -lt 720 ] && store 8 0x171 40 $bs 360K 1.288 + [ $FORMAT -lt 360 ] && store 8 0xEF 9 $bs 320K 1.289 + [ $FORMAT -lt 320 ] && store 8 0xF8 2 $bs 160K 1.290 + 1.291 + # Info text after setup 1.292 + if [ -s "$INFOFILE" ]; then 1.293 + patch 048 9a:00:00:00:90 $bs lcall displayinfo 1.294 + uudecode >$bs.infotext <<EOT 1.295 +begin-base64 644 - 1.296 +MdsGYI7D6AAAXoHGSgCJ8MHoCUii8QGwDbQOuwcAzRCsPAx1I79sBLFbJgIN 1.297 +uBsBJjoNdAnNFnT0mM0Wjsc8IHPjPBt0BuvPCMB1zWEHCx4oAss= 1.298 +==== 1.299 +EOT 1.300 + cat "$INFOFILE" >>$bs.infotext 1.301 + if [ $Version -lt 514 ]; then 1.302 + store 16 0x050 0x0022 $bs.infotext 1.303 fi 1.304 + ddq if=/dev/zero bs=512 count=1 >>$bs.infotext 1.305 + n=$(($(stat -c %s $bs.infotext)/512)) 1.306 + ddq if=$bs.infotext count=$n bs=512 >> $bs 1.307 + rm -f $bs.infotext 1.308 + store 8 0x1F1 $(($setupsz+$n)) $bs update setup size 1.309 + store 8 0x04A $((2+2*$setupsz)) $bs update displayinfo call 1.310 fi 1.311 1.312 - # Store cmdline after setup 1.313 + # Store cmdline after setup for kernels >= 0.99 1.314 if [ -n "$CMDLINE" ]; then 1.315 - [ -n "$DEBUG" ] && echo -n "--cmdline '$CMDLINE' " 1>&2 1.316 - echo -n "$CMDLINE" | dd bs=512 count=1 conv=sync 2> /dev/null >> $bs 1.317 - storelong $ArgPtrOfs $(( $SetupBase + $stacktop )) $bs 1.318 + echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> $bs 1.319 + CmdlineOfs=0x9E00 # Should be in 0x8000 .. 0xA000 1.320 + ArgPtrOfs=0x228 1.321 + ArgPtrVal=$(( $SetupBase + $CmdlineOfs )) 1.322 + if [ $Version -lt 514 ]; then 1.323 + ArgPtrOfs=0x0020 1.324 + ArgPtrVal=$(( 0xA33F + ($CmdlineOfs << 16) )) 1.325 + fi 1.326 + store 32 $ArgPtrOfs $ArgPtrVal $bs "Cmdline '$CMDLINE'" 1.327 fi 1.328 1.329 - # Compute initramfs size 1.330 + # Compute initramfs size (protocol >= 2.00) 1.331 + [ $Version -lt 512 ] && INITRD="" 1.332 initrdlen=0 1.333 +INITRDPAD=4 1.334 +INITRDALIGN=0x1000 1.335 for i in $( echo $INITRD | sed 's/,/ /' ); do 1.336 [ -s "$i" ] || continue 1.337 - [ -n "$DEBUG" ] && echo "--initrd $i " 1>&2 1.338 - initrdlen=$(( ($initrdlen + $(stat -c %s $i) + 3) & -4 )) 1.339 + while [ -L "$i" ]; do i="$(readlink $i)"; done 1.340 + size=$(( ($(stat -c %s "$i") + $INITRDPAD - 1) & -$INITRDPAD )) 1.341 + [ -n "$DEBUG" ] && echo "initrd $i $size " 1>&2 1.342 + initrdlen=$(( $initrdlen + $size )) 1.343 + [ -n "$ADRSRD" ] || ADRSRD=$(( (($MEM * 0x100000) - $initrdlen) & -$INITRDALIGN )) 1.344 + store 32 $RamfsAdrOfs $(( $ADRSRD )) $bs initrd adrs 1.345 + store 32 $RamfsLenOfs $initrdlen $bs initrdlen 1.346 done 1.347 - if [ $initrdlen -ne 0 ]; then 1.348 - [ -n "$DEBUG" ] && echo "initrdlen = $initrdlen " 1>&2 1.349 - storelong $RamfsAdrOfs \ 1.350 - $(( (0x1000000 - $initrdlen) & 0xFFFF0000 )) $bs 1.351 - storelong $RamfsLenOfs $initrdlen $bs 1.352 - fi 1.353 + 1.354 + [ -n "$NOSYSSIZEFIX" ] || store 32 0x1F4 \ 1.355 + $(( ($(stat -c %s $KERNEL)+15)/16 - ($setupsz+1)*32)) $bs fix system size 1.356 1.357 # Output boot sector + setup + cmdline 1.358 - dd if=$bs 2> /dev/null 1.359 + ddq if=$bs 1.360 1.361 # Output kernel code 1.362 - dd if=$KERNEL bs=512 skip=$(( $setupszb + 1 )) 2> /dev/null 1.363 - 1.364 - # Pad to next sector 1.365 - Kpad=$(( 512 - ($(stat -c %s $KERNEL) & 511) )) 1.366 - [ $Kpad -eq 512 ] || dd if=/dev/zero bs=1 count=$Kpad 2> /dev/null 1.367 + syssz=$(( ($(getlong 0x1F4 $bs)+31)/32 )) 1.368 + cat $KERNEL /dev/zero | ddq bs=512 skip=$(( $setupsz+1 )) count=$syssz conv=sync 1.369 1.370 # Output initramfs 1.371 - padding=0 1.372 for i in $( echo $INITRD | sed 's/,/ /' ); do 1.373 [ -s "$i" ] || continue 1.374 - [ $padding -ne 0 ] && dd if=/dev/zero bs=1 count=$padding 2> /dev/null 1.375 - dd if=$i 2> /dev/null 1.376 - padding=$(( 4 - ($(stat -c %s $i) & 3) )) 1.377 - [ $padding -eq 4 ] && padding=0 1.378 + ddq if=$i 1.379 + padding=$(( $INITRDPAD - ($(stat -c %s $i) % $INITRDPAD) )) 1.380 + [ $padding -eq $INITRDPAD ] || ddq if=/dev/zero bs=1 count=$padding 1.381 done 1.382 1.383 # Cleanup 1.384 @@ -199,14 +286,14 @@ 1.385 if [ "$FORMAT" == "0" ]; then # unsplitted 1.386 floppyset > $PREFIX 1.387 PAD=$(( 512 - ($(stat -c %s $PREFIX) % 512) )) 1.388 - [ $PAD -ne 512 ] && dd if=/dev/zero bs=1 count=$PAD >> $PREFIX 2> /dev/null 1.389 + [ $PAD -ne 512 ] && ddq if=/dev/zero bs=1 count=$PAD >> $PREFIX 1.390 exit 1.391 fi 1.392 floppyset | split -b ${FORMAT}k /dev/stdin floppy$$ 1.393 i=1 1.394 -ls floppy$$* | while read file ; do 1.395 +ls floppy$$* 2> /dev/null | while read file ; do 1.396 output=$PREFIX$(printf "%03d" $i) 1.397 - cat $file /dev/zero | dd bs=1k count=$FORMAT conv=sync of=$output 2> /dev/null 1.398 + cat $file /dev/zero | ddq bs=1k count=$FORMAT conv=sync of=$output 1.399 echo $output 1.400 rm -f $file 1.401 i=$(( $i + 1 ))