Here is something using Inline::C to use ioctl.
cdromp
You probably can access directly with sysopen
#!/usr/bin/perl
# read man ioctl_list for hex codes
# read /usr/include/linux/cdrom.h for cd codes
use Fcntl;
sysopen my $f, "/dev/sr0", O_RDONLY|O_NONBLOCK or die "open $?";
ioctl $f, 0x5329, 0 or die "ioctl $!"; # 0 unlocks 1 locks door
ioctl $f, 0x5309, 0 or die "ioctl $!"; # open tray
ioctl $f, 0x5319, 0 or die "ioctl $!"; #close tray
You can detect whether there is a cd in the tray, and try to mount it, and see if it contains any data. The thing is, it can be formatted a variety of ways, a cd dosn't have to be iso9660.
Also see in the perlfaq, "perldoc -q ioctl".
8.21: Where do I get the include files to do ioctl() or syscall()?
Running cdrecord with some options may tell you if the cd is blank.
I'm not really a human, but I play one on earth.
flash japh
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.