Find the answer to your Linux question:
Results 1 to 2 of 2
Hi guys, I've been developing a program that opens a pipe to a subprocess spawned with 'du' command. It builds a model of the file system using complex algorithms based ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    6

    Question Du command inconsistency.. Or, is it?


    Hi guys,
    I've been developing a program that opens a pipe to a subprocess spawned with 'du' command. It builds a model of the file system using complex algorithms based on the list of files and directories combined with the size information retrieved by the du command.
    During the test i noticed some inconsistencies with what the sizes of the file system the program models and the actual file system size. So took some time to figure out the reason behind it.
    It turns out that if I sum up every item listed from 'du -a /target', the sum of the sizes of the files and directories are different from what 'du' command returns as total.
    for example, the following if the output from a du command on a specific target:

    32 scabs/Archive.C
    32 scabs/archive.conf
    32 scabs/Archive.h
    64 scabs/Archive_suse.o
    32 scabs/Backup.C
    32 scabs/backup.conf
    32 scabs/Backup.h
    128 scabs/Backup_suse.o
    32 scabs/CheckFailedException.C
    32 scabs/CheckFailedException.h
    32 scabs/CheckFailedException_suse.o
    32 scabs/CheckVisitor.C
    32 scabs/CheckVisitor.h
    192 scabs/CheckVisitor_suse.o
    32 scabs/DumpFailedException.C
    32 scabs/DumpFailedException.h
    32 scabs/DumpFailedException_suse.o
    32 scabs/PlanVisitor.h
    32 scabs/DumpVisitor.C
    32 scabs/DumpVisitor.h
    256 scabs/DumpVisitor_suse.o
    32 scabs/ErrVisitor.C
    32 scabs/ErrVisitor.h
    64 scabs/ErrVisitor_suse.o
    32 scabs/mailSender.py
    32 scabs/mailSender.pyc
    32 scabs/MailVisitor.C
    32 scabs/MailVisitor.h
    64 scabs/MailVisitor_suse.o
    32 scabs/main.C
    64 scabs/main_suse.o
    32 scabs/Makefile
    32 scabs/Makefile.orig
    32 scabs/Makefile.svn
    32 scabs/PlanVisitor.C
    256 scabs/PlanVisitor_suse.o
    32 scabs/pre_split_archive.py
    32 scabs/pre_split_backup.py
    32 scabs/SCABS.C
    32 scabs/SCABSException.C
    32 scabs/SCABSException.h
    32 scabs/SCABSException_suse.o
    32 scabs/SCABS.h
    160 scabs/SCABS_suse.o
    32 scabs/split_archive.py
    32 scabs/split.py
    32 scabs/Tape.C
    32 scabs/Tape.h
    32 scabs/TapeOverFlowException.C
    32 scabs/TapeOverFlowException.h
    32 scabs/TapeOverFlowException_suse.o
    128 scabs/Tape_suse.o
    32 scabs/Tar.C
    32 scabs/TarElem.C
    32 scabs/TarElem.h
    64 scabs/TarElem_suse.o
    32 scabs/Tar.h
    128 scabs/Tar_suse.o
    32 scabs/Visitor.h
    64 scabs/wxmac.icns
    32 scabs/logs
    3200 scabs
    If I add all of the sizes that du listed before the grand total,
    it comes out to 3168kb

    but the du is claiming that the total is 3200kb.

    Oddly enough, if I do 'ls -l' on the same target, it give me total size of 3168kb.

    Can anyone explain what is happening here? I'm very confused

    Any help or insight will be appreciated!
    Thank you in advance.

    --
    Jin

  2. #2
    Just Joined!
    Join Date
    Mar 2007
    Posts
    6
    Sorry guys, I posted this in SUSE section, and after I found out about this section, I moved it to here.
    But while I was moving this, some lightning fast and very helpful member has already replied to the thread that I posted in the wrong section.

    Quote Originally Posted by gogalthorp View Post
    There is a difference in the size of a file and how much disk space that file consumes. How much space does a 1 byte file take up? Answer: depends on the block size of drive. So if you have a 1024 byte block a 1 byte long file will take up 1024 bytes of disk space. So it all depends on what you are measuring file length or disk space used.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •