From owner-freebsd-emulation@FreeBSD.ORG Wed May 26 04:53:11 2004 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3BD8516A4CE for ; Wed, 26 May 2004 04:53:11 -0700 (PDT) Received: from dynamo.sohgoh.net (dynamo.sohgoh.net [211.10.16.102]) by mx1.FreeBSD.org (Postfix) with ESMTP id DBD9F43D2F for ; Wed, 26 May 2004 04:53:10 -0700 (PDT) (envelope-from sagawa@sohgoh.net) Received: from 127.0.0.1 (localhost.localdomain [127.0.0.1]) by antivirus.sohgoh.net (Postfix) with SMTP id 1FDEC80E93; Wed, 26 May 2004 20:52:35 +0900 (JST) Received: from [127.0.0.1] (dynamo.sohgoh.net [211.10.16.102]) by dynamo.sohgoh.net (Postfix) with ESMTP id 04D4E80E90; Wed, 26 May 2004 20:52:35 +0900 (JST) Date: Wed, 26 May 2004 20:52:24 +0900 From: Akihiro Sagawa To: freebsd-emulation@freebsd.org In-Reply-To: <20040524060403.7239.qmail@web15105.mail.bjs.yahoo.com> References: <20040524060403.7239.qmail@web15105.mail.bjs.yahoo.com> Message-Id: <20040526204931.0F7E.SAGAWA@sohgoh.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.09.01 [ja] cc: Sharp Gao Subject: Re: Device name convert for linux use X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 May 2004 11:53:11 -0000 Hi, 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. (snip) > 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 #include #include 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]); wordfree(&we); } ---- to here ---- for ld-linux, cut here #include #include #include int main(int argc, char* argv[]) { char* exec_args[] = {"id", NULL}; printf("bye stdin\n"); close(STDIN_FILENO); printf("stdin has closed\n"); fflush(stdout); execvp(exec_args[0], exec_args); printf("failed to exec prog.\n"); exit(1); } ---- to here