Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 May 2004 14:51:21 +0100 (BST)
From:      =?iso-8859-1?q?Gao=20Long?= <urgaolong@yahoo.com>
To:        Akihiro Sagawa <sagawa@sohgoh.net>, freebsd-emulation@freebsd.org
Cc:        Sharp Gao <imgaolong@yahoo.com.cn>
Subject:   Re: Device name convert for linux use
Message-ID:  <20040526135121.25679.qmail@web90110.mail.scd.yahoo.com>
In-Reply-To: <20040526204931.0F7E.SAGAWA@sohgoh.net>

next in thread | previous in thread | raw e-mail | index | archive | help


Akihiro Sagawa <sagawa@sohgoh.net> wrote: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


_______________________________________________
freebsd-emulation@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-emulation
To unsubscribe, send any mail to "freebsd-emulation-unsubscribe@freebsd.org"

 

Hi , I moved from imgaolong@yahoo.com.cn to urgaolong@yahoo.com 

for the trouble of gb2312 coding.

The intial pulse to build up a convert table is that we find some one in 

linux always uses the tty? instead of ttyv? , and the gnu libc is always 

fond of checking the major/minor numbers of the devices:->

I have patched the linux_file.c to use a virual name system 

just correspond to  the linux systems , when linux.ko passes device

names into the FreeBSD kernel , we just consult the table and convert 

them into proper FreeBSD styles. So every linux application running on a 

FreeBSD seemed to have a correct device name space , including the 

major/minor device numbers.

After all , the real behavior of the devices are the critical thing. If the 

behavior of the device in two operating systems is absolutely the 

same , so every thing is OK , as we have already impletmented the 

tty? to ttyv? convertion , nothing bad has ever happened . But not to 

any device name else, if the device's behavior is just alike. Other things 

continued to make the table still very short.

I may take up time to implement a my-best solution ,  well , it's just a 

try , before I could understand every details of the device name properties 

of both the Linux and FreeBSD devices.I was still wandering whether it 

could be taken into the next version of linux emulation , for it really can 

improve the compatiblities.


---------------------------------
  Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040526135121.25679.qmail>