[cs631apue] Problems with Blocksize

Jan Schaumann jschauma at stevens.edu
Thu Oct 16 17:57:22 EDT 2014

Chenyi Zhang <czhang42 at stevens.edu> wrote:
> I am getting confused by get really blocks stored in disk or just using the
> file_size / size in 512?

The manual page states:

-s Display the number of file system blocks actually used by each file, in
   units of 512 bytes or BLOCKSIZE (see ENVIRONMENT) where partial units are
   rounded up to the next integer value.  If the output is to a terminal, a
   total sum for all the file sizes is output on a line before the listing.

This is the behaviour your version of ls(1) should exhibit.

Note that the Linux version of ls(1) may not follow the same semantics,
and neglects to describe in its manual page exactly what it means by

Try to see how the Linux version behaves by comparing the following

ls -s
ls -sk
BLOCKSIZE=1024 ls -s
BLOCKSIZE=512 ls -s
BLOCKSIZE=2048 ls -s
BLOCKSIZE=-512000 ls -s
BLOCKSIZE="this is not a number" ls -s


More information about the cs631apue mailing list