[TUHS] History of strncpy

scj at yaccman.com scj at yaccman.com
Thu Jan 24 03:49:13 AEST 2013

This does indeed bring up memories.  The earliest Unix manuals printed
data structure definitions (e.g., inode structure) in the manual. 
Programmers copied these structures into their code.  When we ported Unix
to 32-bits, this turned out to be a disaster.  The whole constellation of
header files, etc. was invented to get these declarations out of user code
and into a place that could adapt to different machines.  The earliest
lint programs checked that system calls that passed pointers to structures
had not just compatible definitions but got their structure definitions
from the same physical location on disc.  After several painful weeks, we
had cleaned these embedded definitions out of the system and most user

Something like strncpy must have existed in Unix very early, however.  The
earliest Unix systems had file names limited to 6 characters (shades of
FORTRAN!).  If you used a longer name, it was truncated.  This led to some
nasty traps.  You could edit a file "smile.c" and write it out, where it
went into the file system as "smile."  Repeated edits would continue to
work just fine.  But when you compiled the sucker, the compiler created
the file "smile.o" and wrote it out, where it also entered the file system
as "smile." and wiped out the source file!

More information about the TUHS mailing list