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

Bruce Cran bruce at cran.org.uk
Fri Mar 27 12:47:04 PDT 2009


On Fri, 27 Mar 2009 10:44:07 +0000
Vincent Hoffman <vince at unsane.co.uk> wrote:

> 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
> 

From the original message:

"/dev/cd0 is readable and writable for me. I rebooted multiple times and
tried with and without atapicam."

So it sounds like the OP is aware of the different device nodes created
with and without atapicam, has checked he has permission to access the
appropriate device and has come across a problem with perl itself.

-- 
Bruce Cran


More information about the freebsd-questions mailing list