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

Re: [MiNT] stat() and blocks



Hello!

I found some documentation about this block stuff on other OS, this is perfectly valid.

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).

Question 1: Are the semantics of st_blocks and st_blksize of the "struct stat" returned by Fstat64() the same as the one returned by stat() ? I believe the answer is yes, but it has to be confirmed.

Yes, that's the idea behing Fstat64().

OS block size: S_BLKSIZE = 512
stat(): st_blocks = 16, st_blksize = 1024
Fstat64(): st_blocks = 16, st_blksize = 1024
Fxattr(): st_blocks = 8, st_blksize = 1024

The Fxattr() system call is similar, but it returns a "struct xattr", which is similar, but not same, as "struct stat". Surprisingly, the st_blocks value is half the value stat's one.

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

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).

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 :-)

Here are the facts.

Hey, FreeMiNT gurus, could you please confirm the behaviours described here are correct ?

Confirmed to be correct.

Anyway, when anyone agrees with the answers to these questions, we will have to comment the members of "struct xattr" in mintlib/lib.h and freemint/sys/mint/stat.h to avoid new interrogations like this in the future.

Yes, docu can always be improved.


Regards,
Frank

--
ATARI FALCON 060 // MILAN 060
-----------------------------
http://sparemint.org/
e-Mail: fnaumann@boerde.de