[cs631apue] blocks (-s) & size (-k -h)

zding4 zding4 at stevens.edu
Fri Oct 17 13:56:12 EDT 2014


APUE book have the paragraph about st_blocks

"Be aware that different versions of the UNIX System use units other 
than 512-byte blocks for st_blocks.
Using this value is nonportable"

So I'm not sure st_block*512 is reliable.

在 10/17/2014 10:49 AM,sshah83 写道:
> Linux ls -s displays the number of blocks allocated to each file in
> unit of 1024 bytes or BLOCKSIZE environment variable (if it's set).
> for example
> 
> 1) ls -s (if no BLOCKSIZE env variable is set)
>  - file_blk_size  = (st_blocks*512)/1024.0
> 
> 
> 2) export BLOCKSIZE = 200
> ls -s
>  - file_blk_size = (st_blocks*512)/env_blksize
> 
> in both above cases if file_blk_size comes in decimal, you have to
> round that partial unit to next integer value.
> 
> 
> Now if -k or -h is combined with ls -s it modifies the ouput of ls -s
> command in the sen
> 
> 
> 
> 
> On 10/17/2014 12:50 AM, xxu15 at stevens.edu wrote:
>> 
>> Hi,
>> -k or -h is to show the file size, they override each other.
>> 
>> -s is to show the total number of blocks, which is a separate column.
>> So, I DON'T UNDERSTAND, IN LS.PDF, WHAT'S THE MEANING OF "-K / -H
>> MODIFIES THE -S OPTION".   
>> 
>> -------------------------
>> 
>> Sincerely,
>> Xiang Xu (徐祥)
>> Student ID: 10388813
>> tel: +1 (201) 918-0570
>>  +86 13851478402
>> qq: 185904095
>> _______________________________________________
>> cs631apue mailing list
>> cs631apue at lists.stevens.edu
>> https://lists.stevens.edu/mailman/listinfo/cs631apue
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue


More information about the cs631apue mailing list