Thread: Mounting & detecting DVD ROM

  1. #1
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476

    Mounting & detecting DVD ROM

    Hi, my boss wanted my application to be able to check whether the DVD ROM drive of the machine is faulty or not. So the user has to only click a button in the GUI, and if there's a DVD inside the drive and the it can read the disk, it will return a success value. Likewise, if it can't read the disk (ie. cannot mount disk, the drive's head is faulty, etc), it will return a failure value.

    The questions is:
    1. How do I mount from inside the application? Do I have to call:
    Code:
    system("mount ...");
    ??

    2. After the drive is successfully mounted, and then what? I don't have any clue as to what to do to check whether it can read any file on the disk. Or maybe I just call the "opendir()" function to see if it returned the directory pointer of the mounted DVD. But if a directory is successfully opened in the application, does that mean the drive itself is not faulty?

    Thanks in advance.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Since you seem to be using Linux or a compatible system, you could use exec*() instead of system(). But basically, if you need to launch the mount program, that's what you'd have to do. The nice thing about exec*() is that you'd be able to check the return value of mount and thus be able to tell if it succeeded or not.

    Supplying the path to mount (if it's the same between distros) would reduce the security risk involved in calling an external program. I don't think it's a constant, though.

    I think that mount will detect some errors related to the disk. For example, if it's unformatted or just plain not in the drive. So I wouldn't worry about that. If it's mounted, it's probably readable.

    Of course, it might not be the right disk. But that's another story. You could check the disk label, or perhaps some of the layout on the disk, to see if it's acceptable. Unless any disk's okay.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    Quote Originally Posted by dwks View Post
    Since you seem to be using Linux or a compatible system, you could use exec*() instead of system(). But basically, if you need to launch the mount program, that's what you'd have to do. The nice thing about exec*() is that you'd be able to check the return value of mount and thus be able to tell if it succeeded or not.

    Supplying the path to mount (if it's the same between distros) would reduce the security risk involved in calling an external program. I don't think it's a constant, though.

    I think that mount will detect some errors related to the disk. For example, if it's unformatted or just plain not in the drive. So I wouldn't worry about that. If it's mounted, it's probably readable.

    Of course, it might not be the right disk. But that's another story. You could check the disk label, or perhaps some of the layout on the disk, to see if it's acceptable. Unless any disk's okay.
    But does that mean if the disk can be mounted, the DVD ROM always in a good condition? I don't know in Linux, but in Windows Explorer, even if the disk can recognize the label of the disk, it doesn't mean that the drive can always read the disk. For example, if the motor or the sensor is already weak, it probably can still read the label, but can't read the file within (in Windows Explorer). So how do I trace that kind of hardware error?
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. HELP!!!!emergency Problem~expert please help
    By unknowppl in forum C++ Programming
    Replies: 9
    Last Post: 08-21-2008, 06:41 PM
  2. HELP!!!!emergency ~expert please help
    By unknowppl in forum C Programming
    Replies: 1
    Last Post: 08-19-2008, 07:35 AM
  3. Watching a dvd film.
    By adrianxw in forum Tech Board
    Replies: 5
    Last Post: 03-11-2003, 02:25 AM
  4. mac dvd rom region code
    By lightatdawn in forum Tech Board
    Replies: 3
    Last Post: 03-07-2003, 01:52 PM
  5. DVD Rom drivers
    By RoD in forum Tech Board
    Replies: 8
    Last Post: 01-31-2003, 12:17 PM