![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Registered User Join Date: Dec 2009
Posts: 4
| df command can help to print out various disk space information for each file system and its underlying implementation relies on the statfs function. I do not know why, in its implementation, the way of getting the available size of a file system is : Code: f_bavail x f_bsize / 1024 ; // free blocks available to non-super user x block size of the file system / 1 Kbyte Code: f_bfree x f_bsize / 1024 // total free blocks of the file system x a block size of the file system / 1 Kbyte Thanks~ |
| learn is offline | |
| | #2 | |
| mastering the obvious Join Date: Jul 2008 Location: SE Queens
Posts: 5,071
| Here's what I think is being referred to here: On an ext2/3/4 filesystem -- which may or may not be the filesystem used in embedded devices, but it is on most normal linux boxes -- 5%* is "reserved for the super-user". This is supposedly to insure there will be space available to important privileged processes if for some reason the filesystem fills up. AFAIK, it is not a good idea to run any OS in a filesytem that is more than 90% full -- it will result in significant, noticable performance degradation, so, most people don't do it. In reality, then, I would guess that 5% is never used -- which may be good, since that may reduce fragmentation (which man mke2fs claims). Pretty sure it is these which are excluded from f_bavail. Based on what you present, it's still not totally clear that it is included in f_bfree, but in any case, IMO the idea is that those reserved super-user blocks are intended for an emergency and should never be intentionally used unless the other 95% is full (and such a situation would be an emergency). Ie, no don't include them in any kind of free or available space count -- either there is other space that should be used, or else these should still be left free for whatever critical operations that will need to occur either to shut the system down or free more space. In fact, I'm sure of that, judging by the df manpage: Quote:
However, it is possible to create an ext2/3/4 filesystem with 0% reserved blocks (this is what I normally do with usb keys, mounted partitions, etc -- only the root filesystem has reserved space) which is probably the case in embedded environments. If there are no reserved blocks, the issue is moot. *by default; you can set this amount when you create the filesystem
__________________ “The essential element in the black art of obscurantism is not that it wants to darken individual understanding, but that it wants to blacken our picture of the world, and darken our idea of existence.” [Friedrich Wilhelm Nietzsche, 1878] Last edited by MK27; 12-27-2009 at 10:40 AM. | |
| MK27 is online now | |
| | #3 |
| Registered User Join Date: Dec 2009
Posts: 4
| Hi MK27, Thank you very much for your help. The information are very clear, informative, and to-the-point. Especially the illustration/analysis from the man page and your personal view. Thanks! |
| learn is offline | |
| | #4 |
| Senior software engineer Join Date: Mar 2007 Location: Portland, OR
Posts: 5,753
| Whether to use f_bfree or f_bavail is a matter of your own policy. If you want to include the superuser blocks in the count, then include them. Otherwise, don't. It's a simple change to the source for df...
__________________ "Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot |
| brewbuck is online now | |
| | #5 |
| Registered User Join Date: Jan 2010
Posts: 1
| can u help me for "implementationof ls command in C" |
| vanita is offline | |
| | #6 |
| mastering the obvious Join Date: Jul 2008 Location: SE Queens
Posts: 5,071
| Start here: Accessing Directories - The GNU C Library
__________________ “The essential element in the black art of obscurantism is not that it wants to darken individual understanding, but that it wants to blacken our picture of the world, and darken our idea of existence.” [Friedrich Wilhelm Nietzsche, 1878] |
| MK27 is online now | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What about the problem of "no matching symbolic information found"in this function? | gjgcstick | C Programming | 5 | 06-01-2009 07:54 PM |
| Going out of scope | nickname_changed | C++ Programming | 9 | 10-12-2003 06:27 PM |
| hard disk space and spyware | oldmancan | A Brief History of Cprogramming.com | 5 | 01-23-2003 01:24 AM |
| Special Allegro Information | TechWins | Game Programming | 12 | 08-20-2002 11:35 PM |
| Information about disk | GaPe | C Programming | 18 | 08-05-2002 06:48 AM |