leowribeiro
Programmer
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.
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.