About DosPacket "ACTION_CURRENT_VOLUME" (Solved +)

4 posts / 0 new
Last post
OldFart
OldFart's picture
Offline
Last seen: 6 hours 51 min ago
Joined: 2010-11-30 14:09
About DosPacket "ACTION_CURRENT_VOLUME" (Solved +)

Hi,

According to "dos/extents.h" "ACTION_CURRENT_VOLUME" is deprecated. Ok, but what exactly did it return and what is the alternative/OS4.0 way of obtaining that same info?

Regards
OldFart

OldFart
OldFart's picture
Offline
Last seen: 6 hours 51 min ago
Joined: 2010-11-30 14:09
Re: About DosPacket "ACTION_CURRENT_VOLUME" (Solved)

Hi,

I may have solved this puzzle by invoking IDOS->FindDosEntry(). Results are looking good

Part of the code applied:

  1. struct VolumeNode *VN;
  2.  
  3. (__PD)->pd_DosList = IDOS->LockDosList(LDF_DEVICES | LDF_VOLUMES | LDF_READ);
  4.  
  5. while (((__PD)->pd_DosList = IDOS->NextDosEntry((__PD)->pd_DosList, LDF_DEVICES)) != NULL)
  6. {
  7. if (
  8. ((__DN)->dn_Startup != ZERO) &&
  9. ((__DN)->dn_Port != NULL) &&
  10. ((VN =(struct VolumeNode *)IDOS->FindDosEntry((__PD)->pd_DosList, (CONST_STRPTR)_CSTR((__DN)->dn_Name), LDF_VOLUMES)) != NULL)
  11. )
  12. {
  13. /*
  14.   ** Perform further madzjiq here...
  15.   */
  16. }
  17. }
  18.  
  19. IDOS->UnLockDosList(LDF_DEVICES | LDF_VOLUMES | LDF_READ);

OldFart

OldFart
OldFart's picture
Offline
Last seen: 6 hours 51 min ago
Joined: 2010-11-30 14:09
Re: About DosPacket "ACTION_CURRENT_VOLUME" (Solved)

Sorry foax! It didn't work out as I had expected.

I expected IDOS->FindDosEntry() to use the same 'Name'. Didn't work that way.

So I conjured up a function of my own, which looks for an identical port address in VolumeNodes and lo' and behold: it works (verified)!

  1. struct VolumeNode *VN;
  2.  
  3. (__PD)->pd_DosList = IDOS->LockDosList(LDF_DEVICES | LDF_VOLUMES | LDF_READ);
  4.  
  5. while (((__PD)->pd_DosList = IDOS->NextDosEntry((__PD)->pd_DosList, LDF_DEVICES)) != NULL)
  6. {
  7. if (
  8. ((__DN)->dn_Startup != ZERO) &&
  9. ((__DN)->dn_Port != NULL) &&
  10. ((VN = (struct VolumeNode *)Find_VolumeNode(xn)) != NULL)
  11. )
  12. {
  13. /*
  14.   ** Perform further madzjiq here...
  15.   */
  16. }
  17. }
  18.  
  19. IDOS->UnLockDosList(LDF_DEVICES | LDF_VOLUMES | LDF_READ);
  20.  
  21.  
  22. struct DosList *Find_VolumeNode(struct ExecParam *xn)
  23. {
  24. INFO_ENTER
  25.  
  26. struct DosList *DOL = IDOS->LockDosList(LDF_VOLUMES | LDF_READ);
  27.  
  28. if (DOL != NULL)
  29. {
  30. while (
  31. ((DOL = IDOS->NextDosEntry(DOL, LDF_VOLUMES)) != NULL) &&
  32. (DOL->dol_Port != (__DN)->dn_Port)
  33. )
  34. {
  35. ;
  36. }
  37.  
  38. IDOS->UnLockDosList(LDF_VOLUMES | LDF_READ);
  39. }
  40.  
  41. INFO_VACATE
  42. return DOL;
  43. }

Hilarious, what?

OldFart

cwenzel
cwenzel's picture
Offline
Last seen: 1 week 5 days ago
Joined: 2021-01-12 07:05
Re: About DosPacket "ACTION_CURRENT_VOLUME" (Solved +)

One may ask WHY ?
Are you just trying to make Rube Goldberg machine or something ?

All the dospacket info is in; dos.dospackets.doc

If you are seriously trying to get access to the volume node for a mounted volume,
you only need to use Lock(), then do some basic field validation for safety.
Here's an example to get the volume node datestamp...

  1. int32 get_volnode_datestamp( STRPTR name, struct DateStamp *ds )
  2. {
  3. int32 result = FALSE;
  4. BPTR blk = IDOS->Lock(name,SHARED_LOCK);
  5.  
  6. /*
  7.   ** clear down datestamp for failure condition
  8.   ** rather than returning random trash.
  9.   */
  10. ds->ds_Days = 0;
  11. ds->ds_Minute = 0;
  12. ds->ds_Tick = 0;
  13.  
  14. if( blk )
  15. {
  16. struct Lock *lock = BADDR(blk);
  17. struct VolumeNode *vn = BADDR(lock->fl_Volume);
  18.  
  19. if( vn ) /* may be NULL or points to something else wierd */
  20. {
  21. if( DLT_VOLUME == vn->vn_Type ) /* check type */
  22. {
  23. if( lock->fl_Port == vn->vn_Port ) /* check port */
  24. {
  25. ds->ds_Days = vn->vn_VolumeDate.ds_Days;
  26. ds->ds_Minute = vn->vn_VolumeDate.ds_Minute;
  27. ds->ds_Tick = vn->vn_VolumeDate.ds_Tick;
  28.  
  29. result = TRUE;
  30. }
  31. }
  32. }
  33.  
  34. IDOS->UnLock(blk);
  35. }
  36.  
  37. return(result);
  38. }
Log in or register to post comments