Program to access raw floppies
John B. Milton
jbm at uncle.UUCP
Sun Feb 19 16:35:41 AEST 1989
This program gets at the disk the same way mtools does. I whipped this up in
about an hour (including research into mtools) to copy some raw tar stuff off
of some XENIX floppies. It's all extreamly clear-cut. The switch after the
getopt() and gd(7) should be the only other docs you'll need :)
This program was needed because the XENIX disk are VERY raw, in that they do
not have a VHB on them, just data. When we do the typical "</dev/rfp021", we
must use UNIXpc formatted floppies.
I leave it to someone else to refine this to write "very raw" disk. While
you're doing that, I'll be writing a util to format nine (9) sector disks and
other fun things...
John
--
John Bly Milton IV, jbm at uncle.UUCP, n8emr!uncle!jbm at osu-cis.cis.ohio-state.edu
(614) h:294-4823, w:764-2933; Got any good 74LS503 circuits?
---
#! /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: rflp.c
# Wrapped by jbm at uncle on Sun Feb 19 01:28:25 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'rflp.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'rflp.c'\"
else
echo shar: Extracting \"'rflp.c'\" \(2199 characters\)
sed "s/^X//" >'rflp.c' <<'END_OF_FILE'
X/* vi:set ts=2 sw=2: */
X
X#include <fcntl.h>
X#include <stdio.h>
X#include <string.h>
X#include <sys/gdioctl.h> /* includes sys/gdisk.h */
X
Xextern int errno;
Xextern int optind;
Xextern char *optarg;
X
X#define LINESIZE 200
X
Xchar *me;
Xint Cyls=40,Debug=0,Intrl=1,Sects=9,Size=512,Tracks=2;
X
Xstatic void shgdctl(gdctl)
Xstruct gdctl *gdctl;
X{
X fprintf(stderr,"stat:%x, dsktyp:%d\n",(unsigned int)gdctl->status,gdctl->dsktyp);
X fprintf(stderr,"name:%6.6s, cyls:%d, heads:%d, psectrk:%d, pseccyl:%d, flags:%x, step:%d, sectorsz:%d\n",gdctl->params.name,gdctl->params.cyls,gdctl->params.heads,gdctl->params.psectrk,gdctl->params.pseccyl,gdctl->params.flags,gdctl->params.step,gdctl->params.sectorsz);
X}
X
Xstatic void proc()
X{
X int f,len;
X struct gdctl gdctl;
X char buf[10240];
X
X if (Debug)
X fprintf(stderr,"opening...\n");
X if ((f=open("/dev/rfp020",O_RDONLY))==-1)
X qperrorf("%s: open /dev/rfp020",me);
X if (Debug)
X fprintf(stderr,"open, doing GDGETA...\n");
X if (ioctl(f,GDGETA,&gdctl)==-1)
X qperrorf("%s: ioctl GDGETA",me);
X if (Debug)
X fprintf(stderr,"done.\n");
X if (Debug)
X shgdctl(&gdctl);
X /* gdctl.params.name */
X gdctl.params.cyls=Cyls;
X gdctl.params.heads=Tracks;
X gdctl.params.psectrk=Sects;
X gdctl.params.pseccyl=Sects*Tracks;
X gdctl.params.flags=1;
X gdctl.params.step=0;
X gdctl.params.sectorsz=Size;
X if (ioctl(f,GDSETA,&gdctl)==-1)
X qperrorf("%s: ioctl GDGETA",me);
X if (Debug)
X shgdctl(&gdctl);
X while ((len=read(f,buf,Size))==Size)
X write(1,buf,Size);
X if (len==-1)
X perrorf("%s: read error",me);
X close(f);
X}
X
Xstatic char *usage="Usage: %s [-{c}ylinders n] [-{i}nterleave n] [-{s}ectors n] [-{t}racks n] [-sector_si{z}e n]\n";
X
Xint main(argc,argv)
Xint argc;
Xchar *argv[];
X{
X int opt;
X
X (me=strrchr(argv[0],'/'))==NULL?me=argv[0]:me++;
X while ((opt=getopt(argc,argv,"c:di:s:t:z:?"))!=EOF)
X switch (opt) { /* optarg, optind */
X case 'c':
X Cyls=atoi(optarg);
X break;
X case 'd':
X Debug=1;
X break;
X case 'i':
X Intrl=atoi(optarg);
X break;
X case 's':
X Sects=atoi(optarg);
X break;
X case 't':
X Tracks=atoi(optarg);
X break;
X case 'z':
X Size=atoi(optarg);
X break;
X case '?':
X default:
X fprintf(stderr,usage,me);
X exit(1);
X }
X proc();
X}
END_OF_FILE
if test 2199 -ne `wc -c <'rflp.c'`; then
echo shar: \"'rflp.c'\" unpacked with wrong size!
fi
# end of 'rflp.c'
fi
echo shar: End of shell archive.
exit 0
More information about the Unix-pc.sources
mailing list