[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] stat() and blocks



Hello, Frank.

Frank Naumann a écrit :
Just to note, you shall difference between the MiNTLib (that try to be POSIX compatible) and the kernel syscalls (they have a non-POSIX history).

Ok, this is important.

First, the "struct xattr" doesn't have a member st_blocks or st_blksize. They are called nblocks and blksize!

The member names for this structure are different between FreeMiNT and the MiNTLib :-(

Question 2: What is the unit used by the st_blocks member of "struct xattr"? We can see that on ext2, the unit is 1024 (to match the file size). So where does this 1024 come from ?

The answer is simple as it's documented inside the ATARI Compendium:
---
blksize - blksize specifies the size of blocks (in bytes) in this file system.

nblocks - nblocks is the actual number of blocks the file is using on the device. This number may include data storage elements other used to keep track of the file (aside from the actual data).
---

As you can see anything is correct. The ext2 blocksize is 1024 bytes and the file use 8 blocks (a 1024 bytes).

Ok, this is clear now.

As the structure definition is not the same in the kernel, the members don't have the exact same names, but it is actually a "struct xattr". The comment clearly says that blksize is the block size, and nblocks is the block count. So the definition of these 2 fields is radically different than in "struct stat".

Yes. I hope you don't have any problem with that :-)

Absolutely no problem, since it is documented. I plan to provide a patch to add more comments in the code, to emphasize the fact that the meaning of the blocks members are different between "struct stat" and "struct xattr". And since the "struct xattr" definition is private inside the MiNTLib, I will rename its members to match the reference definition in the kernel.

Thanks for your precise answer, Frank.
I will continue my quest to get correct values in every case (including hostfs).

--
Vincent Rivière