Reliable CD Ejection
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Reliable CD Ejection




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Reliable CD Ejection  
Bender


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-08-07 12:24 AM

Simple problem.  I want to eject a CD from a drive.  After plenty of
tooling around the only reliable way I could do this is to utilize the
raw device number (or block device number).

I'm using the Solaris SUNWcdrw package to burn disks so I decided to use
it to extract the raw device number using 'cdrw -l'.  Ex: Parse out
"/dev/rdsk/c0d0t0s0" and do a /usr/bin/eject on that device.
The problem is 'cdrw -l' doesn't always give me the raw device number.
Sometimes it gives me the logical name 'cdrom0'. Fortunately I'm working
on a closed system so I could parse out the /etc/mnttab file to get the
block device for the /cdrom mount point but this would never work in a
real world situation.

Finally my question. How can I always reliably eject a CD from its drive?

Thanks.





[ Post a follow-up to this message ]



    Re: Reliable CD Ejection  
fjblurt@yahoo.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-08-07 06:45 AM

On Dec 7, 3:48 pm, Bender <jnbben...@gmail.com> wrote:
> Simple problem.  I want to eject a CD from a drive.  After plenty of
> tooling around the only reliable way I could do this is to utilize the
> raw device number (or block device number).
>
> I'm using the Solaris SUNWcdrw package to burn disks so I decided to use
> it to extract the raw device number using 'cdrw -l'.  Ex: Parse out
> "/dev/rdsk/c0d0t0s0" and do a /usr/bin/eject on that device.
> The problem is 'cdrw -l' doesn't always give me the raw device number.
> Sometimes it gives me the logical name 'cdrom0'. Fortunately I'm working
> on a closed system so I could parse out the /etc/mnttab file to get the
> block device for the /cdrom mount point but this would never work in a
> real world situation.
>
> Finally my question. How can I always reliably eject a CD from its drive?

If there is more than one CD drive on the system, how will you know
which one to eject?





[ Post a follow-up to this message ]



    Re: Reliable CD Ejection  
Bender


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-08-07 06:45 AM

fjblurt@yahoo.com wrote:
> On Dec 7, 3:48 pm, Bender <jnbben...@gmail.com> wrote: 
>
> If there is more than one CD drive on the system, how will you know
> which one to eject?

That situation I can guarantee against or at least give the user an
option. After poking around it looks like some ioctl calls with
CDROMEJECT should do the trick but still...

How do I discover the CD device names?





[ Post a follow-up to this message ]



    Re: Reliable CD Ejection  
Bill Marcum


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-09-07 12:43 AM

On 2007-12-07, Bender <jnbbender@gmail.com> wrote:
>
>
> Simple problem.  I want to eject a CD from a drive.  After plenty of
> tooling around the only reliable way I could do this is to utilize the
> raw device number (or block device number).
>
> I'm using the Solaris SUNWcdrw package to burn disks so I decided to use
> it to extract the raw device number using 'cdrw -l'.  Ex: Parse out
> "/dev/rdsk/c0d0t0s0" and do a /usr/bin/eject on that device.
> The problem is 'cdrw -l' doesn't always give me the raw device number.
> Sometimes it gives me the logical name 'cdrom0'. Fortunately I'm working
> on a closed system so I could parse out the /etc/mnttab file to get the
> block device for the /cdrom mount point but this would never work in a
> real world situation.
>
Wait a minute. If 'cdrw -l' returns a mount point, shouldn't you
umount the cdrom before ejecting it?

ls -ld . $(cdrw -l) | awk '/^b/{print $9}'
should list only block device names.





[ Post a follow-up to this message ]



    Re: Reliable CD Ejection  
Bender


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
12-09-07 12:43 AM

Bill Marcum wrote:
> On 2007-12-07, Bender <jnbbender@gmail.com> wrote: 
> Wait a minute. If 'cdrw -l' returns a mount point, shouldn't you
> umount the cdrom before ejecting it?
>
> ls -ld . $(cdrw -l) | awk '/^b/{print $9}'
> should list only block device names.

'cdrw -l' returns the raw device name or the logical device
name(cdrom0). The nice thing about this is you can eject an unmounted
CD, one that is blank.  I would like to get the device name because then
I would be able to handle the non-mounted case.
In the case where I wanted to eject a CD only if it were mounted I would
parse out the /etc/mnttab using getmntent and grab the device name that way.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 04:51 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register