Path: utzoo!utgpu!watmath!uunet!shelby!bloom-beacon!tut.cis.ohio-state.edu!att!cbnewsc!psfales
From: psfales@cbnewsc.ATT.COM (Peter Fales)
Newsgroups: unix-pc.general
Subject: Re: foreign floppies on the 3b1
Message-ID: <1580@cbnewsc.ATT.COM>
Date: 6 Jul 89 22:46:38 GMT
References: <730@biar.UUCP>
Organization: AT&T Bell Laboratories
Lines: 64

In article <730@biar.UUCP>, jhood@biar.UUCP (John Hood) writes:
> 
> Would somebody please explain how the floppies are laid out, what the
> two floppy devices do and what they're for, and how to get around the
> volume header block for 3b1 <-> PC-family disk transfer?  (I vaguely
> recall that there is a utility out there that specifically handles
> PC-Unix style disks, but we didn't have it, and it would be nice to
> know a way to do without it.)

I am perhaps not the best person to answer this, but I think I can shed
a little light on the issue.  When the 3b1 opens the floppy device, it
reads the first two sectors on the disk and looks for a magic number.
If it finds it, it loads the Volume Header Block (VHB) into memory.  The
VHB contains information about the physical layout of the disk (heads,
cylinders, etc), and the logical format (partition sizes).  If the driver
it does not find a VHB on the disk, it initializes the in-memory copy
to some default values (1 head, and 1 cylinder), and expects you to
change them via an ioctl.  John Milton posted an example of how to
read non-standard disks this way a while back.

As you surmise, /dev/rfp020 is the entire disk.   Also, as you discovered
writing to this partition is a no-no, as it overwrites the VHB.  Reading
from it is OK though.  You may find it useful to compare an 'od -x' with
the information in /usr/include/sys/gdisk.h.

/dev/rfp021 is the partition which does not include the loader and VHB.
This varies depending on the information on the VHB, but for the
no-loader case (fdfmt.nl), it starts with head 1, cylinder 0, sector 8.
For other types of disks, you can view the disk layout by with
'iv -tv /dev/rfp020'

I would transfer files to a PC by writing them to /dev/rfp021 on the
unix-pc.  On the PC side I would use

dd if=/dev/XXX skip=8  | cpio -icv ( or whatever)

where /dev/XXX is the 40 track, double sided, 8 sector floppy device.
The skip=8 skips over the eight 512-byte sectors containing the VHB and
loader.

> And does anyone know whether the 3B1 is particular about the contents
> of the disks fed to it, to the point of tripping over itself and
> panicking on ones it doesn't like?

To the best of my knowledge, it will not.  Normally, you are safe
because the 3b1 will recognize a foreign disk by its magic number.  If
for some reason you had a disk with a valid magic number, you will get
funny numbers for heads, cylinders, etc. that will confuse the floppy
disk hardware, but I don't think it would panic.   I am not going to
go try the experiment on my own machine though :-)

> And a final note: I suspect that the reason the machine lost files may
> have been that the lost+found directory was not large enough to
> accommodate all the recovered files, and fsck automatically threw
> files away.  It was only 1024 bytes or 32 files long.  Make sure your
> lost+found directory is at least as large as the largest directory on
> your system; it's cheap insurance.

Good idea!!
-- 
Peter Fales			AT&T, Room 5B-420
				2000 N. Naperville Rd.
UUCP:	...att!ihlpb!psfales	Naperville, IL 60566
Domain: psfales@ihlpb.att.com	work:	(312) 979-8031