DOSFORMAT utility
Wolf N. Paul
wnp at dcs.UUCP
Sun Dec 18 16:15:21 AEST 1988
Here is my dosformat utility for Microport UNIX V/AT. The uuencoded
image files need to be decoded and placed in /usr/local/lib.
Enjoy!
-----
Wolf N. Paul * 3387 Sam Rayburn Run * Carrollton TX 75007 * (214) 306-9101
UUCP: killer!dcs!wnp ESL: 62832882
DOMAIN: dcs!wnp at killer.dallas.tx.us TLX: 910-380-0585 EES PLANO UD
--------CUT HERE--------
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: dosfdimg.dd.uu dosfdimg.hd.uu dosformat
# Wrapped by wnp at dcs on Mon Dec 19 00:09:14 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'dosfdimg.dd.uu' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dosfdimg.dd.uu'\"
else
echo shar: Extracting \"'dosfdimg.dd.uu'\" \(2958 characters\)
sed "s/^X//" >'dosfdimg.dd.uu' <<'END_OF_FILE'
begin 644 dosfdimg.dd.z
M'QX``"0`#`$!`````0(=&ALY``#V?`(@`0,&"@L-%B8S-C="36%E:6MN;W)S
M='V*BZ'-Z_<%!Q@>*CL]1$E/4V1P>:.JN;N^P,/2Z//]_PX0$QD<'RLN,CD\
M/T!#3FQUB(^FK+2XT-C[_ at 0)#`\1&B(H+31'2%!255987F-F9VAM=G=X?X"&
MB8V.D):8H**QM[R_PL3%Q\K/V>+DYNGJ\?+Z_!4V`4"$2$Q.=.D82!+.'!N<
M%$-#@T.0!3G__^`3QN#@C%X(`T!1/(0Z+0-20%A*'P($(F!2$9XL'X.0Q(@.
M"*8#A$9!P5F0*P8 at V'0B`\`LX"T.A&>&QJ#Y<!4$@/'@C-R(A/'!T(3QP=!T
M\5!0>*B4\,SLW(@"GF8?'SQP8`,-QF-CI*>+8<-`H/&0(H9C9P9"N7!`9AL+
M!^+C4Q&88!:0`?`V=%P:F(L'XS#`P#PN+#$9%$)09&I"!((@O`"%XC.&H0"X
M$YB;&QH$(<(QB;D@^>&XO!*$YYH2GBH1'BV'30E/&04S0/'B`=$)X4 at -&05P
M(EP+P$#H3G at 8`&-CI*>;D0^>.!J;`P, at D``/,B$:&)F'Q$>#7%$,1X7F`!PR
M!T6AV:@\;`W(QB;D@>/#<%07$(A/(QB;D@!CPN(1`>*@F/&`9'#,A"8\$PZ,
M09CQ((3S,%P'0:&1"-#$R)!`>:@^,"`>"LM+`$B84EY at 4@7.B<J+RLZ6EQT3
ME1>5G2DN+BTN(!X!Q2*`L*`)E)TH+!.=+S`N*BLI.E!8*3I64BDZ!D"Q26'2
MXI*!.*2`>D`\(RHO*SI,6EI@=`H4%06!:7%)`/1(3$Y,)!*=.A4)2<2$Q.(Q
M*)CIT*A*3____\!XK&@U&O______________________________________
M____________________________________________________________
M____________________________________________________________
M___________\:#4:____________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M___]55555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
M555555555555555555555555555555555555555555555555555555555555
X(55555554`$!5
X`
end
END_OF_FILE
if test 2958 -ne `wc -c <'dosfdimg.dd.uu'`; then
echo shar: \"'dosfdimg.dd.uu'\" unpacked with wrong size!
fi
# end of 'dosfdimg.dd.uu'
fi
if test -f 'dosfdimg.hd.uu' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dosfdimg.hd.uu'\"
else
echo shar: Extracting \"'dosfdimg.hd.uu'\" \(3578 characters\)
sed "s/^X//" >'dosfdimg.hd.uu' <<'END_OF_FILE'
begin 644 dosfdimg.hd.z
M'QX``#P`"P$!`````@$8'AXZ`/8@?'(!`@8*"PT6)C8W0DUA96EN;W1]BJ'-
MZ_<#!0<8'BHS.SU$24]39&MS>8NCJKF[OL##TNCS^?\.#Q`3&1H<'RLN,CD\
M/T!#3FQP=8B/IJRTN-C[_?X$"0P1%2(H+31'2%!255987F!C9F=H;79W>'^`
MAHF-CI"6F*"BL;>\O\+$Q<?*S]#9X.+DYNGJ\?+Z_#0!`(!04%)QPD"<*(^/
M#T?!C`B`$=""#\?___P?\>@Y$@U`^"\$\\D$`S`S)@5DXB`<2"H%`3'C(B at Z
M#4E`V)I>'B4Q#XQ,05`R!N0!*!T!(^"P0!,>')F$)L"@(P@/!$:DI(>'B`)#
MP\0`\>,`K/&!.>&YTU)0!GB\1$1X>&P"C4<CQ`3GC.'S(*SQP"&&X\/C at 8S8
M1"\.1D11H9F`Y#0,2,#P&CAH'!@,B*.0T+Q"-"TP'!5"@&9F2`0"4,P`!F)Q
M\S"(:`F,#0T, at D#XD&YJ3$1X=C4$@5'F1.>,!,>,X@,B<\<!9,A">(R`2GA8
M`L<!=`>;!<`8@"H\"X`AX@)SS4E(CP\'!H#`Q"<`AYB2!T8"\1"8\&V&$-2$
M:EX!0V!X9B"9A`:`X$@W-280GAV"D,B02GB0;FI,$9X9$@C/&`4GC8-A\7D@
M4G at E(!N#0A)A*>+P6@<!J8D@=&!B3",\S"$;$9"%Q<6@'%0N%I>5 at 6.%98+1
M8<7&SA66"T6'%9LV7&R,A`85A@%Y4!(K.*BT5G"TO-E at L*SBHM%QPL*Q<<!@
M"I66G&RLJ%8N(R&1D(G+!:+#B at N+B\X"946!>&)LK(R&*"@I*!0*3C at M%)2*
M"@I$XI%1QP6BDI____X#1B.AV.__________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M_______________________CH=CO________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M____________________________________________________________
M___________________JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
X)JJJJJJJJJJ#L
X`
end
END_OF_FILE
if test 3578 -ne `wc -c <'dosfdimg.hd.uu'`; then
echo shar: \"'dosfdimg.hd.uu'\" unpacked with wrong size!
fi
# end of 'dosfdimg.hd.uu'
fi
if test -f 'dosformat' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'dosformat'\"
else
echo shar: Extracting \"'dosformat'\" \(10257 characters\)
sed "s/^X//" >'dosformat' <<'END_OF_FILE'
X:
X# dosfmt -- format a DOS floppy on Microport UNIX V/AT
X#
X# Dec. 18, 1988 by Wolf N. Paul
X#
X# This program may be freely copied and used for any purpose;
X# I would appreciate it if my name were retained, but have no way
X# of enforcing this.
X#
X# No warranties or promises are made regarding the performance
X# of this program; use at your own risk.
X#
X#
X# Usage: dosformat [#] [xx]
X# dosformat X:
X# Where: # is the drive number ( 0 = A:, 1 = B:)
X# xx is the disk type (DD = 360K, HD = 1.2M,
X# QD = 720K, XD = 1.44M)
X# X: is a DOS-style drive specification, i.e. A: or B:, etc.
X#
X# None of the options are case sensitive. If Drive Number is not given,
X# default is 0.
X# If Disk Type is not given, default is HD for Drive 0, and DD for
X# Drive 1.
X# If DOS-style drive spec is given, drive number and type are determined
X# from the entries in /dev/dos.
X#
X# Please note that 360K disks formatted in an AT-type drive will not always
X# work reliably in an XT-type drive.
X#
X# As written, this program assumes that you have entries for your
X# floppy disks as follows:
X#
X# /dev/rdsk/fd0dd 360K floppy installed as drive 0
X# /dev/rdsk/fd0hd 1.2M floppy installed as drive 0
X# /dev/rdsk/fd0qd 720K floppy installed as drive 0
X# /dev/rdsk/fd0xd 1.44M floppy installed as drive 0
X#
X# and alternately, the same names with a '1' instead of the '0' if you
X# have any of these installed as drive 1.
X#
X# Note that on Microport V/AT, floppies have more complicated names; you need
X# to make links with the above names to the appropriate Microport names.
X# I find these names easier to use than the default names.
X#
X# Note also that you can have multiple entries for the same physical drive;
X# for example, the standard AT drive 0 can have entries as fd0dd, fd0qd, and
X# fd0hd, to format to 360K, 720K, and 1.2 MB respectively.
X#
X# I have been successful in formatting normal DD diskettes to 720K; these should
X# be readable under DOS in an AT drive.
X#
X# If you wish to use the DOS-style drive specification (see usage message), you
X# also need links for each of your drives in /dev/dos. Microport recommends
X# /dev/dos/A for the AT drive 1, and /dev/dos/B for either drive 0, 360K on
X# a single drive system, or for drive 1, whatever, on dual-drive systems.
X# The Microport manual page for DOSDIR suggest that these should be links
X# to the fd* entries in /dev/dsk; however, for hard disk DOS partitions they
X# suggest that links be made to entries in /dev/rdsk. I suggest that /dev/rdsk
X# devices are more appropriate for the floppy entries, as well. Actually, the
X# Microport distribution disks have links in /dev/dos to the devices in
X# /dev/rdsk, so the manual probably is wrong.
X# Note that since these are in effect file names, you need to make similar
X# links with lower case names if you do not wish to use the shift key when
X# specifying the drive to the dos* utilities.
X#
X# The program works by formatting the disk with the Microport /etc/format
X# command, which does a low-level format, and then copying an image of track 1
X# of the appropriate DOS file system onto the disk. The DOS file system images
X# are stored in packed form; if your system has a faster or more efficient
X# compression program, you can unpack and recompress the image files, and change
X# the invocation of "pcat" towards the end of the program to whatever will
X# uncompress a file to the standard output on your system.
X#
X# Currently, I provide image files for HD and DD diskettes (dosfdimg_hd.z and
X# dosfdimg_dd.z); since I don't currently have 3.5" drives in my machine, I
X# could not conveniently produce the appropriate images for these disks. The
X# procedure to produce the images is simple:
X#
X# Format an appropriate disk using DOS, and then read the first track from that
X# disk using "dd" as follows:
X#
X# (Assuming a 1.44M 3.5" floppy (type XD)):
X#
X# dd if=/dev/rdsk/fd0xd of=/usr/local/lib/dosfdimg_xd bs=18k
X#
X# Then pack it (or compress using some other utility, see above):
X#
X# pack dosfdimg_xd
X#
X# This will produce a file dosfdimg_xd.z.
X#
X# If you wish to speed up the program, and have plenty of hard disk space,
X# you can of course store the image files uncompressed and change the
X# appropriate line towards the very end of this program.
X#
X# ERROR HANDLING:
X#
X# This refers specifically to the handling of bad sectors. If the first
X# attempt to format the disk fails, the format is repeated. If the first
X# attempt to write the DOS image fails, the format is also repeated. I have
X# noticed that this sometimes helps on Microport V/AT systems. If the
X# diskette still produces errors after the second format, it is rejected,
X# since UNIX cannot map bad sectors on a DOS disk. You may still be able
X# to use this disk on a DOS system, since DOS will simply map and not use
X# the bad sectors. I usually throw them away, since it is more hassle than
X# a disk is worth to try and keep them separate.
X
X
usage() {
X echo "
Usage: dosformat [#] [xx]
X dosformat X:
Where: # is the drive number ( 0 = A:, 1 = B:)
X xx is the disk type (DD = 360K, HD = 1.2M,
X QD = 720K, XD = 1.44M)
X X: is a DOS-style drive specification, i.e. A: or B:, etc.
X
None of the options are case sensitive. If Drive Number is not given,
default is 0.
If Disk Type is not given, default is HD for Drive 0, and DD for
Drive 1.
If DOS-style drive spec is given, drive number and type are determined
from the entries in /dev/dos.
X
Please note that 360K disks formatted in an AT-type drive will not always
work reliably in an XT-type drive.\n"
X exit
X}
X
X# Check number of arguments ...
case $# in
X 0)
X# if no args, use defaults (drive 0, 1.2M)
X DRIVNUM=0 ; DRIVLET=A ; DRIVTYP=HD
X echo "DOSFORMAT: No parameters given, using defaults."
X echo " Use \"dosformat -h\" for help on parameters." ;;
X
X 1)
X# if one arg, we assume its the drive number if it is numeric, a drive letter
X# if it ends in a colon, or the drive type otherwise.
X case $1 in
X 0 ) DRIVNUM=0 ; DRIVLET=A ; DRIVTYP=HD ;;
X 1 ) DRIVNUM=1 ; DRIVLET=B ; DRIVTYP=HD ;;
X HD|hd) DRIVNUM=0 ; DRIVLET=A ; DRIVTYP=HD ;;
X DD|dd) DRIVNUM=0 ; DRIVLET=A ; DRIVTYP=DD ;;
X QD|qd) DRIVNUM=0 ; DRIVLET=A ; DRIVTYP=QD ;;
X XD|xd) DRIVNUM=0 ; DRIVLET=A ; DRIVTYP=XD ;;
X
X# This next section determines drive number and drive type from the
X# entries in /dev/dos, which allow specification of disk drives to the
X# doscp and dosdir utilities in MS-DOS style, i.e. "A:". We use the minor
X# device number of the specified device file to determine its number and
X# capacity; currently, I have no info on the appropriate minor device
X# numbers of 3.5" floppies installed as drive 1. I hope that this info
X# will shortly be posted to comp.unix.microport; for XENIX users [ :-( ],
X# you will have to substitute your system's minor numbers, anyway -- if
X# Xenix supports a similar scheme for access to DOS volumes.
X# Anyway, this lets you say "dosformat a:", and let the system figure out
X# what the parameters are. Of course, you are still responsible for putting
X# the right type of floppy into the drive.
X
X *:)
X# strip off the colon
X LET=`echo $1 | tr -d ':'`
X# Is there a character device special file $LET?
X if [ -c /dev/dos/$LET ] ; then
X# if so, parse the info for $LET
X set `ls -l /dev/dos/$LET`
X else
X# else, quit.
X echo Non-existent Drive ; usage
X fi
X# Check Major Device number: Floppy is 6
X if [ "$5" != "6," ] ; then
X echo "$LET: is not a floppy drive!"
X exit -1
X fi
X# Check Minor Device number
X case $6 in
X 70) DRIVNUM=0 ; DRIVLET=$LET ; DRIVTYP=HD ;;
X 23) DRIVNUM=0 ; DRIVLET=$LET ; DRIVTYP=DD ;;
X 78) DRIVNUM=1 ; DRIVLET=$LET ; DRIVTYP=HD ;;
X 91) DRIVNUM=1 ; DRIVLET=$LET ; DRIVTYP=DD ;;
X 119) DRIVNUM=0 ; DRIVLET=$LET ; DRIVTYP=QD ;;
X 102) DRIVNUM=0 ; DRIVLET=$LET ; DRIVTYP=XD ;;
X *) echo Unsupported Drive Type ; usage ;;
X esac ;;
X# Unrecognized arg
X * ) usage ;;
X esac ;;
X
X# If there are two arguments ...
X# the first arg is supposed to be the drive number, the second the type.
X 2) case $1 in
X 0 ) DRIVNUM=0 ; DRIVLET=A ; DRIVTYP=$2 ;;
X 1 ) DRIVNUM=1 ; DRIVLET=B ; DRIVTYP=$2 ;;
X * ) usage ;;
X esac ;;
X
X# If there are more than two args ...
X *) usage ;;
esac
X
X# Set up parameters for the drive types:
X
case $DRIVTYP in
X
X# HD drives have 15 sectors of 512k per track; since there are two sides,
X# each track is actually 15k. There are 80 tracks (cylinders).
X HD|hd) DRIVTYP=HD ; BLOCKSIZE=15k ; CAPACITY="1.2 MB" ;;
X
X# DD drives have 9 sectors of 512k per track; since there are two sides,
X# each track is actually 9k. There are 40 tracks (cylinders).
X DD|dd) DRIVTYP=DD ; BLOCKSIZE=9k ; CAPACITY="360 kB" ;;
X
X# QD drives have 9 sectors of 512k per track; since there are two sides,
X# each track is actually 9k. There are 80 tracks (cylinders).
X QD|qd) DRIVTYP=QD ; BLOCKSIZE=15k ; CAPACITY="720 kB" ;;
X
X# XD drives have 18 sectors of 512k per track; since there are two sides,
X# each track is actually 18k. There are 80 tracks (cylinders).
X XD|xd) DRIVTYP=XD ; BLOCKSIZE=18k ; CAPACITY="1.44 MB" ;;
X
X# This should not be necessary ...
X * ) usage ;;
esac
X
X
X# Build the necessary pathnames ...
DEVICE=/dev/rdsk/fd${DRIVNUM}${DRIVTYP}
IMAGE=/usr/local/lib/dosfdimg_${DRIVTYP}
X
X# Verify parameters with the user ...
echo "DOSFORMAT: Format drive ${DRIVLET}: for ${CAPACITY}? (y/n) \c"
read reply
case $reply in
X N*|n*) exit ;;
X * ) ;;
esac
X
X# And go, do the format!
echo "Low-level format:"
if /etc/format $DEVICE ; then
X echo "Writing DOS information:"
X if pcat $IMAGE | dd of=$DEVICE bs=$BLOCKSIZE ; then
X echo "\nFormat successful.\n"
X exit 0
X fi
else # I have noticed that sometimes formatting twice helps!
X echo Error during first low-level format, trying again!
X if /etc/format $DEVICE ; then
X echo "Writing DOS information:"
X if pcat $IMAGE | dd of=$DEVICE bs=$BLOCKSIZE ; then
X echo "\nFormat successful.\n"
X exit 0
X fi
X else
X echo "Repeated errors during low-level format."
X echo "Most likely your diskette has bad sectors. Use it on"
X echo "a DOS machine only, UNIX cannot map bad sectors on DOS disks."
X echo "\n\007Format NOT successful."
X fi
fi
X
END_OF_FILE
if test 10257 -ne `wc -c <'dosformat'`; then
echo shar: \"'dosformat'\" unpacked with wrong size!
fi
chmod +x 'dosformat'
# end of 'dosformat'
fi
echo shar: End of shell archive.
exit 0
--------THE END--------
--
Wolf N. Paul * 3387 Sam Rayburn Run * Carrollton TX 75007 * (214) 306-9101
UUCP: killer!dcs!wnp ESL: 62832882
DOMAIN: dcs!wnp at killer.dallas.tx.us TLX: 910-380-0585 EES PLANO UD
More information about the Alt.sources
mailing list