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

2009-03-27 Thread Mel Flynn
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.
-- 
Mel
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


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

2009-03-27 Thread Vincent Hoffman
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.

[r...@seaurchin ~]# ls -la /dev/cd0
ls: /dev/cd0: No such file or directory
[r...@seaurchin ~]# ls -la /dev/acd0
crw-r-  1 root  operator0,  74 Feb  6 12:11 /dev/acd0
[r...@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

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

or just change the code to use /dev/acd0

Vince
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


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

2009-03-27 Thread Tobias Rehbein
Am Thu, Mar 26, 2009 at 10:11:28PM + schrieb Bruce Cran:
 
 sysopen certainly works on FreeBSD:
 
  perl
 use POSIX;
 sysopen(CD,/dev/acd0, O_RDONLY|O_NONBLOCK) || perror(sysopen)
 
 and before I fixed the permissions:
 
  perl
 use POSIX;
 sysopen(CD,/dev/acd0, O_RDONLY|O_NONBLOCK) || perror(sysopen)
 sysopen: Permission denied

Hm. Tried this and got ineresting results:

 use POSIX;
 sysopen(CD,/dev/cd0, O_RDONLY|O_NONBLOCK) || perror(sysopen)
works fine, but
 use POSIX;
 sysopen(CD,/dev/cd0, O_RDONLY|O_NONBLOCK)
 print $!
prints No such file or directory

Well, I think I'll have to accept that sysopen works but $! does not... After
all sysopen is more important to me ;)

Regards Tobias


pgpM4g9R02a4U.pgp
Description: PGP signature


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

2009-03-27 Thread Bruce Cran
On Fri, 27 Mar 2009 10:44:07 +
Vincent Hoffman vi...@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.
 
 [r...@seaurchin ~]# ls -la /dev/cd0
 ls: /dev/cd0: No such file or directory
 [r...@seaurchin ~]# ls -la /dev/acd0
 crw-r-  1 root  operator0,  74 Feb  6 12:11 /dev/acd0
 [r...@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
 
 [r...@seaurchin ~]# kldload atapicam
 [r...@seaurchin ~]# ls -la /dev/cd0
 crw-r-  1 root  operator0, 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
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


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

2009-03-27 Thread Joerg Schilling
Bruce Cran br...@cran.org.uk wrote:

cd0 is also what you get if you use atapicam (ATAPI is SCSI over ATA
from what I remember) - for example cdrecord has traditionally used it

No, with CAM on FreeBSD /dev/xpt is opened and then the route to the device is 
extablished via the SCSI address.


when writing CDs. Apparently the OP has the issue both when using
atapicam (/dev/cd0) and the normal ata node /dev/acd0.

Cdrecord did this in 1998 and before - a long time ago.

Jörg

-- 
 EMail:jo...@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
   j...@cs.tu-berlin.de(uni)  
   joerg.schill...@fokus.fraunhofer.de (work) Blog: 
http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


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

2009-03-27 Thread Rehbein
Am Fri, Mar 27, 2009 at 07:46:55PM + schrieb Bruce Cran:
 
 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.

You are right. Normally I use atapicam and let devfs hide /dev/acd0.

As I have written in another message in this thread sysopen actually works, it's
the $! that causes the problems.

Tobias
-- 
Tobias Rehbein

PGP key: 4F2AE314
server:  keys.gnupg.net
fingerprint: ECDA F300 1B6E 9B87 8524  8663 E8B6 3138 4F2A E314


pgpO6G9RXdVJY.pgp
Description: PGP signature


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

2009-03-27 Thread Tobias Rehbein
Am Fri, Mar 27, 2009 at 09:19:53PM +0100 schrieb Joost Bekkers:
 On Fri, March 27, 2009 19:59, Tobias Rehbein wrote:
  Am Thu, Mar 26, 2009 at 10:11:28PM + schrieb Bruce Cran:
 
  Hm. Tried this and got ineresting results:
 
  use POSIX;
  sysopen(CD,/dev/cd0, O_RDONLY|O_NONBLOCK) || perror(sysopen)
  works fine, but
  use POSIX;
  sysopen(CD,/dev/cd0, O_RDONLY|O_NONBLOCK)
  print $!
  prints No such file or directory
 
  Well, I think I'll have to accept that sysopen works but $! does not...
  After
  all sysopen is more important to me ;)
 
 As the perlvar manpage tells us:
 
   $!  If used numerically, yields the current value of the C errno
   variable, or in other words, if a system or library call fails,
   it sets this variable.  This means that the value of $! is
   meaningful only immediately after a failure.
 
 The value of $! is NOT an indicator of success or failure. It only tells
 you why something failed. If something succeeded $! is usualy left
 untouched.

