Overview
df - better than *nix clone of df (disk free): tells the disk free space, percentage of free space, disk used, and total disk space in SI or CS computer units or as a plain number of bytes in verbose mode or as user-defined-units.
df - stands for disk free. shows you disk free space. (also, disk space used). but unlike the UNIX df utility which gives results in useless 512-byte blocks, this gives results in SI units, which is what the disk industry uses to measure disk space by. Microsoft uses TiB, GiB, MiB, KiB, whereas the disk industry uses TB, GB, MB, KB.this is a command-line tool. djgpp, and MinGW-w64 compiled executables with sources [DOS 32-bit, windows 32+64-bit]). The DOS version seems to be limited to 4GiB. The windows version is limited to 92.2 Petabytes (<57 bits or 92,233,720,368,547,758 bytes).
This program supports large-sector disks (not hard-coded to 512-byte sectors).
--units switch shows numbers in terms of (divides output by) the number you give. so you can get output in terms of UNIX df (512) or microsoft disk size format (1_kib=1024).
dos version now supports windows 9x's int21h 7303h FAT32 disk free space call (FreeDOS & win9x uses this windows 9x as well but not FreeDOS although the windows version works as well).
there was UNC support, but it was canceled due to weirdness with numbers returned from OS on XP Pro (code is still in there if you want to compile it back in for your company).
It is available as a single df.zip file which contains the source and executeables.
Downloads
right click on the download button and pick save target as(ff) or save link as (ie) or click on the button(chrome, safari)
I now have a FreeDOS system that has FAT32 on it. I tested the DOS program's FAT32 code (int21h function 7303h) and it works.
as for a VM, I have no clue how to set up a (safe) FreeDOS VM that also has access to my files. one that is ready-made would be very welcome. I can't "insert a floppy" to do my VM work since VirtualBox doesn't recognize floppies! I have seen no freedos VM's. and I don't know how to make a FreeDOS usb stick. I may have to go to VMWare, VirtualBox's Guest Additions are throrughly broken.
07/17/2011 11:12 PM 5,069,040 df.zip %%%% HASHDEEP-1.0 %%%% size,md5,sha1,sha256,filename ## Invoked from: C:\prj\df ## C : \ > hashdeep -c md5,sha1,sha256 df.zip ## 5069040,357e94677fa0b19a97e4ec2d33a6b1ae,412e2ea8bda13aafa79ad48bf327b2fc87e96f63,05202ac243dcbc07abb221a5da805bb526284a6ff1a8d6a8c8 6803c5353f2e64,C:\prj\df\df.zip
The program has been compiled for 32 and 64-bit machines using MinGW, and supports dos/freedos/9x/me/nt/2000/2003/2008/2008 r2/xp/vista/7/8/etc but I don't think it supports windows 3.1 due to the 32-bit nature of it (you could try it and see though).
actually, it shows you disk free space, total space for the drive letter, and percentage, and a graph. at the end there is total free for all drive letters and total used for all drive letters so you don't have to get out a calculator.
optionally, you can get the verbose mode (-verbose) which shows you the exact number of bytes instead of using SI units to display numbers.
And if df's on UNIX or you have UNIX tools installed on your computer, you probably won't want to call it df.exe. rename it df1.exe or something like that. (UNIX machines of course do not use a .exe extension)
This was compilable with Borland C++ 5.5.1, MSVC++ and mingw-w64 (what I used) and djgpp (dos 32-bit).
success for win32, dos, and dos using FAT32 calls. mingw was attempted but the libraries are not borland-like, they are microsoft-like so they don't work at all and I don't currently know what the equivelant Win32 calls are for getting disk free and used space is. Help appreciated here.
chkdsk /f (microsoft disk size measurement)
so let's show the difference between the microsoft way of doing things and the disk industry way of doing things:
E:\>chkdsk e:
The type of the file system is NTFS.
Volume label is samsung 2000.
WARNING! F parameter not specified.
Running CHKDSK in read-only mode.
CHKDSK is verifying files (stage 1 of 3)...
File verification completed.
CHKDSK is verifying indexes (stage 2 of 3)...
Index verification completed.
CHKDSK is verifying security descriptors (stage 3 of 3)...
Security descriptor verification completed.
CHKDSK is verifying Usn Journal...
Usn Journal verification completed.
1953503968 KB total disk space.
944566276 KB in 1935905 files.
646464 KB in 126973 indexes.
0 KB in bad sectors.
2873332 KB in use by the system.
65536 KB occupied by the log file.
1005417896 KB available on disk.
4096 bytes in each allocation unit.
488375992 total allocation units on disk.
251354474 allocation units available on disk.
E:\>c:\u\df -verbose e
*E:1029547663360/2000388063232 (51%)
TOTAL FREE: 1029547663360/2000388063232 (51%)
TOTAL USED: 970840399872/2000388063232 (48%)
E:\>
1029547663360/2^10=1,005,417,640
1029547663360/1024=1,005,417,640
to convert (my) disk industry size in number of bytes to microsoft's computer KiB, divide by 1024 or 2^10.
I right click on c: and pick properties, and I see the bar graph which says I have 1.11TB free space (it does not do rounding). I do df and I see I have 1.23TB free space. I know that because microsoft is using powers of 2, they are going to get a smaller number. calculate that yourself and see.
C:\cd>\u\df -verbose c
*C:1231090249728/2000397758464 (61%)
TOTAL FREE: 1231090249728/2000397758464 (61%)
TOTAL USED: 769307508736/2000397758464 (38%)
C:\prj\df>\u\df * -a
*C:------------------********************** 1.13TB/ 2.00TB (56.63%)
D:---------------------------------------- 0.00B/ 2.36MB (0.00%)
E:------------------********************** 1.10TB/ 2.00TB (55.23%)
TOT:------------------********************** 2.23TB/ 4.00TB (55.93%)
TOT USED:-----------------------***************** 1.76TB/ 4.00TB (44.07%)
C:\prj\df>
1231090249728/2^40=1.119,670,059,531,927,108,764,648,437,5
exactly what microsoft reports. it's the microsoft power-of-2 thing.
(2TB drive, 2TB=2e12)
I have tried BOTH free space reporting numbers given by the OS using GetDiskFreeSpaceEx(), and BOTH return this number. and neither matches up with the numbers given by chkdsk. So if you are trying to shore my program up with chkdsk, I can't help you out, because I am not about to go through the entire filesystem to find this information out. that requires writing filesystem drivers, etc. and I am not up to that. and besides, nobody is going to take out minimum 1/4 day of their time rummaging through the filesystem on a 2TB disk (let alone a Clariion or EMC RAID) to find out how much disk space a program has. it's just not worth it, especially when you have a function that does this in a split second.
Microsoft has provided the Win32 functions GetDiskFreeSpace() and GetDiskFreeSpaceEx() (same thing, just more of it, I use the latter) to developers who need the free disk space number(s). That is what I intend to use for my own sanity.
If you want to use df to get chkdsk or UNIX-df like results (graph or --verbose), for verbose, simply specify --verbose or -verbose or /verbose and --unit or --intermsof followed by the number of bytes. see these examnples for UNIX and microsoft disk sizes.
Wed 06/01/2011 0:45:46.06|C:\prj\df\df-3.5\win\32|>df -unit 512
*C:░░░░░░░░░░░░░░░░░░██████████████████████ 2.24G/ 3.90G (57.49%)
TOT:░░░░░░░░░░░░░░░░░░██████████████████████ 2.24G/ 3.90G (57.49%)
TOT USED:░░░░░░░░░░░░░░░░░░░░░░░█████████████████ 1.66G/ 3.90G (42.51%)
Wed 06/01/2011 0:45:46.37|C:\prj\df\df-3.5\win\32|>df -unit 1:kib
*C:░░░░░░░░░░░░░░░░░░██████████████████████ 1.12G/ 1.95G (57.49%)
TOT:░░░░░░░░░░░░░░░░░░██████████████████████ 1.12G/ 1.95G (57.49%)
TOT USED:░░░░░░░░░░░░░░░░░░░░░░░█████████████████ 830.38M/ 1.95G (42.51%)
Wed 06/01/2011 0:45:46.70|C:\prj\df\df-3.5\win\32|>df -unit 512 -verbose
*C:2246264296/3907026872 (57.49%)
TOT:2246264296/3907026872 (57.49%)
TOT USED:1660762576/3907026872 (42.51%)
Wed 06/01/2011 0:45:47.00|C:\prj\df\df-3.5\win\32|>df -unit 1:kib -verbose
*C:1123132148/1953513436 (57.49%)
TOT:1123132148/1953513436 (57.49%)
TOT USED:830381288/1953513436 (42.51%)
"Windows: No Disk..." error dialog
There is a problem with some virtual floppy drivers that half-stay-around as "installed" but don't actually provide a drive until you activate them from the command-line. (I don't like that). This means that the driver in the system is active, providing a drive letter to the system when it scans for drive letters, but when you use IO_STORAGE_CHECK_VERIFY to see if there's anything in the drive, you get bogus results because only half of the driver is loaded.
When you have used IOCTL_STORAGE_CHECK_VERIFY to see if a removeable drive is actually got media in it or not, and it turns out the drive doesn't, this driver actually returns the wrong value and says that something is there when it is not.
the end result of this is it causes an error message "Windows: No disk (c0000013...)" which c0000013 means NO_MEDIA_IN_DRIVE. The fix for this is to use the /Q or /QUIT option to tell the driver to QUIT on failure.
there have been reports that this has been caused by a virus, and some have said that this is caused by XP's SP3. I get this, and I have SP3.
annoying, and you can't catch(){...} it because it's thrown by the OS (XP). If you are getting this error dialog and you don't have the virtual floppy drivers installed, I want to know about it. please let me know what kind of drives you have on your system (card readers [on printers and other card readers], cdroms, etc) and what drive letters they are, and what df reports for output.
Examples
Sun 07/17/2011 0:00:57.53|C:\prj\df\df-3.5\win\32|>df -ver
Version 3.5
Sun 07/17/2011 0:00:57.98|C:\prj\df\df-3.5\win\32|>df -a @
*C:------------------********************** 1.12TB/ 2.00TB(56.25%)
E:--------------------------************** 709.80GB/ 2.00TB(35.48%)
TOT:----------------------****************** 1.83TB/ 4.00TB(45.87%)
TOT USED:-------------------********************* 2.16TB/ 4.00TB(54.13%)
Sun 07/17/2011 0:01:01.96|C:\prj\df\df-3.5\win\32|>df -a c
C:------------------********************** 1.12TB/ 2.00TB(56.25%)
TOT:------------------********************** 1.12TB/ 2.00TB(56.25%)
TOT USED:-----------------------***************** 875.22GB/ 2.00TB(43.75%)
Sun 07/17/2011 0:01:03.29|C:\prj\df\df-3.5\win\32|>df -verbose @
*C:1125172944896/2000397758464(56.25%)
E:709800292352/2000388063232(35.48%)
TOT:1834973237248/4000785821696(45.87%)
TOT USED:2165812584448/4000785821696(54.13%)
Sun 07/17/2011 0:01:07.00|C:\prj\df\df-3.5\win\32|>df -a *
*C:------------------********************** 1.12TB/ 2.00TB(56.25%)
E:--------------------------************** 709.80GB/ 2.00TB(35.48%)
TOT:----------------------****************** 1.83TB/ 4.00TB(45.87%)
TOT USED:-------------------********************* 2.16TB/ 4.00TB(54.13%)
Sun 07/17/2011 0:01:09.54|C:\prj\df\df-3.5\win\32|>df -verbose foo.bar
ERROR:A: is not a valid drive.
ERROR:B: is not a valid drive.
ERROR:F: is not a valid drive.
ERROR:O: is not a valid drive.
ERROR:R: is not a valid drive.
*C:1125172944896/2000397758464(56.25%)
TOT:1125172944896/2000397758464(56.25%)
TOT USED:875224813568/2000397758464(43.75%)
Sun 07/17/2011 0:01:10.79|C:\prj\df\df-3.5\win\32|>df -a \\.\A: \\.\C: \\.\E: \\.\D: \\.\b:
UNC names not supported. I get bogus results from the OS.
UNC names not supported. I get bogus results from the OS.
UNC names not supported. I get bogus results from the OS.
UNC names not supported. I get bogus results from the OS.
UNC names not supported. I get bogus results from the OS.
*C:------------------********************** 1.12TB/ 2.00TB(56.25%)
TOT:------------------********************** 1.12TB/ 2.00TB(56.25%)
TOT USED:-----------------------***************** 875.22GB/ 2.00TB(43.75%)
Sun 07/17/2011 0:01:12.01|C:\prj\df\df-3.5\win\32|>df -unit 512
*C:░░░░░░░░░░░░░░░░░░██████████████████████ 2.19G/ 3.90G(56.25%)
TOT:░░░░░░░░░░░░░░░░░░██████████████████████ 2.19G/ 3.90G(56.25%)
TOT USED:░░░░░░░░░░░░░░░░░░░░░░░█████████████████ 1.70G/ 3.90G(43.75%)
Sun 07/17/2011 0:01:13.42|C:\prj\df\df-3.5\win\32|>df -unit 1:kib
*C:░░░░░░░░░░░░░░░░░░██████████████████████ 1.09G/ 1.95G(56.25%)
TOT:░░░░░░░░░░░░░░░░░░██████████████████████ 1.09G/ 1.95G(56.25%)
TOT USED:░░░░░░░░░░░░░░░░░░░░░░░█████████████████ 854.71M/ 1.95G(43.75%)
Sun 07/17/2011 0:01:14.60|C:\prj\df\df-3.5\win\32|>df -unit 512 -verbose
*C:2197603408/3907026872(56.25%)
TOT:2197603408/3907026872(56.25%)
TOT USED:1709423464/3907026872(43.75%)
Sun 07/17/2011 0:01:15.82|C:\prj\df\df-3.5\win\32|>df -unit 1:kib -verbose
*C:1098801704/1953513436(56.25%)
TOT:1098801704/1953513436(56.25%)
TOT USED:854711732/1953513436(43.75%)
Sun 07/17/2011 0:01:17.26|C:\prj\df\df-3.5\win\32|>df -si *
*C:░░░░░░░░░░░░░░░░░░██████████████████████ 1.12TB/ 2.00TB(56.25%)
E:░░░░░░░░░░░░░░░░░░░░░░░░░░██████████████ 709.80GB/ 2.00TB(35.48%)
TOT:░░░░░░░░░░░░░░░░░░░░░░██████████████████ 1.83TB/ 4.00TB(45.87%)
TOT USED:░░░░░░░░░░░░░░░░░░░█████████████████████ 2.16TB/ 4.00TB(54.13%)
Sun 07/17/2011 0:01:21.35|C:\prj\df\df-3.5\win\32|>df -cs *
*C:░░░░░░░░░░░░░░░░░░██████████████████████ 1.02TiB/ 1.83TiB(56.25%)
E:░░░░░░░░░░░░░░░░░░░░░░░░░░██████████████ 661.05GiB/ 1.83TiB(35.48%)
TOT:░░░░░░░░░░░░░░░░░░░░░░██████████████████ 1.68TiB/ 3.65TiB(45.87%)
TOT USED:░░░░░░░░░░░░░░░░░░░█████████████████████ 1.99TiB/ 3.65TiB(54.13%)
Documentation
Sun 07/17/2011 0:01:25.37|C:\prj\df\df-3.5\win\32|>df -?
df - report disk free space with graphs
Usage: df [/?|-[-]?|-[-]h[elp]|/h[elp]] [-v[er[sion]]|/v[er[sion]]]
df [/verbose|-[-]verbose] [/a[scii]|-[-]a[scii]] [/SI|-[-]SI] [/CS|-[-]CS] [-[-]intermsof integer64|/intermsof integer64|-[-]unit[s] integer64|/unit[s] i
nteger64] [drivespec ...]
Switches are case insensitive.-? or -h or -help for this help.
-verbose for verbose mode: uses long numbers ir bytes or units instead of SI units.
-v or -ver or -version or --version or /v or /ver or /version prints version number and exits.
-a or -ascii uses ascii characters instead of graphic ones.
-SI (the default) specifies SI units (K, M, G, T, P, E) in terms of powers of 1000.
-CS specifies CS computer units (Microsoft style, Ki, Mi, Gi, Ti, Pi, Ei) in terms of powers of 1024.
-unit or -intermsof followed by integer64, divides the output by the amount (unit) you specify if you specify verbose mode. does not apply entirely to percentag
es (just the absolute values). It also switches off displaying of B on the end of SI units (for instance, instead of TB, it's just T).
integer64 is unsigned and case insensitive. it ignores underscores(_). it can be hexadecimal (start with 0x), decimal (plain number or start with 0d), octal (s
tart with 0, 0q, 0o), binary (start with 0b), and can be appended with SI units (:B :D :DB :H :HB :K :KB :M :MB :G :GB :T :TB :P :PB :E :EB :Z :ZB :Y :YB) or co
mputer units (:Ki :KiB :Mi :MiB :Gi :GiB :Ti :TiB :Pi :PiB :Ei :EiB :Zi :ZiB :Yi :YiB) as a multiplier suffix. priority will be given to longer suffixes in a s
tream of printable characters.
df @ or df * to list all drives that have media in them.
df with no arguments or df . for current drive.
drivespec is any letter from A-Z (case insensitive), colon (:) ignored, . adds the current drive, @ and * add all available valid drive letters.
drivespec can't use a UNC naming convention, such as \\server\sharename\ or \\.\A:\ or \\.\PhysicalDrive0\
The DOS version supports int21h function 7303h FAT32 calls for FreeDOS and windows 9x/me.
Example: df c f for the c: & f: drives.
Example: df -unit 1_kib foo.bar lists the current drive, a:, b:, f:, o:, r: in terms of microsoft 'computer KB' or 1024 bytes per KB in verbose mode.
Copyright 1993 Jim Michaels. under GPL3 License.
boilerplate
gcc compiler note: -fpack-struct cannot be used with iostream or anything to do with libstdc++ (including locale which includes iostream) without getting lots of errors.
The dos version is compiled with DJ Delorie's djgpp (gcc for DOS). It can be obtained at DJDelorie.com/djgpp.
The windows version was compiled with Borland C++ 5.5 (free edition). It is available at article (may include patches), free compiler (requires regisration).
The windows version was also compiled with MinGW 5.1.4 which is a GNU compiler set for windows. it has the peculiarity that it requires any use of __int64 to #include <basestd.h>, and it also doesn't allow 64-bit constants in the microsoft/borland style of appending i64 to the number. it requires you to use the gcc LL instead, however, printf does use %I64d rather than the normal gcc %lld. If you use %lld, your program will crash and do the DrWatson error report thing.
The GNU compiler set has the peculiar ability to glob filenames at the command line. this can be a nice or an unwanted feature. to get around it, aurround the * with double quotes "*". This includes DJGPP-generated and MinGW-generated code.
PHP is a programming language used for web page development and for applications and is available at http://php.net
ArgoUML is a UML diagramming tool used for designing programs and is available at http://argouml.tigris.org
License
It is under the GPL3 license.
Copyright 1993 Jim Michaels
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.