[perl] sysopen(CD, "/dev/cd0", O_RDONLY | O_NONBLOCK) fails

Vincent Hoffman vince at unsane.co.uk
Fri Mar 27 03:44:11 PDT 2009

On 27/3/09 10:32, Mel Flynn wrote:
> On Thursday 26 March 2009 22:20:45 Tobias Rehbein wrote:
>> Hi all.
>> I have a perl script which seems to work fine under Linux but fails on
>> FreeBSD. The Problem is the line:
>>         sysopen(CD, "/dev/cd0", O_RDONLY | O_NONBLOCK)
>> After this line the following evaluates to true:
>>         $! eq "No such file or directory."
> If you're running this in a jail, then cd0 is hidden by devfs, hence the 
> ENOENT. You will need to provide a jail specific ruleset, or override 
> devfsrules_jail from /etc/defaults/devfs.rules in /etc/devfs.rules so it 
> applies to all jails without modification to /etc/rc.conf.
By default for an ATA/ATAPI CDROM, you get an /dev/acd0 not a /dev/cd0
in FreeBSD.

[root at seaurchin ~]# ls -la /dev/cd0
ls: /dev/cd0: No such file or directory
[root at seaurchin ~]# ls -la /dev/acd0
crw-r-----  1 root  operator    0,  74 Feb  6 12:11 /dev/acd0
[root at seaurchin ~]#

To have a /dev/cd0 either use a scsi CDROM or kldload atapicam which
allows ATAPI devices to be accessed via the cam subsytem and will create
a /dev/cd0 node

[root at seaurchin ~]# kldload atapicam
[root at seaurchin ~]# ls -la /dev/cd0
crw-r-----  1 root  operator    0, 113 Feb  6 12:11 /dev/cd0

or just change the code to use /dev/acd0


More information about the freebsd-questions mailing list