differences in the time precision used within linux can bite you

Cameron Simpson cs at zip.com.au
Sun Feb 3 22:43:01 UTC 2008


On 03Feb2008 14:13, mark <m.roth2006 at rcn.com> wrote:
| krishnaakishore at gmail.com wrote:
| > @Bruke: I don't think that is what he is referring to. The problem was
| > with preserving timestamps when the copy is being made.
| > 
| > It has got something to do with struct timespec, struct timeval usage
| > may be. Just a guess.
| 
| Here's a thought: could the cp be 32-bit code, and the timestamp struct shown
| by ls be 64-bit?

The time differences were well less than one second. UNIX generally uses 32
bit seconds, so you'd expect 

Unless you're talking about the sub-second component being in 32 bits,
which would still suffice for nanoseconds.

A quick glance inside time.h shows a "struct timeval" with goes to
microseconds and a "struct timespec" that goes to nanoseconds.

If different code paths use each then this could readily produce the
behaviour reported. For example, if "cp" is using a struct timeval to
copy the time from the original file to the new one.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/




More information about the redhat-list mailing list