Available free space on HD

This is a discussion on Available free space on HD within the C Programming forums, part of the General Programming Boards category; Hello guys, I have a doubt. I need write a FTP like program (client and server) and I need to ...

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    1

    Question Available free space on HD

    Hello guys, I have a doubt.

    I need write a FTP like program (client and server) and I need to write a function that tells me the amount of free space on HD (to know if there is enough space to transfer the file).

    So I informed myself and discovered that the "statvfs" function would resolve my problems. (I'm only using C language exclusively)

    With "statvfs" you get the number of free blocks and the size (in bytes) of a block, so I think that the free space on disk (in bytes) is the following multiplication => "free blocks" x "size of a block"

    Doing that I got "955344498688 bytes" ( I have an 1 TB HD), that's about 889.73 GB.

    When I execute the "df -h" command on the terminal, it gives me this :

    Filesystem Size Used Avail Use% Mounted on
    /dev/sda1 915G 26G 844G 3% /

    When I run "nautilus" (I'm on linux, of course), it says I have 905.4 GB of free space on the file system.

    Can anyone explain me why do I have THREE different values for the free space on disk?? Which one should I believe?

    Thank you all.

  2. #2
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Free allocated space
    By Fader_Berg in forum C Programming
    Replies: 1
    Last Post: 10-31-2010, 08:49 AM
  2. How to deallocate space with free.
    By brack in forum C Programming
    Replies: 18
    Last Post: 08-27-2010, 02:41 AM
  3. Free space in printf
    By arya6000 in forum C Programming
    Replies: 5
    Last Post: 10-05-2007, 08:19 AM
  4. Why should I use the Free Space (heap)
    By BlackSlash12 in forum C++ Programming
    Replies: 8
    Last Post: 09-09-2007, 07:57 PM
  5. How do I get the free space on the CDROM?
    By loobian in forum C++ Programming
    Replies: 5
    Last Post: 10-27-2003, 10:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21