× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Scott:

Your explanation matches with what I came up with as a working assumption, so 
I'll go with it.

Two items come to mind: (1) A process that attempts to find how much space is 
being used overall should use st_allocsize rather than st_size. And (2) writes 
through /QNTC to a Win2K Server can result in very inefficient use of Win2K 
disk space.

I ran various tests to Win2K and continually saw st_allocsize rapidly exceeding 
st_size as the file grew. Just from the single example I provided, you can see 
st_allocsize is almost seven times st_size. When I was trying closes and 
re-opens with O_APPEND, the size difference was worse. Wish I had time for a 
decent benchmark series.

Thanks for some confirmation.

Tom Liotta

midrange-l-request@midrange.com wrote:

>   8. Re: stat(), st_size and st_allocsize (Scott Klement)
>
>st_size is the number of bytes of data that are stored in the file.
>In other words, if you wanted to read the entire file in your program,
>you would need to read "st_size bytes".
>
>st_allocsize is the number of bytes of disk space that have been reserved
>for the file.   Disk space is allocated in chunks, so most of the time the
>st_allocsize will be larger than st_size.   (I'm not sure what terminology
>OS/400 uses for these "chunks", I know in Windows you allocate things one
>"cluster" at a time so if you have a 16k cluster size, a file thats
>between one and 16384 bytes takes up 16k of disk space, a file thats
>between 16385 and 32768 takes up 32k of disk space, etc.   OS/400 may
>call these chunks "blocks" or "sectors" or "clusters", I don't know, but
>the concept is the same as it relates to st_allocsize)
>
>Fortunately, I don't need pay any attention to the "st_blksize" value in
>any of my programs :)
>
>
>
>On Thu, 10 Oct 2002, Tom Liotta wrote:
>>
>> Does anyone have a useful definition of stat's st_allocsize? I'm trying
>> to handle some file size threshhold issues and I'm not sure if st_size
>> or st_alcsize is best.
>>
>> Example... I have a program calling procedures to create and open a
>> streamfile, write lines to it in a loop and close down when st_size
>> exceeds 10K as reported by fstat() over the open file descriptor. Works
>> fine. The program is purely a testing function to get a clear
>> understanding of stat()/fstat().
>>
>> But I'm feeling uncomfortable about what's _really_ happening.
>>
>> When I run the test program specifying a path into the local /root file
>> system, the program ends and reports the following values from the stat
>> structure:
>>
>>   st_size = x'00002732' = 10034 bytes
>>   st_allocsize = x'00004000' = 16384 bytes(?)
>>   st_blksize = x'00008000' = 32768 bytes
>>
>> When I run the same program specifying a path through /QNTC to a Win2000
>> Server system, the values are reported as:
>>
>>   st_size = x'00002732' = 10034 bytes
>>   st_allocsize = x'00011000' = 69632 bytes(???)
>>   st_blksize = x'00001000' = 4096 bytes
>>
>> (The path is retrieved from a data area so I can run the program easily
>> over different file systems.) Okay, st_size and st_blksize seem
>> reasonable in both cases. But what in the world is st_allocsize telling
>> me? Is this a reference to space that is tied up by this object but not
>> yet used for data? If I want to manage by object size, should I be
>> totalling st_allocsize instead of st_size?
>>
>> Various 'net searches have given little but confusion since st_allocsize
>> seems something less than "standard".
--
Tom Liotta
The PowerTech Group, Inc.
19426 68th Avenue South
Kent, WA 98032
Phone  253-872-7788 x313
Fax    253-872-7904
http://www.powertechgroup.com


__________________________________________________________________
The NEW Netscape 7.0 browser is now available. Upgrade now! 
http://channels.netscape.com/ns/browsers/download.jsp

Get your own FREE, personal Netscape Mail account today at 
http://webmail.netscape.com/


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.