Detect the DOS disk

From: Michele Andreoli (
Date: Mon Dec 18 2000 - 17:55:02 CET

This is a little C program compiled for DOS. The intention is to
put this command in every .bat in the dosinstaller, helping muLinux
to find the disk where the user located the images.

The command (called diskinfo.exe) simply outputs a string like:


Example (for my Win98) is:


It meas: disk number 2, label C, directory c:\mu, total kB and
free KB on the hard-disk

The string has the right syntax to be passed, via loadlin, to
the linux kernel and parsed by the boot scripts.

You know, currently muLinux scan every disk and every directory
searching for its images! Using this trick, the boot script can
detect the exact directory and the exact disk the user
issued the command "boot.bat" from.

The values are parsed, then compared with info found using fdisk
in muLinux. I do not know if someone on the list know some more
smart solution.

How to find the right disk? The dos label "C" is unknow to Linux,
obiously. But, if we are lucky, the total disk space is the same
in the two world, or I'm wrong?

It it works, we need to parse the "fdisk -l" output, converting
cylinder boundary and block's sizes in Kb, finding the best
(or exact) match. Can we trust in the poor muLinux fdisk output?


#include <stdio.h>
#include <dos.h>
#include <dir.h>

  diskinfo.c (C) 2000 Michele Andreoli, for muLinux
  output: diskinfo=current-disk,disk-label,
                current-dir,disk-size K,disk-free K

char buf[1024];
double sclus;
int cdisk;
double tot,avail;

struct dfree df;


printf ("diskinfo=%d,%c,%s,%.0f,%.0f\n",cdisk,disks[cdisk], buf,

In summing up, I wish I had some kind of affirmative message to leave
you with, I don't. Would you take two negative messages? - Woody Allen
To unsubscribe, e-mail:
For additional commands, e-mail:

This archive was generated by hypermail 2.1.6 : Sat Feb 08 2003 - 15:27:17 CET