NetBSD-Users archive

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

Re: ls(1) displays wrong file sizes



On 2011-10-01 02.21, jgw%freeshell.org@localhost wrote:
Noticed this the other day; if I run 'du -h<random dir>' and compare
the files sizes to those reported by 'ls -sh1' they don't match. For
example:

# ls -sh1 PROJECTS/LISP/code/*.lsp
4.2K PROJECTS/LISP/code/fsvm.lsp
205B PROJECTS/LISP/code/hello.lsp
1.7K PROJECTS/LISP/code/recursion.lsp
1.1K PROJECTS/LISP/code/test.lsp
4.5K PROJECTS/LISP/code/tictactoe

# du -h PROJECTS/LISP/code/*.lsp
6.0K    PROJECTS/LISP/code/fsvm.lsp
2.0K    PROJECTS/LISP/code/hello.lsp
2.0K    PROJECTS/LISP/code/recursion.lsp
2.0K    PROJECTS/LISP/code/test.lsp
6.0K    PROJECTS/LISP/code/tictactoe.lsp

Not only do they not match, they don't seem to be off by any set amount
or ratio.  I don't have BLOCKSIZE set and my filesystem is the default
FFS.  Some system specifics below:

# sysctl kern. | head -n 4
kern.ostype = NetBSD
kern.osrelease = 5.0_STABLE
kern.osrevision = 500000003
kern.version = NetBSD 5.0_STABLE (GENERIC) #0: Fri Apr  2 03:45:48 UTC 2010

# disklabel wd0 | grep -B1 "^ a"
#        size    offset     fstype [fsize bsize cpg/sgs]
  a:   3984561        63     4.2BSD   2048 16384     0

# dumpfs -s / | head -n 9
file system: /dev/rwd0a
endian  little-endian
magic 11954 (UFS1)  time  Fri Sep 30 17:03:32 2011
superblock location 8192  id  [ 4bb67bda 87b5b2c ]
cylgrp  dynamic inodes  4.4BSD  sblock  FFSv2 fslevel 4
nbfree  90278 ndir  1798  nifree  223202  nffree  164
ncg 11  size  996140  blocks  980555
bsize 16384 shift 14  mask  0xffffc000
fsize 2048  shift 11  mask  0xfffff800

--

Is this a known issue/bug or is there something I've overlooked?

Maybe that actual disk usage for a file of 205 bytes is not really 205 bytes, but some multiple of the blocksize of the disk?

        Johnny


Home | Main Index | Thread Index | Old Index