execl() returning EBADF

Hi everbody!

Does anybody know, what might cause execl() a EBADF error?

I couldn’t find any hint in the docs …





Mit freundlichen Grüßen aus Krefeld,
With best regards from Krefeld,

MBS GmbH
Karsten Hoffmann


MBS GmbH E-Mail: karsten.hoffmann@mbs-software.de
Römerstraße 15 Tel: +49 / 2151 / 72 94-38
D-47809 Krefeld Fax: +49 / 2151 / 72 94-50
http://www.mbs-software.de Mobil: +49 / 172 / 38 12 373

Karsten P. Hoffmann wrote:

Does anybody know, what might cause execl() a EBADF error?

I couldn’t find any hint in the docs …

Guess I found the reason for this Message …


I’m currentl porting my QNX6.2 diskless workstation to QNX6.3.

Since QNET is not ‘unmountable’ anymore, I set the new hostname and
domainname with ‘sethostname()’ and ‘setdomainname()’, wait a few seconds,
create lots of links to the server (bin, lib, usr, etc, tmp, …) and then I
want to execl() a shellscript from the server via one of the links, which
fails with the undocumented EBADF.

(In QNX6.2 I simply unmounted QNET and re-mounted it with the new names and
everything work fine)


On the server I can see both names, the old AND the new one, and as soon
as I do a ‘ls -l /net’ on the server everthing works fine, too. The ‘old’
name of the diskless workstation is reported with ‘no route to host’ and
disappears from the server’s namespace hereafter.


Is there any method to resync the validity of the names in QNET? (ioctl() or
whatever)?




Mit freundlichen Grüßen aus Krefeld,
With best regards from Krefeld,

MBS GmbH
Karsten Hoffmann


MBS GmbH E-Mail: karsten.hoffmann@mbs-software.de

Römerstraße 15 Tel: +49 / 2151 / 72 94-38
D-47809 Krefeld Fax: +49 / 2151 / 72 94-50
http://www.mbs-software.de Mobil: +49 / 172 / 38 12 373

After change you own hostname, try open(/net/server/dev/null, O_RDONLY) with
a delay until successed? (Probably 2 try would be fine).

-xtang

Karsten P. Hoffmann <karsten.hoffmann@mbs-software.de> wrote in message
news:d13t36$ate$1@inn.qnx.com

Karsten P. Hoffmann wrote:
Does anybody know, what might cause execl() a EBADF error?

I couldn’t find any hint in the docs …

Guess I found the reason for this Message …


I’m currentl porting my QNX6.2 diskless workstation to QNX6.3.

Since QNET is not ‘unmountable’ anymore, I set the new hostname and
domainname with ‘sethostname()’ and ‘setdomainname()’, wait a few seconds,
create lots of links to the server (bin, lib, usr, etc, tmp, …) and then
I
want to execl() a shellscript from the server via one of the links, which
fails with the undocumented EBADF.

(In QNX6.2 I simply unmounted QNET and re-mounted it with the new names
and
everything work fine)


On the server I can see both names, the old AND the new one, and as soon
as I do a ‘ls -l /net’ on the server everthing works fine, too. The ‘old’
name of the diskless workstation is reported with ‘no route to host’ and
disappears from the server’s namespace hereafter.


Is there any method to resync the validity of the names in QNET? (ioctl()
or
whatever)?




Mit freundlichen Grüßen aus Krefeld,
With best regards from Krefeld,

MBS GmbH
Karsten Hoffmann


MBS GmbH E-Mail: > karsten.hoffmann@mbs-software.de

Römerstraße 15 Tel: +49 / 2151 / 72 94-38
D-47809 Krefeld Fax: +49 / 2151 / 72 94-50
http://www.mbs-software.de > Mobil: +49 / 172 / 38 12 373

Xiaodan Tang wrote:

After change you own hostname, try open(/net/server/dev/null, O_RDONLY)
with a delay until successed? (Probably 2 try would be fine).

Hhm, I tried ‘access ( “/net/server/bin/ksh”, F_OK)’ already,
without success (which means: access() returned 0 immediately, but execl
("/bin/ksh", “ksh”, NULL) still failed …).

But I’ll try your idea tomorrow … perhaps ‘open()’ is something
different.

Thanks a lot!


Karsten P. Hoffmann <karsten.p.hoffmann@web.de>
“I love deadlines. I especially like the whooshing sound
they make as they go flying by.”
[In memoriam Douglas Adams, 1952-2001]

Karsten P. Hoffmann wrote:

But I’ll try your idea tomorrow … perhaps ‘open()’ is something
different.

Doesn’t work either …

So here’s what I’m doing ‘in toto’:


o Boot from Flash

o Detect NIC and read MAC address

o Create a hostname “Client-”

o Start QNET with hostname

o Search all host in /net for a server, that knows my
MAC address. Get the ‘real’ hostname and domainname
from that server.

