Skip to content

Commit 166b6d2

Browse files
author
none
committed
tool to create FAT16 disk images for OS load testing
1 parent 9e57fab commit 166b6d2

File tree

3 files changed

+82
-2
lines changed

3 files changed

+82
-2
lines changed

configs/tiny68k_minix.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--target
22
tiny68k
33
--diskfile
4-
../../Tiny68k/t68k_cpm_disk.bin
4+
disk.dmg
55
--eeprom
66
../../68k_rom/tiny68k.rom
77
--symbols

tools/cpm.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
# CP/M 68K executable format tools
44
#
55

6-
import struct, sys, os
6+
import struct
7+
import sys
8+
import os
79
from hexdump import hexdump
810

911
# object file types

tools/dir2disk.sh

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/sh
2+
#
3+
# Make a single-partition FAT16 disk image with the contents of a folder.
4+
#
5+
# macOS only, since the DiskImages framework does all the heavy lifting.
6+
#
7+
8+
function usage() {
9+
if [ ! -z '$1' ]; then
10+
echo "\nERROR: $1\n"
11+
fi
12+
echo "usage: $0 [-o] [-p <pad MiB> | -s <size MiB>] <output file> <input directory>\n"
13+
echo " creates a FAT16 disk image in <output file> containing the files in <input directory>"
14+
echo " -o OK to replace <output file> if it exists"
15+
echo " -p <pad MiB> add padding to filesystem (min 5MiB)"
16+
echo " -s <size MiB> set filesystem size (must be large enough for files + 5MiB)"
17+
exit 1
18+
}
19+
20+
overwrite=1
21+
padsize=5
22+
fixsize=0
23+
24+
args=`getopt op:s: $*`
25+
if [ $? != 0 ]; then
26+
usage "invalid option(s)"
27+
fi
28+
set -- $args
29+
for i; do
30+
case "$i" in
31+
-o )
32+
overwrite=0
33+
shift;;
34+
-p )
35+
padsize=$2
36+
shift; shift;;
37+
-s )
38+
fixsize=$2
39+
shift; shift;;
40+
-- )
41+
shift; break;;
42+
esac
43+
done
44+
45+
if [ ! $# -eq 2 ]; then
46+
usage "missing argument(s)"
47+
fi
48+
if [ -e $1 ]; then
49+
if [ -f $1 ]; then
50+
if [ ! $overwrite ]; then
51+
usage "file $1 already exists"
52+
fi
53+
rm -f $1
54+
else
55+
usage "$1 exists and is not a file"
56+
fi
57+
fi
58+
if [ ! -d $2 ]; then
59+
usage "$2 not a directory or does not exist"
60+
fi
61+
62+
dirsize=`du -mLs $2 | cut -f 1`
63+
64+
if [ $fixsize -gt 0 ]; then
65+
if [ $fixsize -lt $dirsize ]; then
66+
usage "specified size $fixsize MiB too small, need $dirsize MiB"
67+
fi
68+
elif [ $padsize -gt 0 ]; then
69+
if [ $padsize -lt 5 ]; then
70+
usage "padding size less than 5 MiB not recommended"
71+
fi
72+
fixsize=`expr $dirsize + $padsize`
73+
else
74+
usage "must specify a non-zero padding size, or a fixed size"
75+
fi
76+
77+
echo "creating $fixsize MiB image $1 with contents from $2..."
78+
hdiutil create -megabytes $fixsize -layout MBRSPUD -fs "MS-DOS FAT16" -format UDIF -srcfolder $2 $1

0 commit comments

Comments
 (0)