Re: execve() returns ENOENT when ld-linux.so isn't found

From: Luca Barbieri
Date: Fri Mar 26 2010 - 17:06:37 EST


>> None of these perfectly fit, but EINVAL seems the closest.
>
> No.  ENOENT is the right value.

Not according to POSIX 2008, which does not explicitly specify this case.

Again, it says:
[ENOENT]
A component of <i>path</i> or <i>file</i> does not name an
existing file or <i>path</i> or <i>file</i> is an empty string.

Here "path" and "file" refer to the argument to the C function and
"component" refers to the tokens obtained after splitting using "/" as
a separator.
POSIX 2008 doesn't talk at all about dependencies of the executables.

POSIX 2008 mandates EINVAL if you interpret "executable format" as
being "ELF executable with interpreter /lib/FOO" as opposed to just
"ELF", or if you interpret "architecture" as including the ELF
interpreter name in addition to the machine type.

By the way, is there any way to do this in the shell other than
including an ELF parser or assuming the ELF interpreter is missing if
the kernel returns ENOENT but the file exists and has an ELF
signature? (both of these solutions seem quite unsatisfactory)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/