On this page: Main Content. Details. Test script.

Make OS/2 Detect Changed CD/DVD Media

October 13, 2016. OS/2 EcomStations may not notice that CD/DVD media has changed until the drive door is closed manually. Common physical utilities like CDRECORD and DVDDAO fail to notify the operating system when they open or close the door programmatically. As a result, following an optical disk change, the operating system may be using the previously cached directory and data. When you need to open and close the door programmatically, it seems that an effective workaround is if you always have OS/2 immediately check the disk (e.g., taking a dir) immediately after programatically opening the drive door.

Details

This issue can be demonstrated with two optical discs, one that contains files, the other ready to write but with no files (e.g. formatted but unwritten DVD+RW; virgin or blanked DVD-RW). For the sake of example, suppose the optical drive is logically 'S:' and physically '0,1,0'.

  1. Insert the DVD+RW with files, close the drive door, wait for it to spin up, and take a directory ('dir S:').
  2. Eject the DVD+RW by any convenient means, for example:
  3. Insert the DVD that's ready to write but has no files and close the door programmatically. I found that 'DVDDAO -d S --load' did not work, but these methods did:
  4. Take a directory ('dir S:').
  5. Observe that the system displays the directory of the previous disk. When you attempt to read a file that you had previously opened, you may even see its data, thanks to caching. Otherwise, you see blanks as the disk is actually empty.

To repeat, it appears that a workaround is that any time you programmatically eject a disk, you immediately have the operating system attempt to access the drive while the door is still open. Then it realizes there's been a disk change. You can use CHKDSK, DIR, VOL, as well as the Rexx Utility functions SysDriveInfo, SysFileSystemType (not in Classic Rexx), and SysFileTree.

Test Script

I found it convenient to use this Rexx Script for testing (hard coded to use my drive S and 0,1,0):


/* @#walt.gregg.juneau.ak.us:2016.287#@OS-2_DetectChangedCD-DVD.CMD - in ECS-OS/2. */
'@echo off'
parse source system calltype script
THIS=filespec('name',script)

parse upper arg string
select
  when string='CHKDSK' then notify=CHKDSK
  when string='DIR' then notify=DIR
  when string='VOL' then notify=VOL
  when string='SYSDRIVEINFO' then notify=SYSDRIVEINFO
  when string='SYSFILESYSTEMTYPE' then notify=SYSFILESYSTEMTYPE
  when string='SYSFILETREE' then notify=SYSFILETREE
  when string='NONE' then notify=NONE
  otherwise do
    say 'Use' THIS 'to see if OS/2 detects an optical media change.'
    say 'Syntax:'
    say '  'THIS '[CHKDSK][dir][vol]'
    say '  'THIS '[SysDriveInfo][SysFileSystemType][SysFileTree]'
    say '  'THIS '[none]'
    say 'where:'
    say '  The method to notify OS/2 that the media changed.'
    exit 0
  end
end

/* Open door, get data disk */
'dvddao -d 0,1,0 --eject'
'cls'
say 'Please insert a disk with files and let me close the door.'
'pause'

/* Close door, get dir, open door, get blank disk */
'dvddao -d 0,1,0'
'dir s:'
'dvddao -d 0,1,0 --eject'
'cls'
say 'Please insert a disk with no files and let me close the door.'
'pause'

/* Optionally tell operating system the media changed */
select
  when notify='CHKDSK' then 'CHKDSK S:'
  when notify='DIR' then 'DIR S:'
  when notify='VOL' then 'VOL S:'
  when notify='SYSDRIVEINFO' then do
    call RxFuncAdd 'SysDriveInfo','RexxUtil','SysDriveInfo'
    toss=SysDriveInfo('S')
  end
  when notify='SYSFILESYSTEMTYPE' then do
    call RxFuncAdd 'SysFileSystemType','RexxUtil','SysFileSystemType'
    toss=SysFileSystemType('S')
  end
  when notify='SYSFILETREE' then do
    call RxFuncAdd 'SysFileTree','RexxUtil','SysFileTree'
    toss=SysFileTree('S:\*','entry','bo')
  end
  when notify='NONE' then nop
  otherwise nop
end

/* Close door, get dir, if files, bugaboo */
'dvddao -d 0,1,0'
'cls'
say 'When you continue if you see files it is a bugaboo.'
'pause'
'dir s:'


, Make OS/2 Detect Changed CD/DVD Media (Oct. 2016) (available at ). © W. Gregg 2016; CreativeCommons.org /licenses /by-nc-sa/4.0.

 No Privacy