Well I have in my hands a copy of volume 1 of the "UNIX Programmers Manual" version 7. Copyright is 1983, 1979 Bell Telephone Laboratories. All rights reserved. ISBN 0-03-061742-1 Published by CBS College Publishing; Holt, Rinehart and Winston; The Dryden Press; Saunders College Publishing.
I also have Operating Systems Design and Implementation, Andrew S. Tanenbaum 1987. Where I reference Minix below, it is the book I am quoting. The bibliography lists the identical UNIXv7 manual that I am refering to.
The Linux I quote is the one loaded on my system here: 2.4.22 The BSD I quote from is 4.4Lite - the first free distribution that resulted from the AT&T vs. UCB lawsuit, and therefore the one most likely to be in accord with the sealed settlement.
Feel free to ask me to look up anything. For the moment I will just go through the ABI files from the December letter.
There are no files in the Unix manual of course, but much of the information in the files seems to be present, and in many cases the manual content appears to be taken verbatim from the relevant files.
errno.h
Errno.h defines error numbers for use by functions in the operating system kernel. While the Linux errno.h file is almost identical to the System 7 manual this is not a copyright problem. The names of all the errors are a POSIX standard. The values of the errors are also identical to the System 7 manual. However numbers do not involve creative input and are therefor not copyrightable. The comments also closely follow the System 7 manual. However nearly all of them are also identical to the descriptive text in the POSIX specifiction and the descent of the others is mixed: The following entries
11 EAGAIN No more processes 12 ENOMEM Not enough core 33 EDOM Math argument 34 ERANGE Result too largeare entirely original to Linux. The following entries
4 EINTR Interrupted system call 8 ENOEXEC Exec format error 15 ENOTBLK Block device required 29 ESPIPE Illegal seekare identical to both BSD4.4-Lite and System 7, leaving only
9 EBADF Bad file number 23 ENFILE File table overflow 25 ENOTTY Not a typewriterwhich are only to be found in both Linux and System 7. My take on this is that all both EBADF and ENFILE are obvious texts given their meaning and their names. ENOTTY is famous. It is also worth remembering that these texts are the displayed to the user when the error occurs. They would therefore have entered the memory of any programmer working on Unix, and their text would have been the obvious comment to use.
The errno.h file in Minix has no comments.
signal.h:
This has also been disected before. Interestingly Linux has no comments, while Minix follows the System 7 comments above very closely. Here's the Minix file:
#define SIGHUP 1 /* hangup */ #define SIGINT 2 /* interrupt (DEL) */ #define SIGQUIT 3 /* quit (ASCII FS) */ #define SIGILL 4 /* illegal instruction (not reset when caught) */ #define SIGTRAP 5 /* trace trap (not reset when caught) */ #define SIGIOT 6 /* IOT instruction */ #define SIGEMT 7 /* EMT instruction */ #define SIGFPE 8 /* floating point exception */ #define SIGKILL 9 /* kill (cannot be caught or ignored) */ #define SIGBUS 10 /* bus error */ #define SIGSEGV 11 /* segmentation violation */ #define SIGSYS 12 /* bad argument to system call */ #define SIGPIPE 13 /* write on a pipe with no one to read it */ #define SIGALRM 14 /* alarm clock */ #define SIGTERM 15 /* software termination signal from kill */ #define STACK_FAULT 16 /* used by kernel to signal stack fault */
The POSIX specification has a few of the same descriptions, SIGPIPE for example, but may have been rewritten to give more information than this rather terse language.
With no comments in the Linux source there is not copyright protected code in this file.
linux/stat.h
Nothing found in Unixv7 or BSD4.4-Lite that matches this file in Linux.
linux/ctype.h
lib/ctype.c
Section 3 - isalpha, isupper, tolower, isdigit, isalnum, isspace, ispunct, isprint, iscntrl, isascii - character classification SYNOPSIS #include <ctype.h> isalpha(c) ... DESCRIPTION These macros classify ASCII-coded integer values by table lookup. Each is a predicate returning nonzero for true, zero for false. Isascii is defined on all integer values; the rest are defined only where isascii is true and on the single non-ASCII value EOF (see stdio(3)). [which defines it to be -1.] isalpha c is a letter isupper c is an upper case letter islower c is a lower case letter isdigit c is a digit isalnum c is an alphanumeric character isspace c is a space, tab, carriage return, newline, or formfeed ispunct c is a punctuation character (neither control or alphanumeric) isprint c is a printing character, code 040(8) (space) through 0176 (tilde) iscntrl c is a delete character (0177( or ordinary control character (less than 040). isascii c is an ASCII character, code less than 0200 SEE ALSO ascii(7)
That describes the same method that Linux uses, but doesn't match up otherwise except in the macro names used, which are C standards. Interestingly the above description uses octal, whereas Linux and BSD use hexadecimal.
include/asm-xxx/ioctl.h
include/asm-xxx/ioctls.h
Section 4 - TTYthis (long) section defines the following 'codes':
TIOCGETP TIOCSETP TIOCSETN TIOCEXCL TIOCNXCL TIOCHPCL TIOCFLUSH TIOCSETC TIOCSETP
No values are given. Only TIOCEXCL and TIOCNXCL appear in Linux. There do not appear to be any other matches. My copy of Operating Systems (ie Minix) only defines the TIOCSETC, TIOCGETP and TIOCSETP codes. BSD defines TIOCEXCL, TIOCNXCL and TIOCFLUSH with different values to Linux.
linux/ipc.h
Nothing found in Unixv7 that matches this file in Linux. It does exist in BSD4.4-Lite, but with totally different contents.linux/acct.h
Section 5 - acct SYNOPSIS #include <sys/acct.h> DESCRIPTION Acct(2) causes entries to be made into an accounting file for each process that terminates. The accounting file is a sequence of entries whose layout, as defined by the include file is: /* * Accounting structures */ typedef ushort comp_t; /* "floating point" */ /* 13-bit fraction, 3-bit exponent */ struct acct { char ac_flag; /* Accounting flag */ char ac_stat; /* Exit status */ ushort ac_uid; /* Accounting user ID */ ushort ac_gid; /* Accounting group ID */ dev_t ac_tty; /* control typewriter */ time_t ac_btime; /* Beginning time */ comp_t ac_utime; /* acctng user time in clock ticks */ comp_t ac_stime; /* acctng system time in clock ticks */ comp_t ac_etime; /* acctng elapsed time in clock ticks */ comp_t ac_mem; /* memory usage */ comp_t ac_io; /* chars transferred */ comp_t ac_rw; /* blocks read or written */ char ac_comm[8]; /* command name */ }; extern struct acct actbuff; extern struct inode *acctp;/* inode of accounting file */ #define AFORK 01 /* has executed fork, but no exec */ #define ASU 02 /* has super-user privileges */ #define ACCTF 0300 /* record type: 00 = acct */ If the process does an exec(2), the first 10[sic] characters of the filename appear in ac_comm. The accounting flag contains bits indicating whether exec(2) was ever accomplished, and whether the process ever had super-user privileges. SEE ALSO acct(2), sa(1)
Linux has:
... * This header file contains the definitions needed to implement * BSD-style process accounting. ... /* * comp_t is a 16-bit "floating" point number with a 3-bit base 8 * exponent and a 13-bit fraction. See linux/kernel/acct.c for the * specific encoding system used. */ typedef __u16 comp_t; /* * accounting file record * * This structure contains all of the information written out to the * process accounting file whenever a process exits. */ #define ACCT_COMM 16 struct acct { char ac_flag; /* Accounting Flags */ /* * No binary format break with 2.0 - but when we hit 32bit uid we'll * have to bite one */ __u16 ac_uid; /* Accounting Real User ID */ __u16 ac_gid; /* Accounting Real Group ID */ __u16 ac_tty; /* Accounting Control Terminal */ __u32 ac_btime; /* Accounting Process Creation Time */ comp_t ac_utime; /* Accounting User Time */ comp_t ac_stime; /* Accounting System Time */ comp_t ac_etime; /* Accounting Elapsed Time */ comp_t ac_mem; /* Accounting Average Memory Usage */ comp_t ac_io; /* Accounting Chars Transferred */ comp_t ac_rw; /* Accounting Blocks Read or Written */ comp_t ac_minflt; /* Accounting Minor Pagefaults */ comp_t ac_majflt; /* Accounting Major Pagefaults */ comp_t ac_swaps; /* Accounting Number of Swaps */ __u32 ac_exitcode; /* Accounting Exitcode */ char ac_comm[ACCT_COMM + 1]; /* Accounting Command Name */ char ac_pad[10]; /* Accounting Padding Bytes */ }; /* * accounting flags */ /* bit set when the process ... */ #define AFORK 0x01 /* ... executed fork, but did not exec */ #define ASU 0x02 /* ... used super-user privileges */ #define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */ #define ACORE 0x08 /* ... dumped core */ #define AXSIG 0x10 /* ... was killed by a signal */ #define AHZ 100
Note Linux's reference to BSD. Here is the BSD code.
Most of the comments here are fairly obvious, and other facets are probably not copyrightable, but the Linux version is fascinatingly close to both versions. The BSD file does have an AT&T copyright./* * Accounting structures; these use a comp_t type which is a 3 bits base 8 * exponent, 13 bit fraction ``floating point'' number. Units are 1/AHZ * seconds. */ typedef u_short comp_t; struct acct { char ac_comm[10]; /* command name */ comp_t ac_utime; /* user time */ comp_t ac_stime; /* system time */ comp_t ac_etime; /* elapsed time */ time_t ac_btime; /* starting time */ uid_t ac_uid; /* user id */ gid_t ac_gid; /* group id */ short ac_mem; /* average memory usage */ comp_t ac_io; /* count of IO blocks */ dev_t ac_tty; /* controlling tty */ #define AFORK 0x01 /* forked but not execed */ #define ASU 0x02 /* used super-user permissions */ #define ACOMPAT 0x04 /* used compatibility mode */ #define ACORE 0x08 /* dumped core */ #define AXSIG 0x10 /* killed by a signal */ char ac_flag; /* accounting flags */ }; /* * 1/AHZ is the granularity of the data encoded in the comp_t fields. * This is not necessarily equal to hz. */ #define AHZ 64
asm/a.out.h
linux/a.out.h
UNIXv7 has:
Section 5 - a.out struct exec { /* a.out header */ int a_magic; /* magic number */ unsigned a_text; /* size of text segment */ unsigned a_data; /* size of initialized data */ unsigned a_bss; /* size of uninitialized data */ unsigned a_syms; /* size of symbol table */ unsigned a_entry; /* entry point */ unsigned a_unused; /* not used */ unsigned a_flag; /* relacation info stripped */
Linux has:
struct exec { unsigned long a_info; /* Use macros N_MAGIC, etc for access */ unsigned a_text; /* length of text, in bytes */ unsigned a_data; /* length of data, in bytes */ unsigned a_bss; /* length of uninitialized data area for file, in bytes */ unsigned a_syms; /* length of symbol table data in file, in bytes */ unsigned a_entry; /* start address */ unsigned a_trsize; /* length of relocation info for text, in bytes */ unsigned a_drsize; /* length of relocation info for data, in bytes */ };
Minix does not use a structure for this information, but the code that implements it is equivilant to:
struct { unsigned long MAGIC; unsigned long LITERAL=0x20; unsigned long TEXTB; /* size of text segment in bytes */ unsigned long DATAB; /* size of initialized data segment in bytes */ unsigned long BSSB; /* size of bss in bytes */ unsigned long LITERAL=0; unsigned long TOTB; /* total memory allocated to program (text, data and stack, combined) */ unsigned long LITERAL=0; };
BSD has:
struct exec { #define OMAGIC 0407 /* old impure format */ #define NMAGIC 0410 /* read-only text */ #define ZMAGIC 0413 /* demand load format */ long a_magic; /* magic number */ u_long a_text; /* text segment size */ u_long a_data; /* initialized data size */ u_long a_bss; /* uninitialized data size */ u_long a_syms; /* symbol table size */ u_long a_entry; /* entry point */ u_long a_trsize; /* text relocation size */ u_long a_drsize; /* data relocation size */ };
UNIXv7 specifies magic numbers MAGIC1(0407), MAGIC2(0410), MAGIC3(0411) and MAGIC4(0405). The values 0407 (OMAGIC) and 0410 (NMAGIC) appear in Linux and have the same meaning. The other values in Linux are 0413 (ZMAGIC), 0314 (QMAGIC) and 0421 (CMAGIC). Minix uses 0410 and 0420, but 0420 is equivilant to Unix and Linux 0410.
Now for the kicker - The BSD uses the same OMAGIC, NMAGIC and ZMAGIC and has almost exactly the same structure format as Linux. And there is no AT&T copyright.
UNIXv7 defines a structure called nlist:
struct nlist { /* symbol table entry */ char n_name[8]; /* symbol name */ int n_type; /* type flag */ unsigned n_value; /* value */ };
the definition in Linux is:
struct nlist { union { char *n_name; struct nlist *n_next; long n_strx; } n_un; unsigned char n_type; char n_other; short n_desc; unsigned long n_value; };
Note that although n_name, n_type and n_value are defined in both, they all have different types.
UNIXv7 has:
#define N_UNDF 0 /* undefined */ #define N_ABS 01 /* absolute */ #define N_TEXT 02 /* text symbol */ #define N_DATA 03 /* data symbol */ #define N_BSS 04 /* bss symbol */ #define N_TYPE 037 #define N_REG 024 /* register name */ #define N_FN 037 /* file name symbol */ #define N_EXT 040 /* external bit, or'ed in */
Linux has (with #if etc. removed):
#define N_UNDF 0 #define N_ABS 2 #define N_TEXT 4 #define N_DATA 6 #define N_BSS 8 #define N_FN 15 #define N_EXT 1 #define N_TYPE 036 #define N_STAB 0340
The following files are already covered or are not applicable:
asm-sparc*/bsderrno.h
asm-sparc*/solerrno.h
Conclusion
There are some striking similarities in many of the files. However similarities only seem to lie in the non-copyrightable facets - variable names and values, the order of elements in a structure. It may be useful to trace the origins of the BSD accounting structure. We already know how the errno.h file was created from the gcc compiler files, but it would be useful to track it back beyond there in order to exonerate F/OSS entirely.

