First, create a file larger than the limit and use the DD command.
Dd If =/dev/Zero of =/home/Leon/tmpfile BS = 1024 COUNT = 1048576
In this case, a 1 GB file is created.
TheProgram:
# Include <unistd. h> # include <stdlib. h> # include <stdio. h> # include <fcntl. h> int main (INT argc, char ** argv) {If (open ("tempfile", o_rdwr) <0) {fprintf (stderr, "Open error "); exit (-1);} If (unlink ("tempfile") <0) {fprintf (stderr, "unlink error"); exit (-1 );} printf ("file unlinked \ n"); sleep (15); printf ("done \ n"); exit (0 );}
During program sleep, run the DF command to check the hard drive space;
At the end of the program, run the DF command again to check the hard drive space, and the system will find that the hard drive space resource is 1 GB more.
However, when you run the "du" command, there will be no difference.
The reason is:
The unlink function is to delete a file without being accessed by any other file and without any progress.
Difference between du and DF:
The Du-s command accumulates the total number of directories, symbolic links, and blocks used by the specified file system;
The DF command displays the disk block distribution graph of the file system to obtain the total number of blocks and the remaining number.
Du is a user-level program and does not consider meta data (some disk blocks allocated by the system)