In "Device name convert for linux use", wrote:
> I was developig a name and major/minor device number converting
> mechanism for linux applications to use on a linux.ko module , as if
> the application itself run on a linux.

> Is this helpful to linux emulator ?

This mail was a bit old, but that sounds great.

AFAIK, glibc's wordexp(3) checks /dev/null's device number before
opening /dev/null as stderr for a shell. If they are not match (ie.
under FreeBSD Linux emulation mode), wordexp always returns error.

And (maybe?) ld-linux.so also checks /dev/null's device number before
launching programs when one of stdin, stdout, stderr is closed and program
has set SetUID bit. (In glibc-2.3.2/sysdeps/generic/dl-sysdep.c???)

Therefore I made a quick hack patch for sys/compat/linux/linux_stats.c
to tell a lie about /dev/null's device number. But Sharp Gao's way seems
to be better.

Where is the patch?

Akihiro SAGAWA

To reproduce this problem, compile below source
with linux gcc.
---- for wordexp, cut here

int main(int argc, char* argv[])
int i, err;
wordexp_t we;

err = wordexp("`date`", &we, 0);
printf("err=%d\n", err);
if (!err)
for(i=0; i < we.we_wordc; i++)
printf("[%d] %s\n", i, we.we_wordv[i]);
---- to here

---- for ld-linux, cut here

int main(int argc, char* argv[])
char* exec_args[] = {"id", NULL};

printf("bye stdin\n");
printf("stdin has closed\n");
execvp(exec_args[0], exec_args);
printf("failed to exec prog.\n");
---- to here

freebsd-emulation@freebsd.org mailing list
To unsubscribe, send any mail to "freebsd-emulation-unsubscribe@freebsd.org"