The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] why does tar have the tape device hard coded into it and why is it mt1 instead of mt0
@ 2015-12-11 22:27 Will Senn
  2015-12-11 22:31 ` Clem Cole
  0 siblings, 1 reply; 14+ messages in thread
From: Will Senn @ 2015-12-11 22:27 UTC (permalink / raw)


All,

In my exploration of v6, I followed the advice in "Setting up Unix - 
Seventh Edition" and copied v6tar from v7 to v6. Life is good. However, 
tar is using mt1 and it is hard coded into the source, tar.c:
char    magtape[]       = "/dev/mt1";

As the subject line suggested, I have two questions for those of you who 
might know:

1. Why is it hard coded?
2. Why is it the second device and not the first?

Interestingly, it took me a little while to figure out it was doing this 
because I didn't actually move files between v6 and v7 until today. 
Before this my tests had been limited to separate tests on v6 and v7 
along the lines of:

cd /wherever
tar c .
followed by
tar t
list of files
cd /elsewhere
tar x
files extracted and matching

What it was doing was writing to the non-existant /dev/mt1, which it 
then created, tarring up stuff, and exiting. Then when I listed the 
contents of the tarfile, or extracted the contents, it was successful. 
But, when I went to move the tape between v6 and v7, the tape (mt0) was 
blank, of course. It was at this point that I followed  Noel's advice 
and "Used the source", and figured out that it was hard-coded as you see 
above.

Thanks,

Will



^ permalink raw reply	[flat|nested] 14+ messages in thread
* [TUHS] why does tar have the tape device hard coded into it and why is it mt1 instead of mt0
@ 2015-12-12  2:09 Doug McIlroy
  2015-12-12 18:54 ` Mary Ann Horton
  0 siblings, 1 reply; 14+ messages in thread
From: Doug McIlroy @ 2015-12-12  2:09 UTC (permalink / raw)



> I have no memory of why Ken used mt1 not mt0.   Doug may know.

I don't know either. Come to think of it, I can't remember ever
using tar without option -f. Direct machine-to-machine trasfer,
e.g. by uucp, took a lot of business away from magtape soon
after tar was introduced. Incidentally, I think tar was written
by Chuck Haley or Greg Chesson, not Ken.

Doug



^ permalink raw reply	[flat|nested] 14+ messages in thread
* [TUHS] TUHS] why does tar have the tape device hard coded into it and why is it mt1 instead of mt0
@ 2015-12-12 17:17 Doug McIlroy
  2015-12-12 20:17 ` [TUHS] " Diomidis Spinellis
  0 siblings, 1 reply; 14+ messages in thread
From: Doug McIlroy @ 2015-12-12 17:17 UTC (permalink / raw)


Forget that I said, "I think that tar was written by Chuck Haley or Greg Chesson".
Ken confirms that he wrote it, for dectape.

Doug



^ permalink raw reply	[flat|nested] 14+ messages in thread
* [TUHS] why does tar have the tape device hard coded into it and why is it mt1 instead of mt0
@ 2015-12-13  1:41 Norman Wilson
  2015-12-13  3:04 ` Lyndon Nerenberg
  0 siblings, 1 reply; 14+ messages in thread
From: Norman Wilson @ 2015-12-13  1:41 UTC (permalink / raw)


/dev/makefile on the V7 distribution tape (or at least the
unpacked image I have that I believe to be same) says:

ht:
	/etc/mknod mt0 b 7 64
	/etc/mknod mt1 b 7 0
	/etc/mknod rmt0 c 15 64
	/etc/mknod rmt1 c 15 0
	/etc/mknod nrmt0 c 15 192
	/etc/mknod nrmt1 c 15 128
	chmod go+w mt0 mt1 rmt0 rmt1 nrmt0 nrmt1

According to /usr/sys/dev/ht.c, the minor device
number was used as follows:

minor(dev) & 07		slave unit number
minor(dev) & 070	controller unit number
minor(dev) & 0100	tape density: set == 800 bpi, clear 1600
minor(dev) & 0200	no-rewind flag

It takes some digging in the source code (and the PDP-11
Peripherals Handbook) to understand all this numerology.
In most of the code, minor(dev) & 077 is just treated as
a unit number (fair enough).  The use of 0200 appears only
as a magic number in htopen; that of 0100 only as a magic
number in htstart, and that only implied: the test is
not minor(dev) & 0100, but
	unit = minor(bp->b_dev) & 0177;
	if(unit > 077)

Not so bad when the whole driver is only 376 lines of code,
but it wouldn't have hurt to make it 400 lines if that
meant fewer magic numbers.

Anyway, what all this means is that /dev/*mt0 and /dev/*mt1
both actually meant slave 0 on TU16 controller 0, but mt0
was 800 bpi and mt1 1600 bpi.  Hence, I would guess, tar's
default to mt1.

My first exposure to the insides of UNIX was in the High
Energy Physics group at Caltech.  Some of our systems had
multiple tape drives and every drive supported multiple
densities, so we invented for ourselves a system like that
many other sites invented, with names like /dev/rmt3h to
mean the third tape drive at high density.  (Hence the
USG naming scheme of /dev/rmt/3h and the like--not that
we taught it to them, just that many places had the same
idea.)

Our world wasn't nearly as exciting as that of our neighbors,
across the building and three floors down, in the Space
Radiation Laboratory.  They had a huge room full of racks
of magtapes full of data from satellites, and many locally-
written tools for extracting the data so researchers could
work on it.  The hardware was an 11/70 with eight tape drives,
and at any given time at least half the the drives would be
spinning.  One of the drives was seven-track rather than
nine-track, because some of the satellite data had been
written in that format.

Fair disclosure: I had a vague memory that the `drive number'
in the device name had been recycled for other purposes,
but couldn't remember whether it was density or something
else.  (I'm a little surprised none of the other old-timers
here remembered that, but maybe I worked with tapes more than
them.)  But I had to dig into the source code for the details;
I didn't remember all that.  And I did have to climb up to the
high shelf in my home office for a Peripherals Handbook to
understand the magic numbers being stuffed into registers!

Norman Wilson
Toronto ON



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-12-13  3:04 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-11 22:27 [TUHS] why does tar have the tape device hard coded into it and why is it mt1 instead of mt0 Will Senn
2015-12-11 22:31 ` Clem Cole
2015-12-11 22:52   ` Will Senn
2015-12-11 23:13     ` John Cowan
2015-12-12  0:26       ` Random832
2015-12-12  2:09 Doug McIlroy
2015-12-12 18:54 ` Mary Ann Horton
2015-12-12 19:58   ` Armando Stettner
2015-12-12 20:13   ` Clem Cole
2015-12-12 22:44     ` Lyndon Nerenberg
2015-12-12 20:57   ` John Cowan
2015-12-12 17:17 [TUHS] TUHS] " Doug McIlroy
2015-12-12 20:17 ` [TUHS] " Diomidis Spinellis
2015-12-13  1:41 Norman Wilson
2015-12-13  3:04 ` Lyndon Nerenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).