bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

touch problem?


From: Simone Piccardi
Subject: touch problem?
Date: Thu, 18 Jan 2001 15:37:44 +0100
User-agent: Mozilla/5.0 (X11; U; Linux 2.2.18 i686; en-US; 0.7) Gecko/20010105

Hi,
I found a behaviour of touch that I don't understand (It seems to me a bug, at least a bug for the documentation) regarding the access, modifications and change times attributes of a file.

I'm using a Debian GNU/Linux 2.2r2, linux 2.2.18, glibc 2.1 and the problem is that if I get the file times after a touch also the ctime is always changed.

To get the file times I use this code (that seems fine to me):

    errstat = stat(argv[optind], &infos);
    if (errstat!=0) {
        perror("Error on stat calling");
        exit(errstat);
    }
    printf("File %s stats results:\n", argv[optind]);
    printf("     atime = %s", ctime(&infos.st_atime));
    printf("     mtime = %s", ctime(&infos.st_mtime));
    printf("     ctime = %s", ctime(&infos.st_ctime));

and in any case after a touch (both using or not -a and -m options) the ctime is changed also, while in the documentation results that only modification and access time should be affected.

Could you explain me this behaviour?
In the glibc documentation I found that:

*************
   Reading from a file updates its access time attribute, and writing
updates its modification time.  When a file is created, all three time
stamps for that file are set to the current time.  In addition, the
attribute change time and modification time fields of the directory that
contains the new entry are updated.

   Adding a new name for a file with the `link' function updates the
attribute change time field of the file being linked, and both the
attribute change time and modification time fields of the directory
containing the new name.  These same fields are affected if a file name
is deleted with `unlink', `remove', or `rmdir'.  Renaming a file with
`rename' affects only the attribute change time and modification time
fields of the two parent directories involved, and not the times for
the file being renamed.

   Changing attributes of a file (for example, with `chmod') updates
its attribute change time field.

   You can also change some of the time stamps of a file explicitly
using the `utime' function--all except the attribute change time.  You
need to include the header file `utime.h' to use this facility.
*************

According to this it doesn't seems to me that changing the change time with touch is the right thing.

Thanks
Simone Piccardi





reply via email to

[Prev in Thread] Current Thread [Next in Thread]