Easy way to find if device is locked/protected agains R/W

7 posts / 0 new
Last post
jabirulo
jabirulo's picture
Offline
Last seen: 4 hours 58 min ago
Joined: 2013-05-30 00:53
Easy way to find if device is locked/protected agains R/W

Hi, An easy way or DOS function that show me status of DEVICES (ONLY READ, R/W,...)?

That piece of code shows me all devices, but I can't find the mode to show if such devices are R/W or ONLY_READ.

  1. dn = (struct DeviceNode *)IDOS->LockDosList(flags);
  2. while( (dn = (struct DeviceNode *)IDOS->NextDosEntry( (struct DosList *)dn, flags)) )
  3. {
  4. if(dn->dn_Port != NULL)
  5. {
  6. // if( !strcmp((char *)BADDR(dn->dn_Name)+1, "RAM") ) // Skip RAM Disk
  7. // continue;
  8. IDOS->Printf("%s\n",(char *)BADDR(dn->dn_Name)+1 );

TIA

thomas
thomas's picture
Offline
Last seen: 10 hours 17 min ago
Joined: 2011-05-16 14:23
IDOS->Info() should be able

IDOS->Info() should be able to tell you.

jabirulo
jabirulo's picture
Offline
Last seen: 4 hours 58 min ago
Joined: 2013-05-30 00:53
@Thomas THX just used

@Thomas
THX just used GetDiskInfo (as sdk tells is better to use it instead of Info() ) well it seems to works :-) but find something "strange..

  1. ..
  2. dn = (struct DeviceNode *)IDOS->LockDosList(flags);
  3. while( (dn = (struct DeviceNode *)IDOS->NextDosEntry( (struct DosList *)dn, flags)) )
  4. {
  5. if(dn->dn_Port != NULL)
  6. {
  7. if( !strcmp( (char *)BADDR(dn->dn_Name)+1, "RAM") ) continue; // Skip RAM Disk
  8. result = IDOS->GetDiskInfoTags(GDI_MsgPortInput, dn->dn_Port,
  9. GDI_InfoData, &id,
  10. TAG_END);
  11. if(id.id_DiskState != ID_DISKSTATE_WRITE_PROTECTED)
  12. {
  13. // IDOS->FlushVolumePort(dn->dn_Port); // Requires dos.library V53.90
  14. // IDOS->InhibitPort(dn->dn_Port, TRUE); // Requires dos.library V53.88
  15. IDOS->Printf("Flushed/Inhibitted %s\n",(char *)BADDR(dn->dn_Name)+1);
  16. }
  17. }
  18. }
  19. IDOS->UnLockDosList(flags);
  20. ..

..if I protect my main volume SDH0 CD0 also gets portected ¿:-P

SHELL/CLI output:
#a.out (normal)
Flushed/Inhibitted SDH0
Flushed/Inhibitted CD0
Flushed/Inhibitted SDH1
Flushed/Inhibitted SDH2
Flushed/Inhibitted SDH3
Flushed/Inhibitted SDH5
Flushed/Inhibitted SDH7
Flushed/Inhibitted SDH8
Flushed/Inhibitted ENV
Flushed/Inhibitted TEXTCLIP
#a.out (using RAWBInfo or Lock cmd and locking/protecting only SDH0)
Flushed/Inhibitted SDH1
Flushed/Inhibitted SDH2
Flushed/Inhibitted SDH3
Flushed/Inhibitted SDH5
Flushed/Inhibitted SDH7
Flushed/Inhibitted SDH8
Flushed/Inhibitted ENV
Flushed/Inhibitted TEXTCLIP

¿any idea? Not a big problem, just curiosity :-)

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

thomas
thomas's picture
Offline
Last seen: 10 hours 17 min ago
Joined: 2011-05-16 14:23
You don't check 'result'.

You don't check 'result'. Probably GetDiskInfo for CD0 fails, because there is no disk in the drive. You just repeat the output from the previous call (which was SDH0).

jabirulo
jabirulo's picture
Offline
Last seen: 4 hours 58 min ago
Joined: 2013-05-30 00:53
result - (zero or non-zero)

result - (zero or non-zero)
The result will be zero for failure, or non-zero for
success, the non-zero success value represents the
number of tags passed to this function as parameters.

result as SDK says, only shows/has number of tags passed:
..
#lock sdh0: on
LOCK: Unidad "sdh0:" bloqueada.
#a.out
SDH0=80 [res=2]
SDH0 is locked/protected
CD0=80 [res=2]
CD0 is locked/protected
SDH1=82 [res=2]
Flushed/Inhibitted SDH1
SDH2=82 [res=2]
Flushed/Inhibitted SDH2
..

Inserting a DVD/CD on CD0 drive (and unlocking SDH0):
#a.out
SDH0=82 [res=2]
Flushed/Inhibitted SDH0
CD0=80 [res=2]
CD0 is locked/protected
SDH1=82 [res=2]
Flushed/Inhibitted SDH1
..

So maybe I should check for ID_NO_DISK_PRESENT too and skip such devices?

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

jabirulo
jabirulo's picture
Offline
Last seen: 4 hours 58 min ago
Joined: 2013-05-30 00:53
Changed from

Changed from using

  1. IDOS->LockDosList(LDF_READ|LDF_DEVICES)

to use

  1. struct List *list = IDOS->AllocDosObjectTags(DOS_VOLUMELIST,
  2. ADO_Type, LDF_VOLUMES,
  3. ADO_AddColon, TRUE,
  4. TAG_END);
  5.  

But my problem now is how from VOLUME (Workbench) obtain/get DEVICE (DH0) (and then the msg port to the handler process.) any function that performs such "search"?

TIA

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

jabirulo
jabirulo's picture
Offline
Last seen: 4 hours 58 min ago
Joined: 2013-05-30 00:53
Found how-to :-) using (after

Found how-to :-) using (after AllocDosObjectTags):

  1. ..
  2. if(list)
  3. {
  4. for( nd = IExec->GetHead(list); nd; nd = IExec->GetSucc(nd) )
  5. {
  6. dp = IDOS->GetDeviceProc(nd->ln_Name, NULL);
  7. ..

I can obtain the Handler Port (dp->dvp_Port)
THX to SFSobject.c by Martin Steigerwald.

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

Log in or register to post comments