qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [patch] Fix uname syscall
@ 2004-09-11 18:33 Paul Brook
  2004-09-11 18:54 ` Lennert Buytenhek
  2004-09-13 21:23 ` Fabrice Bellard
  0 siblings, 2 replies; 4+ messages in thread
From: Paul Brook @ 2004-09-11 18:33 UTC (permalink / raw)
  To: qemu-devel

The patch below changes the uname syscall to return the emulated machine type, 
rather than the host machine type. Without this things get awfully confused 
when trying to compile in a chroot.

Paul

Index: syscall.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/syscall.c,v
retrieving revision 1.50
diff -u -p -r1.50 syscall.c
--- syscall.c 19 Jun 2004 16:59:03 -0000 1.50
+++ syscall.c 11 Sep 2004 18:28:19 -0000
@@ -72,6 +72,17 @@
 /* 16 bit uid wrappers emulation */
 #define USE_UID16
 #endif
+#if defined(TARGET_ARM)
+#define UNAME_MACHINE "armv4"
+#elif defined(TARGET_I386)
+#define UNAME_MACHINE "i686"
+#elif defined(TARGET_PPC)
+#define UNAME_MACHINE "ppc"
+#elif defined(TARGET_SPARC)
+#define UNAME_MACHINE "sun4"
+#else
+#error unsupported CPU
+#endif
 
 //#include <linux/msdos_fs.h>
 #define VFAT_IOCTL_READDIR_BOTH  _IOR('r', 1, struct dirent [2])
@@ -2391,8 +2406,17 @@ long do_syscall(void *cpu_env, int num, 
         ret = get_errno(setdomainname((const char *)arg1, arg2));
         break;
     case TARGET_NR_uname:
-        /* no need to transcode because we use the linux syscall */
-        ret = get_errno(sys_uname((struct new_utsname *)arg1));
+ {
+     struct new_utsname * buf;
+
+     buf = (struct new_utsname *)arg1;
+     ret = get_errno(sys_uname(buf));
+     if (!is_error(ret)) {
+  /* Overwrite the native machine name with whatever is being
+     emulated. */
+  strcpy (buf->machine, UNAME_MACHINE);
+     }
+ }
         break;
 #ifdef TARGET_I386
     case TARGET_NR_modify_ldt:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [patch] Fix uname syscall
  2004-09-11 18:33 [Qemu-devel] [patch] Fix uname syscall Paul Brook
@ 2004-09-11 18:54 ` Lennert Buytenhek
  2004-09-12 11:18   ` Paul Brook
  2004-09-13 21:23 ` Fabrice Bellard
  1 sibling, 1 reply; 4+ messages in thread
From: Lennert Buytenhek @ 2004-09-11 18:54 UTC (permalink / raw)
  To: qemu-devel

On Sat, Sep 11, 2004 at 07:33:10PM +0100, Paul Brook wrote:

> +#define UNAME_MACHINE "armv4"

Wouldn't this be armv4l/armv4b (depending on endianness)?


--L

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [patch] Fix uname syscall
  2004-09-11 18:54 ` Lennert Buytenhek
@ 2004-09-12 11:18   ` Paul Brook
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Brook @ 2004-09-12 11:18 UTC (permalink / raw)
  To: qemu-devel

On Saturday 11 September 2004 19:54, Lennert Buytenhek wrote:
> On Sat, Sep 11, 2004 at 07:33:10PM +0100, Paul Brook wrote:
> > +#define UNAME_MACHINE "armv4"
>
> Wouldn't this be armv4l/armv4b (depending on endianness)?

Yes. Updated patch below.

Paul

Index: syscall.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/syscall.c,v
retrieving revision 1.50
diff -u -p -r1.50 syscall.c
--- syscall.c 19 Jun 2004 16:59:03 -0000 1.50
+++ syscall.c 12 Sep 2004 11:11:26 -0000
@@ -72,6 +72,21 @@
 /* 16 bit uid wrappers emulation */
 #define USE_UID16
 #endif
+#if defined(TARGET_ARM)
+#if defined(TARGET_WORDS_BIGENDIAN)
+#define UNAME_MACHINE "armv4b"
+#else
+#define UNAME_MACHINE "armv4l"
+#endif
+#elif defined(TARGET_I386)
+#define UNAME_MACHINE "i686"
+#elif defined(TARGET_PPC)
+#define UNAME_MACHINE "ppc"
+#elif defined(TARGET_SPARC)
+#define UNAME_MACHINE "sun4"
+#else
+#error unsupported CPU
+#endif
 
 //#include <linux/msdos_fs.h>
 #define VFAT_IOCTL_READDIR_BOTH  _IOR('r', 1, struct dirent [2])
@@ -2391,8 +2410,17 @@ long do_syscall(void *cpu_env, int num, 
         ret = get_errno(setdomainname((const char *)arg1, arg2));
         break;
     case TARGET_NR_uname:
-        /* no need to transcode because we use the linux syscall */
-        ret = get_errno(sys_uname((struct new_utsname *)arg1));
+ {
+     struct new_utsname * buf;
+
+     buf = (struct new_utsname *)arg1;
+     ret = get_errno(sys_uname(buf));
+     if (!is_error(ret)) {
+  /* Overrite the native machine name with whatever is being
+     emulated. */
+  strcpy (buf->machine, UNAME_MACHINE);
+     }
+ }
         break;
 #ifdef TARGET_I386
     case TARGET_NR_modify_ldt:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [patch] Fix uname syscall
  2004-09-11 18:33 [Qemu-devel] [patch] Fix uname syscall Paul Brook
  2004-09-11 18:54 ` Lennert Buytenhek
@ 2004-09-13 21:23 ` Fabrice Bellard
  1 sibling, 0 replies; 4+ messages in thread
From: Fabrice Bellard @ 2004-09-13 21:23 UTC (permalink / raw)
  To: qemu-devel

Applied, but suppressed ifdefs.

Fabrice.

Paul Brook wrote:
> The patch below changes the uname syscall to return the emulated machine type, 
> rather than the host machine type. Without this things get awfully confused 
> when trying to compile in a chroot.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-09-13 21:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-11 18:33 [Qemu-devel] [patch] Fix uname syscall Paul Brook
2004-09-11 18:54 ` Lennert Buytenhek
2004-09-12 11:18   ` Paul Brook
2004-09-13 21:23 ` Fabrice Bellard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).