LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-17-2004, 03:48 AM   #1
ur_prince
LQ Newbie
 
Registered: Dec 2004
Posts: 2

Rep: Reputation: 0
whether cd or dvd is inserted?


hi, i have dvd-rw in my system. is there anyway to know whether cd or dvd has beed inserted before writing? any ioctl call or some other way?
-prince
 
Old 12-17-2004, 10:03 AM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
lsof | grep ${cdmp}

where cdmp is your cd mount point. For a test, something like

if [ ! -z "`lsof | grep ${cdmp}`" ]; then
do something
fi

May have holes in it, but it should work. But it sounds like you're asking a programming question and I don't know much of anything about that.
 
Old 12-17-2004, 10:10 AM   #3
SlackerLX
Senior Member
 
Registered: Dec 2004
Location: Herzliyya, Israel
Distribution: SuSE 10.1; Testing Distros
Posts: 1,832

Rep: Reputation: 47
Depends also on System and Environment you use, besides, of course, command line.

In Gnome, for instance, it's configurable via
Code:
APPLICATIONS->DESKTOP PREFERENCES->REMOVABLE STORAGE
 
Old 12-17-2004, 11:40 AM   #4
bm17
Member
 
Registered: Sep 2004
Location: Santa Cruz, CA, USA
Distribution: Redhat 9.0
Posts: 104

Rep: Reputation: 15
Are you polling or do you want async notification? This is tricky and it depends on whether you are using a SCSI or an IDE interface. Some drivers have the ability to asynchronously notify you of insertions while other drivers require you to poll them. One way or another this come down to sending a TEST_UNIT_READY ioctl command. You'll have to examine the driver source for details, or else look at another programs that does the same thing. Hurrah for open source.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
auto starting when cd is inserted oingram Linux - Software 1 11-10-2005 01:54 AM
'logout' inserted in profile cryo70 Linux - Security 6 09-19-2005 05:01 PM
System hangs when DVD is inserted (MKD 10.2, 2005 LE) dandaman96 Mandriva 1 05-30-2005 03:02 PM
K3B won't recognise a unformatted dvd+rw when inserted into drive. jackstoage Linux - Software 1 01-29-2005 04:13 PM
whether cd or dvd is inserted? ur_prince Programming 0 12-22-2004 02:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration