File: fdformat

package info (click to toggle)
fdutils 5.3-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,004 kB
  • ctags: 621
  • sloc: ansic: 6,098; sh: 2,236; makefile: 279; sed: 4
file content (55 lines) | stat: -rw-r--r-- 1,182 bytes parent folder | download | duplicates (4)
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
#!/bin/sh
#
# Shell script to simulate fdformat by using superformat.
# (C) 1996 Michael Meskes <meskes@informatik.rwth-aachen.de>
# Placed under GPL.
#
# Modified by (C) 1997 Anthony Fok <foka@gpu.srv.ualberta.ca> for fdutils-5.x
# Also placed under GPL v2 or later.  :)

set -e -u

#
# shall we verify?
#

if [ ! $1 ]
then
	echo "Usage: $0 [ -n ] device"
	exit 1
elif [ $1 = "-n" ]
then
	shift 1
	args="--noverify"
else
	args="--verify_later"
fi

#
# calculate parameters
#

format=`getfdprm -a $1`

capacity=`expr "'$format'" : '.* size=\([[:digit:]]\+\)'`
capacity=`expr $capacity / 2`
sectors="`expr "'$format'" : '.* sect=\([[:digit:]]\+\)'` sec" || \
	sectors=`expr "'$format'" : '.* tracksize=\([[:alnum:]]\+\)'`

heads=`echo $format | cut -d' ' -f1 | tr '[:lower:]' '[:upper:]'`
tracks=`expr "'$format'" : '.* cyl=\([[:digit:]]\+\)'`

#device=`echo $1|sed -e 's/\/dev\/fd//' -e 's/\(u\|h\|H\|d\|D\|E\)[0-9]\+$//'`
device=`expr $1 : '/dev/fd\([[:digit:]]\+\)'`

args="$args /dev/fd$device $format"

headtext="Sing"
if [ $heads = "DS" ]
then
	headtext="Doub"
fi

echo ${headtext}le-sided, ${tracks} tracks, ${sectors}/track. Total capacity ${capacity} kB.

superformat $args