Imported Upstream version 4.0.43
[platform/upstream/mtools.git] / scripts / amuFormat.sh
1 #!/bin/sh
2 # Copyright 2004 Feuz Stefan.
3 # Copyright 2007 Adam Tkac.
4 # This file is part of mtools.
5 #
6 # Mtools is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Mtools is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Mtools.  If not, see <http://www.gnu.org/licenses/>.
18 #
19 #  amuFormat.sh  Formats various types and sizes of PC-Cards, according to the
20 #  AMU-specification
21 #
22 #  parameters:   $1:   Card Type: The Card Type is written as disk/volume-label
23 #                      to the boot-record
24 #                      The string should have a length of max. 11 characters.
25 #
26 #                $2:   Drive character (b:, c:)
27 #
28 #  10-12-2003    lct   created
29 #
30 vers=1.4
31
32 #echo "debug: $0,$1,$2,$3,$4"
33
34 #
35 # main()
36 #
37 if [ $# -ne 2 ] ; then
38         echo "Usage: amuFormat.sh <Card Type> <drive>" >&2
39         echo "<Card Type> has to be defined in amuFormat.sh itself" >&2
40         echo "<drive> has to be defined in mtools.conf" >&2
41         exit 1
42 fi
43
44 echo "amuFormat $vers started..."
45
46 drive="$2"
47
48 case "$1" in
49 8MBCARD-FW)
50         ## using the f: or g: drive for fat12 formatting...
51         ## see mtools.conf file...
52         case "$2" in
53         [bB]:) drive="f:" ;;
54         [cC]:) drive="g:" ;;
55         *) echo "Drive $2 not supported."; exit 1 ;;
56         esac
57         cylinders=245 heads=2 cluster_size=8
58         ;;
59 32MBCARD-FW)
60         #from amu_toolkit_0_6:
61         #mformat -t489 -h4 -c4 -n32 -H32 -r32 -vPC-CARD -M512 -N0000 c:
62         cylinders=489 heads=4 cluster_size=4
63         ;;
64 64MBCARD-FW)
65         echo "***** WARNING: untested on AvHMU, exiting *****"
66         exit 1
67         cylinders=245 heads=2 cluster_size=8
68         ;;
69 1GBCARD-FW)
70         # from amu_toolkit_0_6:
71         #mformat -t2327 -h16 -c64 -n63 -H63 -r32 -v AMU-CARD -M512 -N 0000 c:
72         echo "***** WARNING: untested on AvHMU *****"
73         cylinders=2327 heads=16 cluster_size=64
74         ;;
75 64MBCARDSAN)
76         # from amu_toolkit_0_6:
77         #mformat -t489 -h8 -c4 -n32 -H32 -r32 -v AMU-CARD -M512 -N 0000 c:
78         cylinders=489 heads=8 cluster_size=4
79         ;;
80 #
81 # insert new cards here...
82 #
83 *)
84         echo "Card not supported."
85         exit 1
86         ;;
87 esac
88
89 echo "Formatting card in slot $2 as $1"
90
91 ## initialise partition table
92 mpartition -I "$drive"
93
94 # write a partition table
95 mpartition -c -t$cylinders -h$heads -s32 -b32 "$drive"
96
97 ## write boot-record, two FATs and a root-directory
98 mformat -c$cluster_size -v "$1" "$drive"
99
100 minfo "$2"
101 mdir  "$2"
102
103 echo "done."