opening things without the O_LARGEFILE flag



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.

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.

Does anyone know any conceivable way to accomplish this? Any help will
be appreciated.

If I should take this question to another group or list more suitable
to get an answer, could you also please indicate that group?

Kind Regards,
Athanasios

(I know, I know, the tun/tap driver may be slightly broken in the
strict sense, but let's leave that outside for a moment.)

.



Relevant Pages

  • Re: Output of Concise
    ... that op, and, unless the op has the OPf_STACKED flag, it is used to ... Instead, the TARG ... Perl source - the only kind of documentation found therein is the ... It's not anything like reading prose: ...
    (comp.lang.perl.misc)
  • Re: Output of Concise
    ... that op, and, unless the op has the OPf_STACKED flag, it is used to ... Perl source - the only kind of documentation found therein is the ... get this information - there are no books about this kind of Perl ...
    (comp.lang.perl.misc)
  • Re: opening things without the O_LARGEFILE flag
    ... I am trying to open the /dev/net/tun character device with perl. ... EBADFD (File descriptor in bad state). ... a simple C program works quite fine without that flag. ... Or write a small C server that will accept socket connections and ...
    (comp.lang.perl.misc)
  • RE: Issue with perl, DBD::Oracle, Solaris 10
    ... So when I edit the Makefile and remove the "extra" cc from the command ... Against the stock perl in Solaris 10, I get an error that looks ... Do you have a Sun C compiler on the machine? ... the OTHERLDFLAGS, ...
    (perl.dbi.users)
  • Re: Embedding perl in shared libs
    ... perl functions from within a C program. ... flag, a segfault occurs during the parsing of the script. ... When statically linking library B to program A (instead of dlopening it), ... | bol resolution of subsequently loaded libraries. ...
    (comp.lang.perl.misc)