Bootable/non-bootable and fixed/removable

3 posts / 0 new
Last post
OldFart
OldFart's picture
Offline
Last seen: 15 hours 40 sec ago
Joined: 2010-11-30 14:09
Bootable/non-bootable and fixed/removable

Hi there,

The title may sound a bit cryptic, but I was wandering how I can detect whether a volume is bootable or not and whether a volume is fixed, meaning not removable.

Any ideas?

OldFart

thomas
thomas's picture
Offline
Last seen: 4 hours 5 min ago
Joined: 2011-05-16 14:23
Re: Bootable/non-bootable and fixed/removable

Short answer: you cannot.

Long answer: AmigaDOS does not maintain this information. Bootable devices are collected by expansion.library before AmigaDOS is started. It determines "the" boot device and gives it to AmigaDOS. After that AFAIK the list is lost. And from AmigaDOS' point of view all devices are removable. Each masstorage device has a device and a volume entry. Volumes may move from one device to another. For example the boot floppy can be moved from DF0 to DF1.

You can however do some guesses. You can traverse the list of DOS devices to find the FileSystemStartupMessage of each device. The FSSM contains the exec device and unit number as well as a pointer to the DOS environment vector which contains the mount data. But be careful, the startup pointer does not need to point to a FSSM. Check if the pointer points to memory and is not just a number before you reference it.

With the device/unit information you can send a TD_GETGEOMETRY command to the underlying exec device. If the command succeeds, the returned data contains a SCSI device type and a removable flag.

If TD_GETGTEOMETRY does not work you can try HD_SCSICMD with a SCSI INQUIRY command. If the device supports the command, it will return the SCSI device type and the removable flag, too.

If either of the two commands succeed, it's likely that you find the RigidDiskBlock in the first few sectors of the disk. Then you can find the partition entries which contain the information whether a partition is bootable or not.

If the device is not a harddisk, you can check the DOS environment vector. If the table size is large enough to include the boot priority, the device might be bootable.

To find out the device which booted the current session, you can call CurrentDir(0) followed by Lock("").

OldFart
OldFart's picture
Offline
Last seen: 15 hours 40 sec ago
Joined: 2010-11-30 14:09
Re: Bootable/non-bootable and fixed/removable

Thanks for your clear, and hence long, answer.

OldFart

Log in or register to post comments