Filesystem Usage / Information: di Tcl extension

The di program provides a Tcl extension.

Current Version: 4.49 https://sourceforge.net/projects/diskinfo-di/

2020-6-3: a .zip file with pre-built binaries and a pkgIndex.tcl file is now available. The "tcl-diskspace" .zip file contains binaries for Windows 32/64, Linux 32/64 and MacOS.


Website: https://diskinfo-di.sourceforge.io/

Author: bll

di is a highly portable program to display disk information. It features the ability to display the disk usage in the format you prefer.

The 'di' Tcl interface provides a 'diskspace' command that returns a dictionary with the filesystem information.

The dictionary returned is nested and keyed by the mount point. The dictionary keys are: device, fstype, total, free, available, totalinodes, freeinodes, availableinodes, mountoptions, display.

The total, free and available space are returned as bytes.

'display' is returned when the di format specifier is not empty. The data returned is a list of the display items.

Any of the di options may be used to change the data returned in the 'display' key. See the di manual page for the complete list.

Example usage:

% package require diskspace

% set di [diskspace -f {} /] ; # get only the basic information for root filesystem
/ {device /dev/sda1 fstype ext4 total 485893496832 free 269818650624 available 245113102336 totalinodes 30138368 freeinodes 29762805 % availableinodes 29762805 mountoptions rw,errors=remount-ro}

% set di [diskspace -f {up} /] ; # also get the used space and percentage used.
/ {display {201.2G      50%} device /dev/sda1 fstype ext4 total 485893496832 free 269818736640 available 245113188352 totalinodes 30138368 freeinodes 29762805 availableinodes 29762805 mountoptions rw,errors=remount-ro}
% lassign [dict get $di / display] useddisplay percused

% set di [diskspace -d 1 -f up /] ; # instead, get the used value in bytes.
/ {display {216074854400        50%} device /dev/sda1 fstype ext4 total 485893496832 free 269818642432 available 245113094144 totalinodes 30138368 freeinodes 29762805 availableinodes 29762805 mountoptions rw,errors=remount-ro}
% lassign [dict get $di / display] usedbytes percused

% set di [diskspace -f {}] ; # get information on the usual list of filesystems.

To build the Tcl extension:

Most systems:

    cd C
    make tcl-sh

Windows Cygwin:

    cd C
    make CC=gcc NO_PIE=T NO_TLS=T tcl-sh

Windows Msys:

    cd C
    make WINAPI=T NO_PIE=T NO_TLS=T LDFLAGS_SHARED="-static-libgcc" tcl-sh

 Updates

Update 2018-8-12: Fixed all bugs found by scan.coverity.com. Configuration for the Tcl interface has been improved.

Update 2018-4-11: The memory bug has been fixed in the Tcl interface, and various exit conditions (malloc failures, invalid options, --help, --version) are now handled properly.

Update 2017-5-23: Updated to di version 4.44 (Exabyte overflow bug).

Update 2016-8-26: The pre-built libraries now include .dll for windows with statically linked libgcc.

Update 2016-8-9: I now have pre-built shared libraries available for the Tcl extension.