[tex-live] ctan->tl updates caught up

Reinhard Kotucha reinhard.kotucha at web.de
Fri Aug 3 23:55:22 CEST 2012

On 2012-08-03 at 13:38:17 +0100, Philip TAYLOR wrote:

 > Zdenek Wagner wrote:
 > > I cannot answer. I switched from DOS+Windows 3.0 to OS/2 in 1994, thus
 > > I do not know the Windows specific details. Maybe I have old notes how
 > > it worked on DOS but most probably, if I still keep them, they may be
 > > on an old 5 1/4" diskette for which I do not have a drive any longer.
 > OK, but it was not a Windows question (particularly as we already
 > know from Tomek that that step may be omitted on Windows without
 > any obvious harm).  It is a more general question, applicable to
 > any operating system.  Q1 :  When TAR creates a file, does it set
 > "last modified" to "time created", as it has not yet been modified.

When a tar file is created, file names, time stamps, permission flags,
and other meta data are stored along with the file contents in the tar

When files are extracted, these values are restored.  The creation
time will not be preserved because a new file had been created indeed.
The creation time denotes the time when a file was created on the
*file system*.

The last modified time is then set to the value stored in the tar file.
It denotes the time when the *content* was modified. 

Therefore a copied file could have been modified even before it was
created.  It's important to know that ctime and atime (time of last
access) refer to the file system and mtime refers to the file

 > And Q2 :  If so, why is it then necessary to adjust "last modified"
 > as a separate step ?

Because time stamps and permission flags are not part of the file
itself.  Not even the file name.  They are stored in inodes on Unix
and in directories at least in FAT file systems.  Don't know much
about NTFS but it's probably more Unix-like.

Since user-level commands like cp or copy also transfer meta data, at
a first glance one gets the impression that everything is stored
together and copying a file can be done with a single step on system
level.  Writing the system independent Perl function copy() in
tlpkg/TeXLive/TLUtils.pm was very instructive in this respect.  

A description of a copy function might be helpful in order to
understand how things work on system level.  All C functions
mentioned below are available on both, Unix and Windows.  On Windows
these functions reside in MSVCRT.DLL, the C runtime library.  

On Linux these functions are described in manual pages, on Windows
there are quite useful comments within the C source files.

In order to copy a file, the following steps have to be performed:

 * open the source file readonly with open().

 * if the target file doesn't exist already, it has to be created with
   creat(). This function creates a data structure in the file system
   if necessary and sets file permissions.  Hence it can also be used
   if the target file exists but permission flags from the source file
   have to be preserved.

 * open the target file writeonly with open().

 * read the content of the source file to memory with read() and write
   it to the target file using write().  In order to save memory, this
   is usually done block by block.

 * close both files using close(). 

What we have achieved so far is that we have a new file with the
content of another file.  creat() creates a new data structure within
the file system and sets file permissions, open() sets the file name,
read() and write() copy the content only.  No other meta data can be
transferred with these low-level system calls, hence all time stamps
are set to the time the new file was created.

If the last modified or last accessed time stamps have to be
preserved, they have to be retrieved from the meta data of the source
file and set accordingly using utime().


Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.

More information about the tex-live mailing list