Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

lsattr -v gives me the "version number" of given file(s).

What does this mean?

On Redhat 7.3, I could've sworn all the version numbers were 1 except those I changed with chattr -v.

On Fedora 11, they appeared to be random numbers.

Setting version numbers or even having multiple versions of a file could be very useful, so I want to understand how "versioning" works in ext3.

share|improve this question
add comment

2 Answers

This is not really an answer, but just a interresting find.

I played around with lsattr -v and it seems like each new file you create gets a unique number assigned to it. Im not sure if this is correct, my expirement is documented below.

$ mkdir temp                  # make a new folder
$ cd temp       
$ touch a b c d e f g         # create a lot files in that folder.
$ lsattr -v *                 # checkout those files using lsattr -v
1386486996 -------------e- a
1386486997 -------------e- b
1386486998 -------------e- c
1386486999 -------------e- d
1386487000 -------------e- e
1386487001 -------------e- f
1386487002 -------------e- g

This behaviour could be limited to the distribution or the disk format.

share|improve this answer
    
So it's sort of like an inode number, but it never repeats for the life of the filesystem? –  barrycarter Oct 30 '10 at 20:52
    
OK, I used "chattr -v 1 file*" to change several files' version number. It worked (lsattr showed version 1) and the files didn't get merged into each other or anything weird. So I think this is still an open question. Is it just "we had extra space for an int in the inode", or does it have a meaning/usage/history/etc (other than NFS above) –  barrycarter Nov 2 '10 at 20:23
    
add this to your question, by editing your question. That way more people get to see it... –  Stefan Nov 2 '10 at 20:35
add comment

lsattr -v invokes the EXT2_IOC_GETVERSION ioctl for the file. This, in turn, retrieves the inode's i_generation field. This is a feature primarily intended for use with NFS: each time an inode gets allocated, one has to make sure it gets a new generation. Otherwise, NFS clients with stale file handles may manage to access data that weren't meant for them. ext2/ext3/ext4 allocates the generation number from a volume-global counter s_next_generation, which is incremented on every allocation.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.