0
votes

I am running Centos 7 kernel 3.10.0 on Oracle's VirtualBox 4.3.20 with an ext4 filesystem.

It seems that setting the "A" flag on a file doesn't keep the access time field from updating.

I created a file and used stat to check the access time -

touch ./foo
stat ./foo

which returns the following

File: ./foo

Size: 0 Blocks: 0 IO Block: 4096 regular empty file

Device: fd01h/64769d Inode: 1444417 Links: 1

Access: (0777/-rwxrwxrwx) Uid: ( 1000/ user_1) Gid: ( 1000/ user_1)

Context: unconfined_u:object_r:user_home_t:s0

Access: 2015-08-02 11:52:23.451524456 -0700

Modify: 2015-08-02 11:52:23.451524456 -0700

Change: 2015-08-02 11:52:23.451524456 -0700

Birth: -

If I then change the attribute and rerun stat -

sudo chattr +A ./foo
stat ./foo

I get the following which (I think) shows the access time value as updated?

File: ./foo

Size: 0 Blocks: 0 IO Block: 4096 regular empty file

Device: fd01h/64769d Inode: 1444417 Links: 1

Access: (0777/-rwxrwxrwx) Uid: ( 1000/ user_1) Gid: ( 1000/ user_1)

Context: unconfined_u:object_r:user_home_t:s0

Access: 2015-08-02 11:53:32.400974020 -0700

Modify: 2015-08-02 11:53:32.400974020 -0700

Change: 2015-08-02 11:53:32.400974020 -0700

Birth: -

Am I misunderstanding the use of the A flag? I thought it would keep the access time from changing?

Thanks for any insights you can offer. I am just trying to understand how things work.

Rog

1

1 Answers

0
votes

+A will keep the same atime when you open the file with vi for example and not modify it. The result you've posted after modifying the attribute doesn't look right to me. Changing the attribute should only affect the 'Change' timestamp. In your case, all 3 timestamps are the same.