o Change hostname with ‘sethostname()’

o Change domainname with ‘setdomainname()’

o Create a links to Server ( /bin → /net/server/bin,
/sbin → /net/server/sbin, …)

o Wait a few seconds and access() /net/server/bin/ksh
until OK.

o exec ("/bin/ksh", “ksh”, , NULL);
→ return -1 and ‘errno’ is set to EBADF.
(command doesn’t matter, also ‘ls’ fails).


As soon as a “ls -l /net/” is executed on the server, the
exec() command succeeds. Both, the old and the new name,
can be seen before the first ‘ls’ on the server.

Any more ideas?


TIA,

Karsten.


MBS GmbH E-Mail: karsten.hoffmann@mbs-software.de
Römerstraße 15 Tel: +49 / 2151 / 72 94-38
D-47809 Krefeld Fax: +49 / 2151 / 72 94-50
http://www.mbs-software.de Mobil: +49 / 172 / 38 12 373

Are you saying the “access()” (or open()) is successed but the next
exec() failed?

-xtang

Karsten P. Hoffmann <karsten.hoffmann@mbs-software.de> wrote in message
news:d16429$t51$1@inn.qnx.com

Karsten P. Hoffmann wrote:

But I’ll try your idea tomorrow … perhaps ‘open()’ is something
different.

Doesn’t work either …

So here’s what I’m doing ‘in toto’:


o Boot from Flash

o Detect NIC and read MAC address

o Create a hostname “Client-”

o Start QNET with hostname

o Search all host in /net for a server, that knows my
MAC address. Get the ‘real’ hostname and domainname
from that server.

o Change hostname with ‘sethostname()’

o Change domainname with ‘setdomainname()’

o Create a links to Server ( /bin → /net/server/bin,
/sbin → /net/server/sbin, …)

o Wait a few seconds and access() /net/server/bin/ksh
until OK.

o exec ("/bin/ksh", “ksh”, , NULL);
→ return -1 and ‘errno’ is set to EBADF.
(command doesn’t matter, also ‘ls’ fails).


As soon as a “ls -l /net/” is executed on the server, the
exec() command succeeds. Both, the old and the new name,
can be seen before the first ‘ls’ on the server.

Any more ideas?


TIA,

Karsten.


MBS GmbH E-Mail: > karsten.hoffmann@mbs-software.de
Römerstraße 15 Tel: +49 / 2151 / 72 94-38
D-47809 Krefeld Fax: +49 / 2151 / 72 94-50
http://www.mbs-software.de > Mobil: +49 / 172 / 38 12 373

Xiaodan Tang wrote:

Are you saying the “access()” (or open()) is successed but the next
exec() failed?

Yes! Obviously execl() need something more than just opening files …


Mit freundlichen Grüßen aus Krefeld,
With best regards from Krefeld,

MBS GmbH
Karsten Hoffmann


MBS GmbH E-Mail: karsten.hoffmann@mbs-software.de
Römerstraße 15 Tel: +49 / 2151 / 72 94-38
D-47809 Krefeld Fax: +49 / 2151 / 72 94-50
http://www.mbs-software.de Mobil: +49 / 172 / 38 12 373

Hm…

I wonder if you could do a rmdir("/net/server/net/Client-"),
first, then try “access()” or “open()”,
and then execl() something from server,

Would this helpful?

-xtang


Karsten P. Hoffmann <karsten.hoffmann@mbs-software.de> wrote in message
news:d16vn7$jrt$1@inn.qnx.com

Xiaodan Tang wrote:
Are you saying the “access()” (or open()) is successed but the next
exec() failed?

Yes! Obviously execl() need something more than just opening files …


Mit freundlichen Grüßen aus Krefeld,
With best regards from Krefeld,

MBS GmbH
Karsten Hoffmann


MBS GmbH E-Mail: > karsten.hoffmann@mbs-software.de
Römerstraße 15 Tel: +49 / 2151 / 72 94-38
D-47809 Krefeld Fax: +49 / 2151 / 72 94-50
http://www.mbs-software.de > Mobil: +49 / 172 / 38 12 373

Xiaodan Tang wrote:

I wonder if you could do a rmdir("/net/server/net/Client-"),
first, then try “access()” or “open()”,
and then execl() something from server,

Great idea, this works!

I tried removing things from the local ‘/net’ (own name, server name, etc),
but this didn’t help.

Removing the own name from the server’s ‘/net’ directory works!


Thanks a lot!

Mit freundlichen Grüßen aus Krefeld,
With best regards from Krefeld,

MBS GmbH
Karsten Hoffmann


MBS GmbH E-Mail: karsten.hoffmann@mbs-software.de
Römerstraße 15 Tel: +49 / 2151 / 72 94-38
D-47809 Krefeld Fax: +49 / 2151 / 72 94-50
http://www.mbs-software.de Mobil: +49 / 172 / 38 12 373