#!/bin/sh
# Copyright 2004 Feuz Stefan.
# Copyright 2007 Adam Tkac.
# This file is part of mtools.
#
# Mtools is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Mtools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mtools. If not, see .
#
# amuFormat.sh Formats various types and sizes of PC-Cards, according to the
# AMU-specification
#
# parameters: $1: Card Type: The Card Type is written as disk/volume-label
# to the boot-record
# The string should have a length of max. 11 characters.
#
# $2: Drive character (b:, c:)
#
# 10-12-2003 lct created
#
global vers := '1.4'
#echo "debug: $0,$1,$2,$3,$4"
#
# main()
#
if test $Argc -ne 2 {
echo "Usage: amuFormat.sh " > !2
echo " has to be defined in amuFormat.sh itself" > !2
echo " has to be defined in mtools.conf" > !2
exit 1
}
echo "amuFormat $vers started..."
global drive := $2
matchstr $1 {
8MBCARD-FW {
## using the f: or g: drive for fat12 formatting...
## see mtools.conf file...
matchstr $2 {
[bB]: { global drive := '"f:'" }
[cC]: { global drive := '"g:'" }
* { echo "Drive $2 not supported."; exit 1 }
}
global cylinders := '245', heads := '2', cluster_size := '8'
}
32MBCARD-FW {
#from amu_toolkit_0_6:
#mformat -t489 -h4 -c4 -n32 -H32 -r32 -vPC-CARD -M512 -N0000 c:
global cylinders := '489', heads := '4', cluster_size := '4'
}
64MBCARD-FW {
echo "***** WARNING: untested on AvHMU, exiting *****"
exit 1
global cylinders := '245', heads := '2', cluster_size := '8'
}
1GBCARD-FW {
# from amu_toolkit_0_6:
#mformat -t2327 -h16 -c64 -n63 -H63 -r32 -v AMU-CARD -M512 -N 0000 c:
echo "***** WARNING: untested on AvHMU *****"
global cylinders := '2327', heads := '16', cluster_size := '64'
}
64MBCARDSAN {
# from amu_toolkit_0_6:
#mformat -t489 -h8 -c4 -n32 -H32 -r32 -v AMU-CARD -M512 -N 0000 c:
global cylinders := '489', heads := '8', cluster_size := '4'
}
#
# insert new cards here...
#
* {
echo "Card not supported."
exit 1
}
}
echo "Formatting card in slot $2 as $1"
## initialise partition table
mpartition -I $drive
# write a partition table
mpartition -c -t$cylinders -h$heads -s32 -b32 $drive
## write boot-record, two FATs and a root-directory
mformat -c$cluster_size -v $1 $drive
minfo $2
mdir $2
echo "done."
(CommandList
children: [
(Assignment
keyword: Assign_None
pairs: [(assign_pair lhs:(LhsName name:vers) op:Equal rhs:{(1.4)} spids:[87])]
spids: [87]
)
(If
arms: [
(if_arm
cond: [
(Sentence
child: (C {(Lit_Other "[")} {($ VSub_Pound "$#")} {(-ne)} {(2)} {(Lit_Other "]")})
terminator:
)
]
action: [
(SimpleCommand
words: [{(echo)} {(DQ ("Usage: amuFormat.sh "))}]
redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[127])]
)
(SimpleCommand
words: [{(echo)} {(DQ (" has to be defined in amuFormat.sh itself"))}]
redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[137])]
)
(SimpleCommand
words: [{(echo)} {(DQ (" has to be defined in mtools.conf"))}]
redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[147])]
)
(C {(exit)} {(1)})
]
spids: [-1 118]
)
]
spids: [-1 155]
)
(C {(echo)} {(DQ ("amuFormat ") ($ VSub_Name "$vers") (" started..."))})
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:drive)
op: Equal
rhs: {(DQ ($ VSub_Number "$2"))}
spids: [167]
)
]
spids: [167]
)
(Case
to_match: {(DQ ($ VSub_Number "$1"))}
arms: [
(case_arm
pat_list: [{(8MBCARD-FW)}]
action: [
(Case
to_match: {(DQ ($ VSub_Number "$2"))}
arms: [
(case_arm
pat_list: [{(Lit_Other "[") (bB) (Lit_Other "]") (Lit_Other ":")}]
action: [
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:drive)
op: Equal
rhs: {(DQ ("f:"))}
spids: [208]
)
]
spids: [208]
)
]
spids: [202 206 213 -1]
)
(case_arm
pat_list: [{(Lit_Other "[") (cC) (Lit_Other "]") (Lit_Other ":")}]
action: [
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:drive)
op: Equal
rhs: {(DQ ("g:"))}
spids: [222]
)
]
spids: [222]
)
]
spids: [216 220 227 -1]
)
(case_arm
pat_list: [{(Lit_Other "*")}]
action: [
(Sentence
child: (C {(echo)} {(DQ ("Drive ") ($ VSub_Number "$2") (" not supported."))})
terminator:
)
(C {(exit)} {(1)})
]
spids: [230 231 246 -1]
)
]
spids: [193 199 249]
)
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:cylinders)
op: Equal
rhs: {(245)}
spids: [252]
)
(assign_pair lhs:(LhsName name:heads) op:Equal rhs:{(2)} spids:[255])
(assign_pair
lhs: (LhsName name:cluster_size)
op: Equal
rhs: {(8)}
spids: [258]
)
]
spids: [252]
)
]
spids: [181 182 262 -1]
)
(case_arm
pat_list: [{(32MBCARD-FW)}]
action: [
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:cylinders)
op: Equal
rhs: {(489)}
spids: [276]
)
(assign_pair lhs:(LhsName name:heads) op:Equal rhs:{(4)} spids:[279])
(assign_pair
lhs: (LhsName name:cluster_size)
op: Equal
rhs: {(4)}
spids: [282]
)
]
spids: [276]
)
]
spids: [264 265 286 -1]
)
(case_arm
pat_list: [{(64MBCARD-FW)}]
action: [
(C {(echo)} {(DQ ("***** WARNING: untested on AvHMU, exiting *****"))})
(C {(exit)} {(1)})
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:cylinders)
op: Equal
rhs: {(245)}
spids: [304]
)
(assign_pair lhs:(LhsName name:heads) op:Equal rhs:{(2)} spids:[307])
(assign_pair
lhs: (LhsName name:cluster_size)
op: Equal
rhs: {(8)}
spids: [310]
)
]
spids: [304]
)
]
spids: [288 289 314 -1]
)
(case_arm
pat_list: [{(1GBCARD-FW)}]
action: [
(C {(echo)} {(DQ ("***** WARNING: untested on AvHMU *****"))})
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:cylinders)
op: Equal
rhs: {(2327)}
spids: [335]
)
(assign_pair
lhs: (LhsName name:heads)
op: Equal
rhs: {(16)}
spids: [338]
)
(assign_pair
lhs: (LhsName name:cluster_size)
op: Equal
rhs: {(64)}
spids: [341]
)
]
spids: [335]
)
]
spids: [316 317 345 -1]
)
(case_arm
pat_list: [{(64MBCARDSAN)}]
action: [
(Assignment
keyword: Assign_None
pairs: [
(assign_pair
lhs: (LhsName name:cylinders)
op: Equal
rhs: {(489)}
spids: [359]
)
(assign_pair lhs:(LhsName name:heads) op:Equal rhs:{(8)} spids:[362])
(assign_pair
lhs: (LhsName name:cluster_size)
op: Equal
rhs: {(4)}
spids: [365]
)
]
spids: [359]
)
]
spids: [347 348 369 -1]
)
(case_arm
pat_list: [{(Lit_Other "*")}]
action: [(C {(echo)} {(DQ ("Card not supported."))}) (C {(exit)} {(1)})]
spids: [380 381 396 -1]
)
]
spids: [173 179 398]
)
(C {(echo)} {(DQ ("Formatting card in slot ") ($ VSub_Number "$2") (" as ") ($ VSub_Number "$1"))})
(C {(mpartition)} {(-I)} {(DQ ($ VSub_Name "$drive"))})
(C {(mpartition)} {(-c)} {(-t) ($ VSub_Name "$cylinders")} {(-h) ($ VSub_Name "$heads")} {(-s32)}
{(-b32)} {(DQ ($ VSub_Name "$drive"))}
)
(C {(mformat)} {(-c) ($ VSub_Name "$cluster_size")} {(-v)} {(DQ ($ VSub_Number "$1"))}
{(DQ ($ VSub_Name "$drive"))}
)
(C {(minfo)} {(DQ ($ VSub_Number "$2"))})
(C {(mdir)} {(DQ ($ VSub_Number "$2"))})
(C {(echo)} {(DQ (done.))})
]
)