3 ms·
While GNU tar inherits this from the original tar, it doesn't seem to be something intrinsic to the PDP-11 or DEC given that the earlier Unix 'tap' archival sys
by eesmith 4y ago
While GNU tar inherits this from the original tar, it doesn't seem to be something intrinsic to the PDP-11 or DEC given that the earlier Unix 'tap' archival system uses 'plain binary numbers ("base 256")', not octals.
Here's the V7 tar.c: https://github.com/dspinellis/unix-history-repo/blob/Research-V7-Snapshot-Development/usr/src/cmd/tar/tar.c https://github.com/dspinellis/unix-history-repo/blob/Researc...
and it's documentation: https://github.com/dspinellis/unix-history-repo/blob/Research-V7-Snapshot-Development/usr/man/man1/tar.1 https://github.com/dspinellis/unix-history-repo/blob/Researc...
The C code clearly shows the octal (I've never used "%o" myself!):
sscanf(dblock.dbuf.mode, "%o", &i);
sp->st_mode = i;
sscanf(dblock.dbuf.uid, "%o", &i);
sp->st_uid = i;
sscanf(dblock.dbuf.gid, "%o", &i);
sp->st_gid = i;
sscanf(dblock.dbuf.size, "%lo", &sp->st_size);
sscanf(dblock.dbuf.mtime, "%lo", &sp->st_mtime);
sscanf(dblock.dbuf.chksum, "%o", &chksum);
Now, older versions of Unix supported DECTape, going back to the first manual from 1971 (see the "tap" command at http://www.bitsavers.org/pdf/bellLabs/unix/UNIX_ProgrammersManual_Nov71.pdf http://www.bitsavers.org/pdf/bellLabs/unix/UNIX_ProgrammersM... , page "5_06", which is 94 of 211 - the command-line interface is clearly related to tar).
Here's the tp.5 format description from V6 at https://github.com/dspinellis/unix-history-repo/blob/Research-V6-Snapshot-Development/usr/doc/man/man5/tp.5 https://github.com/dspinellis/unix-history-repo/blob/Researc...
DEC/mag tape formats
...
Each entry has the following format:
path name 32 bytes
mode 2 bytes
uid 1 byte
gid 1 byte
unused 1 byte
size 3 bytes
time modified 4 bytes
tape address 2 bytes
unused 16 bytes
check sum 2 bytes
These are in essentially the same order as the "struct file_header" for tar shown in the linked-to essay.
But you can see at https://github.com/dspinellis/unix-history-repo/blob/Research-V6-Snapshot-Development/usr/sys/ino.h https://github.com/dspinellis/unix-history-repo/blob/Researc... that mtime is an int[2], so 4 bytes (yes, 16-bit integers; confirm with https://github.com/dspinellis/unix-history-repo/blob/Research-V6-Snapshot-Development/usr/sys/inode.h https://github.com/dspinellis/unix-history-repo/blob/Researc... showing i_mode is an integer).
Which means this older "tap" DECTape support uses 'plain binary numbers ("base 256")', not octal.