Comment 1 for bug 935480

Revision history for this message
Jan Claeys (janc) wrote :

This looks like the same bug we are seeing in GParted: https://bugzilla.gnome.org/show_bug.cgi?id=693955

This is caused by an incorrect test in mkdosfs whether a device is a "hard disk":

    if (fstat(dev, &statbuf) < 0)
        die("unable to stat %s");
    if (!S_ISBLK(statbuf.st_mode)) {
        statbuf.st_rdev = 0;
        check = 0;
    } else
        /*
         * Ignore any 'full' fixed disk devices, if -I is not given.
         * On a MO-disk one doesn't need partitions. The filesytem can go
         * directly to the whole disk. Under other OSes this is known as
         * the 'superfloppy' format. As I don't know how to find out if
         * this is a MO disk I introduce a -I (ignore) switch. -Joey
         */
        if (!ignore_full_disk && ((statbuf.st_rdev & 0xff3f) == 0x0300 || /* hda, hdb */
                                  (statbuf.st_rdev & 0xff0f) == 0x0800 || /* sd */
                                  (statbuf.st_rdev & 0xff3f) == 0x0d00 || /* xd */
                                  (statbuf.st_rdev & 0xff3f) == 0x1600) /* hdc, hdd */
        )
        die("Device partition expected, not making filesystem on entire device '%s' (use -I to override)");

It makes certain apparently incorrect assumptions about how raw device numbers for full disks vs. partitions look like.
(It also doesn't use major()/minor() on the raw device number, which looks not very portable or future-proof to me...)