Re: opening things without the O_LARGEFILE flag



"Athanasios" <aduitsis@xxxxxxxxx> wrote:
Hi everyone,

I am trying to open the /dev/net/tun character device with perl.

In C, I would issue:

open("/dev/net/tun", O_RDWR)

and continue as usual.

However, when I try to use sysopen in perl like

sysopen(TUNNELDEV, "/dev/net/tun", O_RDWR);

from the strace (truss) output I can see that instead it tries to do:

open("/dev/net/tun", O_RDWR|O_LARGEFILE)

which for some VERY strange reason succeeds but the file descriptor is
left in a bad state, so it is really unusable. For anything I try to do
afterwards, I get a

EBADFD (File descriptor in bad state).

As I have come down to the systel call level, there is no other reason
for this problem that I can think of except the O_LARGEFILE flag.
Indeed, a simple C program works quite fine without that flag.

Just to make sure it is absolutely nailed down, does the simple C program
stop working fine if you add the O_LARGEFILE in?


I also have tried to use POSIX::open but it still adds the flag.

The documentation clearly states that from perl 5.6 and forth, the
O_LARGEFILE will be used whenever possible. But I really need to bypass
this and generate an open system call without it.

Maybe you could compile perl without large file support?

Or write a small C server that will accept socket connections and
proxy /dev/net/tun over the socket.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
.



Relevant Pages

  • opening things without the O_LARGEFILE flag
    ... I am trying to open the /dev/net/tun character device with perl. ... which for some VERY strange reason succeeds but the file descriptor is ... EBADFD (File descriptor in bad state). ... a simple C program works quite fine without that flag. ...
    (comp.lang.perl.misc)
  • Re: Bug?: backticks operator upsetting while(<FH>)
    ... You are creating a bad file descriptor under Perl 5.8 version. ... symbol after a REM insert, although you are not doing this. ... Might be some confusion in perl core on those redirect symbols. ...
    (comp.lang.perl.misc)
  • FAQ 5.33 How do I close a file descriptor by number?
    ... If, for some reason, you have a file descriptor instead of a filehandle ... as the Perl Cclose()> function is to be ... The perlfaq-workers, a group of volunteers, maintain the perlfaq. ... so please include relevant details for ...
    (comp.lang.perl.misc)
  • FAQ 5.33 How do I close a file descriptor by number?
    ... If, for some reason, you have a file descriptor instead of a filehandle ... as the Perl Cclose()> function is to be ... The perlfaq-workers, a group of volunteers, maintain the perlfaq. ... so please include relevant details for ...
    (comp.lang.perl.misc)
  • FAQ 5.33 How do I close a file descriptor by number?
    ... If, for some reason, you have a file descriptor instead of a filehandle ... as the Perl "close" function is to be ... The perlfaq-workers, a group of volunteers, maintain the perlfaq. ... so please include relevant details for ...
    (comp.lang.perl.misc)