From mint-bounce@lists.fishpool.fi  Wed Sep  9 19:23:34 2009
Date: Thu, 10 Sep 2009 01:20:44 +0200 (CEST)
From: Frank Naumann <fnaumann@boerde.de>
X-X-Sender: fnaumann@localhost
To: =?ISO-8859-15?Q?Vincent_Rivi=E8re?= <vincent.riviere@freesbee.fr>
Cc: mint@lists.fishpool.fi
Subject: Re: [MiNT] stat() and blocks
In-Reply-To: <4AA82362.4040704@freesbee.fr>
Message-ID: <alpine.LFD.2.00.0909100111240.3840@localhost>
References: <4A95B430.9080304@freesbee.fr>  <8cf5b8cc0908270241p4ebc59d8yc8b2b9380972cf90@mail.gmail.com>  <4A969DEF.7000106@freesbee.fr>  <1251385614.19057.51.camel@jetpack.demon.co.uk>  <4A979AFC.3020405@freesbee.fr>  <1251450405.19057.79.camel@jetpack.
 <4AA82362.4040704@freesbee.fr>
User-Agent: Alpine 2.00 (LFD 1167 2008-08-23)
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
X-Virus-Scanned: by amavisd-new at relay.boerde.de
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on relay.boerde.de
X-Spam-Status: No, hits=- tagged_above=-50.5 required=7.0 WHITELISTED 
X-Spam-Level: 
X-ecartis-version: Ecartis v1.0.0
Sender: mint-bounce@lists.fishpool.fi
Errors-to: mint-bounce@lists.fishpool.fi
X-original-sender: fnaumann@boerde.de
Precedence: bulk
List-help: <mailto:ecartis@lists.fishpool.fi?Subject=help>
List-unsubscribe: <mailto:mint-request@lists.fishpool.fi?Subject=unsubscribe>
List-Id: <mint.lists.fishpool.fi>
X-List-ID: <mint.lists.fishpool.fi>
List-subscribe: <mailto:mint-request@lists.fishpool.fi?Subject=subscribe>
List-owner: <mailto:tjhukkan@fishpool.fi>
List-post: <mailto:mint@lists.fishpool.fi>

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


