Get devices list

8 posts / 0 new
Last post
mritter0
mritter0's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2014-04-21 21:15
Get devices list

I can find all the devices on the computer just fine: LockDosList(LDF_DEVICES | LDF_READ);

I then check doslist->dol_Port to filter out non-DH0:, non-DF0:, etc. But it still allows ENV:, APPDIR:, and a few others through.

Is there an easy way to only get DFx:, DHx:, RAM:, RAD:, CDx: USB: ? Physical devices.

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
That dol_Port is initialized

That dol_Port is initialized doesn't necessarily mean that it's a filesystem. You should use IDOS->IsFileSystemPort() to check this.

Also to discount ENV: and APPDIR: make sure that there is a valid volume. You can do that using IDOS->GetDiskInfo(). Just make sure that the returned id_VolumeNode is non-zero and a valid BPTR (top two bits should be cleared).

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
Also to discount ENV: and


Also to discount ENV: and APPDIR: make sure that there is a valid volume. You can do that using IDOS->GetDiskInfo(). Just make sure that the returned id_VolumeNode is non-zero and a valid BPTR (top two bits should be cleared).

Colin Wenzel has informed me that the above that the above won't work because ENV: and APPDIR: do have volume nodes though they are not public (i.e. added to the doslist).

It looks like the best way might be to look for a DLT_VOLUME entry with the same dol_Port value as the DLT_DEVICE entry. If you can't find one then it's either a filesystem like ENV:/APPDIR: or there simply is no disk inserted there.

mritter0
mritter0's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2014-04-21 21:15
I updated the code with what

I updated the code with what you put here and some other stuff found on Hyperion's forum. Still not perfect but just do a name check for ENV: and APPDIR: and skip them.

Thanks

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
Colin Wenzel has suggested to

Colin Wenzel has suggested to me that you should just use AllocDosObject(DOS_VOLUMELIST, ...) (available in dos.library V53.52+) to get a list of current volumes rather than manually running the doslist (which is discouraged).

mritter0
mritter0's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2014-04-21 21:15
That will work, too. But I

That will work, too. But I am thinking that only lists the devices with a disk inserted. i want to find them all, then check if has disk inserted. I will keep trying different ways.

salass00
salass00's picture
Offline
Last seen: 6 months 1 week ago
Joined: 2011-02-03 11:27
Still not perfect but just do


Still not perfect but just do a name check for ENV: and APPDIR: and skip them.

Rather than doing checks against some hard coded names you can use IDOS->GetDiskFileSystemData(). It will fail if the device is not for a standard block storage file system.

mritter0
mritter0's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2014-04-21 21:15
Using GetDeviceProc() and

Using GetDeviceProc() and IsFileSystemPort() lets ENV: and APPDIR: through with the real devices. Good.

Then check with GetDiskFileSystemData() ignores ENV: and APPDIR: (good) but also ignores RAM:.
So I do a name check for RAM: to not check GetDiskFileSystemData() and all is good.

Not 100% full proof but darn close.

Thanks!

Log in or register to post comments