Yes, that sounds sensible. Thanks for clarification.
-- 
Tobias Rehbein

PGP key: 4F2AE314
server:  keys.gnupg.net
fingerprint: ECDA F300 1B6E 9B87 8524  8663 E8B6 3138 4F2A E314


pgpRnzKIGUICh.pgp
Description: PGP signature


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

2009-03-27 Thread Joost Bekkers
On Fri, March 27, 2009 19:59, Tobias Rehbein wrote:
 Am Thu, Mar 26, 2009 at 10:11:28PM + schrieb Bruce Cran:

 Hm. Tried this and got ineresting results:

 use POSIX;
 sysopen(CD,/dev/cd0, O_RDONLY|O_NONBLOCK) || perror(sysopen)
 works fine, but
 use POSIX;
 sysopen(CD,/dev/cd0, O_RDONLY|O_NONBLOCK)
 print $!
 prints No such file or directory

 Well, I think I'll have to accept that sysopen works but $! does not...
 After
 all sysopen is more important to me ;)

As the perlvar manpage tells us:

  $!  If used numerically, yields the current value of the C errno
  variable, or in other words, if a system or library call fails,
  it sets this variable.  This means that the value of $! is
  meaningful only immediately after a failure.

The value of $! is NOT an indicator of success or failure. It only tells
you why something failed. If something succeeded $! is usualy left
untouched.


Joost.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


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

2009-03-26 Thread Glen Barber
On Thu, Mar 26, 2009 at 5:20 PM, Tobias Rehbein tobias.rehb...@web.de 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.


I may be wrong, but shouldn't that be '/dev/acd0' ?

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

        sysopen(CD, /dev/acd0, O_RDONLY | O_NONBLOCK)

 fails either. So what's up here? Is sysopen a linuxism?

 Any help is greatly appreciated.

 Regards Tobias


-- 
Glen Barber
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


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

2009-03-26 Thread Robert Huff

Glen Barber writes:

   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.
  
  
  I may be wrong, but shouldn't that be '/dev/acd0' ?

/dev/cd0 = SCSI CD-ROM (and maybe other stuff).

I don't know if that's what the OP has, but it is a possible
value.


Robert Huff

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


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

2009-03-26 Thread Bruce Cran
On Thu, 26 Mar 2009 22:20:45 +0100
Tobias Rehbein tobias.rehb...@web.de 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.
 
 /dev/cd0 is readable and writable for me. I rebooted multiple times
 and tried with and without atapicam. 
 
 sysopen(CD, /dev/acd0, O_RDONLY | O_NONBLOCK)
 
 fails either. So what's up here? Is sysopen a linuxism?
 

sysopen certainly works on FreeBSD:

 perl
use POSIX;
sysopen(CD,/dev/acd0, O_RDONLY|O_NONBLOCK) || perror(sysopen)
 

and before I fixed the permissions:

 perl
use POSIX;
sysopen(CD,/dev/acd0, O_RDONLY|O_NONBLOCK) || perror(sysopen)
sysopen: Permission denied


-- 
Bruce Cran
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


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

2009-03-26 Thread Bruce Cran
On Thu, 26 Mar 2009 18:17:46 -0400
Robert Huff roberth...@rcn.com wrote:

 
 Glen Barber writes:
 
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.
   
   
   I may be wrong, but shouldn't that be '/dev/acd0' ?
 
   /dev/cd0 = SCSI CD-ROM (and maybe other stuff).
 
   I don't know if that's what the OP has, but it is a possible
 value.

cd0 is also what you get if you use atapicam (ATAPI is SCSI over ATA
from what I remember) - for example cdrecord has traditionally used it
when writing CDs. Apparently the OP has the issue both when using
atapicam (/dev/cd0) and the normal ata node /dev/acd0.

-- 
Bruce Cran
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org