User: Password:
|
|
Subscribe / Log in / New account

File creation times

File creation times

Posted Jul 29, 2010 7:34 UTC (Thu) by dlang (subscriber, #313)
Parent article: File creation times

if a file gets larger so that another block needs to be allocated, doesn't this change the metadata for the file?


(Log in to post comments)

File creation times

Posted Jul 29, 2010 9:18 UTC (Thu) by saffroy (subscriber, #43999) [Link]

Any change to file data will require updating mtime, which is metadata, hence ctime will be updated too. If you enlarge the file with truncate() without touching its content, you still change the file length, again a metadata.

File creation times

Posted Jul 29, 2010 9:48 UTC (Thu) by fperrin (guest, #61941) [Link]

> Any change to file data will require updating mtime, which is metadata, hence ctime will be updated too.

Does this mean that ctime is always more recent than mtime ?

File creation times

Posted Jul 29, 2010 10:01 UTC (Thu) by Mog (subscriber, #29529) [Link]

> Does this mean that ctime is always more recent than mtime ?

Since mtime can be set to any value (using touch for example), not always.

File creation times

Posted Jul 29, 2010 17:10 UTC (Thu) by docwhat (guest, #40373) [Link]

I had to try it for myself...
$ mkdir -p /tmp/tmp.e0EkZhvZQR
$ touch /tmp/tmp.e0EkZhvZQR/somefile
$ stat /tmp/tmp.e0EkZhvZQR/somefile
  File: `/tmp/tmp.e0EkZhvZQR/somefile'
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: 801h/2049d	Inode: 2760536     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/  holtje)   Gid: ( 1000/  holtje)
Access: 2010-07-29 13:09:14.990815140 -0400
Modify: 2010-07-29 13:09:14.990815140 -0400
Change: 2010-07-29 13:09:14.990815140 -0400
$ touch -m -d 2110-01-01 /tmp/tmp.e0EkZhvZQR/somefile
$ stat /tmp/tmp.e0EkZhvZQR/somefile
  File: `/tmp/tmp.e0EkZhvZQR/somefile'
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: 801h/2049d	Inode: 2760536     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/  holtje)   Gid: ( 1000/  holtje)
Access: 2010-07-29 13:09:14.990815140 -0400
Modify: 2110-01-01 00:00:00.000000000 -0500
Change: 2010-07-29 13:09:14.990815140 -0400
Yup!

File creation times

Posted Jul 29, 2010 23:45 UTC (Thu) by jzbiciak (subscriber, #5246) [Link]

So how come ctime did *not* change? The metadata (ie. mtime) changed. I'm willing to believe that mtime is *not* in the set of metadata that ctime represents.

File creation times

Posted Jul 30, 2010 0:13 UTC (Fri) by docwhat (guest, #40373) [Link]

It happened too fast. I'm using a script. Here it is with a sleep.
$ mkdir -p /tmp/tmp.RZFIqs7625
$ touch /tmp/tmp.RZFIqs7625/somefile
$ stat /tmp/tmp.RZFIqs7625/somefile
  File: `/tmp/tmp.RZFIqs7625/somefile'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: ca02h/51714d    Inode: 1622396     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1002/ docwhat)   Gid: ( 1002/ docwhat)
Access: 2010-07-29 19:50:55.000000000 -0400
Modify: 2010-07-29 19:50:55.000000000 -0400
Change: 2010-07-29 19:50:55.000000000 -0400
$ sleep 2
$ touch -m -d 2110-01-01 /tmp/tmp.RZFIqs7625/somefile
$ stat /tmp/tmp.RZFIqs7625/somefile
  File: `/tmp/tmp.RZFIqs7625/somefile'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: ca02h/51714d    Inode: 1622396     Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1002/ docwhat)   Gid: ( 1002/ docwhat)
Access: 2010-07-29 19:50:55.000000000 -0400
Modify: 2110-01-01 00:00:00.000000000 -0500
Change: 2010-07-29 19:50:57.000000000 -0400
The script I used:
#!/bin/bash

set -x

mkdir -p /tmp/tmp.e0EkZhvZQR
touch /tmp/tmp.e0EkZhvZQR/somefile
stat /tmp/tmp.e0EkZhvZQR/somefile
sleep 2
touch -m -d 2110-01-01 /tmp/tmp.e0EkZhvZQR/somefile
stat /tmp/tmp.e0EkZhvZQR/somefile
Here's how I ran it:
$ /tmp/foo.sh |& perl -p -e 's@^\+@\$@'
I just cut-and-pasted the middle of the output.

Ciao!

File creation times

Posted Jul 30, 2010 13:49 UTC (Fri) by jzbiciak (subscriber, #5246) [Link]

Ah, ok. Mystery solved!


Copyright © 2018, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds