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