Skip to contentSkip to conversation

inode generation numbers

DISCUSSION Bernd Schubert 5 participants 6 messages Sep 9, 2003 – Sep 11, 2003

lore
Share & tools
lore
#0 lore raw

Hello,

for a user space nfs-daemon it would be helpful to get the inode generation numbers. However it seems the fstat() from the glibc doesn't support this, but refering to some google search fstat() from some (not all) other unixes does.
Does anyone know how to read those numbers from userspace with linux?

Thanks,
Bernd

#1 lore raw
Quoted 5 lines · Bernd Schubert

for a user space nfs-daemon it would be helpful to get the inode generation numbers. However it seems the fstat() from the glibc doesn't support this, but refering to some google search fstat() from some (not all) other unixes does.
Does anyone know how to read those numbers from userspace with linux?

For ext2/ext3 filesystems you can use EXT2_GET_VERSION ioctl for this. Maybe reiserfs as well.

Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/

#2 lore raw
Quoted 8 lines · Andreas Dilger
Quoted 5 lines · Bernd Schubert

for a user space nfs-daemon it would be helpful to get the inode generation numbers. However it seems the fstat() from the glibc doesn't support this, but refering to some google search fstat() from some (not all) other unixes does.
Does anyone know how to read those numbers from userspace with linux?

For ext2/ext3 filesystems you can use EXT2_GET_VERSION ioctl for this.

regarding to fs/ext2/ioctl.c it should be EXT2_IOC_GETVERSION, shouldn't it?

Quoted 2 lines

Maybe reiserfs as well.

Hello,

thanks a lot, it seems to work pretty well.
Since I have never used the ioctl() call before I only want to be sure I don't do something wrong, I think this is correct, isn't it?

int ret, igen;
ret = ioctl(fd, EXT2_IOC_GETVERSION, &igen);

It also works for reiserfs-partitions with the very same call, @reiserfs-team, this won't change in the future, will it?

Cheers,
Bernd

#5 lore raw
In reply to Bernd Schubert
Quoted 5 lines · Bernd Schubert

for a user space nfs-daemon it would be helpful to get the inode generation numbers. However it seems the fstat() from the glibc doesn't support this, but refering to some google search fstat() from some (not all) other unixes does.
Does anyone know how to read those numbers from userspace with linux?

For ext2:
The i_generation field of a file can be read and set using the EXT2_IOC_GETVERSION and EXT2_IOC_SETVERSION ioctls.

#4 lore raw
In reply to Andreas Dilger
Quoted 9 lines · Andreas Dilger
Quoted 5 lines · Bernd Schubert

for a user space nfs-daemon it would be helpful to get the inode generation numbers. However it seems the fstat() from the glibc doesn't support this, but refering to some google search fstat() from some (not all) other unixes does.
Does anyone know how to read those numbers from userspace with linux?

For ext2/ext3 filesystems you can use EXT2_GET_VERSION ioctl for this. Maybe reiserfs as well.

yes.

Quoted 2 lines

Cheers, Andreas

Nikita.

#3 lore raw
In reply to Bernd Schubert

Hello!

Quoted 2 lines · Bernd Schubert

It also works for reiserfs-partitions with the very same call, @reiserfs-team, this won't change in the future, will it?

Yes, it is in there just to be compatible with ext2.

Be warned that on v3.5 filesystems this generation stuff is weakly implemented and defaults to object id of parent directory.

Bye,
Oleg