-
Notifications
You must be signed in to change notification settings - Fork 4
/
s3floppy
executable file
·68 lines (63 loc) · 1.41 KB
/
s3floppy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
FLOPPY=/dev/fd0
CYL=80
SSIZE=1024
SECT=10
SIZE=$(($CYL*$SSIZE*$SECT*2))
check_bin ()
{
if [ x"$(which $1)" = x ]; then
echo "$1 not found"
exit 1
fi
}
setup_floppy ()
{
check_bin fdrawcmd
check_bin setfdprm
fdrawcmd dumpregs > /dev/null 2>&1
setfdprm -p "$FLOPPY" sect=$SECT hd ssize=$SSIZE cyl=$CYL
}
print_help ()
{
echo "Usage: $(basename $0) {read,write,format} [file]"
echo
echo " For modes read and write, if no file is given on the commandline,"
echo " /dev/stdout and /dev/stdin will be used, respectively."
echo " For mode format, all other arguments will be ignored."
}
case "$1" in
write)
shift
INPUT=/dev/stdin
if [ x"$1" != x ]; then
INPUT="$1"
TXTFILE=`echo "$1" | rev | cut -c 5- | rev`.txt
if [ -e "$TXTFILE" ]; then
uniq "$TXTFILE"
fi
fi
setup_floppy
dd if="$INPUT" bs=$SIZE count=1 of="$FLOPPY"
break
;;
read)
shift
OUTPUT=/dev/stdout
if [ x"$1" != x ]; then
OUTPUT="$1"
fi
setup_floppy
dd of="$OUTPUT" bs=$SIZE count=1 if="$FLOPPY"
break
;;
format)
check_bin superformat
superformat "$FLOPPY" sect=$SECT hd ssize=$SSIZE cyl=$CYL
break
;;
*)
print_help
break
;;
esac