Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

99.4. mtools-4.0.49

Collection of utilities for DOS disks in Unix

Version 4.0.49, release 1
Shelf filesystem — Filesystem utilities, FUSE, and network or encrypted filesystems
Phase 41_system (System), 218 of 1047 in build order
Licence GPL-3.0-or-later
Homepage https://www.gnu.org/software/mtools/
Build time 0.3 SBU
Installed size 501.0 KiB in 62 files
Recipe ports/core/filesystem/mtools/kpkgbuild

About

GNU mtools reads and writes MS-DOS FAT filesystems without mounting them: mcopy, mdir, mformat, mmd and the rest work on a device or an image file directly, as an ordinary user. In KDOS its consumer at build time is limine, whose configure needs mcopy to build limine-uefi-cd.bin, the FAT image inside the ISO that UEFI firmware boots from. gparted depends on it as well.

Sources

Dependencies

Depends on: nothing a recipe names.

Required by (2): gparted, limine.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install mtools'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/filesystem/mtools.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/filesystem/mtools
echo '6fe5193583d6e7c59da75e63d7234f76c0b07caf33b103894f46f66a871ffc9f  mtools-4.0.49.tar.bz2' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/mtools
SRC=$SRC_ROOT/mtools-4.0.49
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf mtools-4.0.49.tar.bz2 -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

./configure --prefix=/usr \
            --sysconfdir=/etc/default \
            --disable-floppyd \
            --without-x
make
make DESTDIR=$PKG install
rm -f $PKG/usr/share/man/man1/floppyd.1 $PKG/usr/share/man/man1/floppyd_installtest.1

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/mtools, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf mtools-4.0.49-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/mtools, and runs the triggers its paths call for.

Contents

Installed programs: amuFormat.sh, lz, mattrib, mbadblocks, mcat, mcd, mcheck, mcomp, mcopy, mdel, mdeltree, mdir, mdoctorfat, mdu, mformat, minfo, mkmanifest, mlabel, mmd, mmount, mmove, mpartition, mrd, mren, mshortname, mshowfat, mtools, mtoolstest, mtype, mxtar, mzip, tgz, uz.

Installed directories: /usr/share/licenses/mtools.

Short descriptions

mattrib change MSDOS file attribute tags
mbadblocks tests a floppy disk, and marks the bad blocks in the FAT
mcat dump raw disk image
mcd change MSDOS directory
mcopy copy MSDOS files to/from Unix
mdel delete an MSDOS file
mdeltree recursively delete an MSDOS directory and its contents
mdir display an MSDOS directory
mdoctorfat doctors the allocation table of a file
mdu display the amount of space occupied by an MSDOS directory
mformat add an MSDOS filesystem to a low-level formatted floppy disk
minfo print the parameters of a MSDOS filesystem
mkmanifest makes list of file names and their DOS 8+3 equivalent
mlabel make an MSDOS volume label
mmd make an MSDOS subdirectory
mmount mount an MSDOS disk
mmove move or rename an MSDOS file or subdirectory
mpartition partition an MSDOS hard disk
mrd remove an MSDOS subdirectory
mren rename an existing MSDOS file
mshortname shows short name of a file
mshowfat shows FAT clusters allocated to file
mtools utilities to access DOS disks in Unix.
mtoolstest tests and displays the configuration
mtype display contents of an MSDOS file
mzip change protection mode and eject disk on Zip/Jaz drive

Notes

floppyd.1 and floppyd_installtest.1 are in the Makefile’s list of manual pages whether the programs are built or not, so make install installs both pages. The recipe deletes them, so the package carries no page for a program it does not contain.