Skip to contentSkip to conversation

General Question: ctime, mtime, and xattrs

DISCUSSION Robert White 3 participants 4 messages Dec 5, 2014 – Dec 6, 2014 1 message not in the archive Btrfs file system

lore
Share & tools
lore
#0 lore raw

So I was reading the wiki on the internal layout. The INODE description says "st_ctime. Also updated when xattrs change."

Why isn't changing the xattrs a modification (st_mtime) event?

It just seems odd to me...

A message that is not in the archive (sent off-list or not yet received): CAE5mzvgrdYSNWSWLrnmHMz2fSgPSJV_ocYr_ZSBGPwLWBshH-g@mail.gmail.com

#2 lore raw

Ah...

I've been thinking "ctime" is/was (still) "create time". It seems that somewhere in the last couple decades it became "change time"; Or that I picked up that incorrect "create time" idea back in the UNIX Sys V R 3 days and just never had cause to think about it again...

Never mind. /sigh...

What a maroon. 8-)

Quoted 8 lines · cwillu

xattrs are commonly used to implement acls, which wouldn't typically be considered a content modification.

Quoted 4 lines · Robert White

So I was reading the wiki on the internal layout. The INODE description says "st_ctime. Also updated when xattrs change."

Why isn't changing the xattrs a modification (st_mtime) event?

#3 lore raw
Quoted 4 lines · Robert White

I've been thinking "ctime" is/was (still) "create time". It seems that somewhere in the last couple decades it became "change time"; Or that I picked up that incorrect "create time" idea back in the UNIX Sys V R 3 days and just never had cause to think about it again...

Sadly there's never been a creation time in Linux that you can get with a standard system call, there was an attempt 4-5 years ago to get xstat merged that would include creation time from filesystems that support it (like ext4) but it never went anywhere (for a variety of reasons).

LWN article on the patch set:

https://lwn.net/Articles/394298/

Linus knocking it back:

https://lkml.org/lkml/2010/7/22/249

FreeBSD has:

st_birthtim Time when the inode was created.

No idea when that was added!

All the best,
Chris

Signature · 1 line
 Chris Samuel  :  http://www.csamuel.org/  :  Melbourne, VIC
#4 lore raw
In reply to Robert White
Quoted 7 lines · Robert White

Ah...

I've been thinking "ctime" is/was (still) "create time". It seems that somewhere in the last couple decades it became "change time"; Or that I picked up that incorrect "create time" idea back in the UNIX Sys V R 3 days and just never had cause to think about it again...

v7 is the point where the third timestamp has first appeared (v6 has only two - access and update). And their stat(2) says this:
st_atime is the file was last read. For reasons of efficiency, it is not set when a directory is searched, although this would be more logi‐ cal. st_mtime is the time the file was last written or created. It is not set by changes of owner, group, link count, or mode. st_ctime is set both both by writing and changing the i-node.

FWIW, their /usr/sys/sys/sys4.c has
chmod()

{
        register struct inode *ip;
        register struct a {
                char    *fname;
                int     fmode;
        } *uap;

        uap = (struct a *)u.u_ap;
        if ((ip = owner()) == NULL)
                return;
        ip->i_mode &= ~07777;
        if (u.u_uid)
                uap->fmode &= ~ISVTX;
        ip->i_mode |= uap->fmode&07777;
        ip->i_flag |= ICHG;
        if (ip->i_flag&ITEXT && (ip->i_mode&ISVTX)==0)
                xrele(ip);
        iput(ip);
}
and /usr/sys/sys/iget.c has, in the end of iupdat() (called on the final
iput(), as well as on stat(2) and several other paths), this:
                if(ip->i_flag&IACC)
                        dp->di_atime = *ta;
                if(ip->i_flag&IUPD)
                        dp->di_mtime = *tm;
                if(ip->i_flag&ICHG)
                        dp->di_ctime = time;
                ip->i_flag &= ~(IUPD|IACC|ICHG);

(ta and tm are both equal to &time in that call chain). IOW, chmod(2) definitely sets ctime.

IOW, ctime has never been "create time"; it's "change time" and it had been that way since its introduction.