summaryrefslogtreecommitdiff
path: root/elksemu
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2004-01-24 16:27:32 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:49 +0200
commitbeba34dc223aa0dcf3e5f696966c5e8408b022c3 (patch)
treeea0523ac242bd3e877338e9a771b975d4cd3839a /elksemu
parentb5dac1e3bdd01a2ce105df747a9073ff0d6a94e2 (diff)
downloaddev86-beba34dc223aa0dcf3e5f696966c5e8408b022c3.tar.gz
Import Dev86src-0.16.15.tar.gzv0.16.15
Diffstat (limited to 'elksemu')
-rw-r--r--elksemu/Makefile7
-rw-r--r--elksemu/README8
-rw-r--r--elksemu/Security2
-rw-r--r--elksemu/elks.c5
-rw-r--r--elksemu/elks.h22
-rw-r--r--elksemu/elks_sys.c37
-rw-r--r--elksemu/mkefile11
7 files changed, 57 insertions, 35 deletions
diff --git a/elksemu/Makefile b/elksemu/Makefile
index f613fde..df97c2d 100644
--- a/elksemu/Makefile
+++ b/elksemu/Makefile
@@ -26,13 +26,16 @@ OBJ=elks.o elks_sys.o elks_signal.o minix.o
elksemu: $(OBJ)
$(CC) $(CFLAGS) -o $@ $^
-elks_sys.o: call_tab.v
+elks_sys.o: call_tab.v efile.h
$(OBJ): elks.h
call_tab.v: dummy
-cp -p ../libc/syscall/call_tab.v . 2>/dev/null
-cp -p ../libc/syscall/defn_tab.v . 2>/dev/null
+efile.h: ../libc/error/liberror.txt
+ sh mkefile ../libc/error/liberror.txt
+
dummy:
# The kernel patch or module _requires_ this location but binfmt-misc is easy
@@ -42,7 +45,7 @@ install: elksemu
install -s -o root -g root -m 4555 elksemu $(DIST)/lib/elksemu
clean realclean:
- rm -f $(OBJ) binfmt_elks.o elksemu call_tab.v defn_tab.v
+ rm -f $(OBJ) binfmt_elks.o elksemu call_tab.v defn_tab.v efile.h
module: binfmt_elks.o
diff --git a/elksemu/README b/elksemu/README
index 065d22b..a7092b8 100644
--- a/elksemu/README
+++ b/elksemu/README
@@ -6,18 +6,12 @@ If you're using a 2.0.36, 2.1.43, 2.2.0 or later kernel then the
binfmt_misc driver is in the stock kernel and all you need to do is
add the following line into the relevent /etc/rc* file.
-echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/lib/elksemu:' \
+echo ':i86-elks:M::\x01\x03\x20\x00:\xff\xff\xff\x83:/usr/bin/elksemu:' \
> /proc/sys/fs/binfmt_misc/register
Note, however, if binfmt_misc is compiled as a module it will not auto
load so you will have to do this manually.
-Further by default the elksemu executable is compiled as an OMAGIC
-executable and needs binfmt_aout. If binfmt_aout is a module and your
-/etc/modules.conf is not correctly configured you may have to load this
-module manually too. Alternativily you can compile elksemu using GCC
-to produce an ELF executable.
-
If your kernel version is 1.2.13 then apply the patch in the Kernel_patch
file.
diff --git a/elksemu/Security b/elksemu/Security
index 2fbef8b..16418e7 100644
--- a/elksemu/Security
+++ b/elksemu/Security
@@ -1,4 +1,4 @@
-The install scripts now install /lib/elksemu as a suid-root executable.
+Is is possible to install /usr/bin/elksemu as a suid-root executable.
This gives two additional facilities when running elks executables.
1) It is now possible to run programs that are execute only, without
diff --git a/elksemu/elks.c b/elksemu/elks.c
index ddcf549..3dd3a4d 100644
--- a/elksemu/elks.c
+++ b/elksemu/elks.c
@@ -223,7 +223,8 @@ void build_stack(char ** argv, char ** envp)
*pip++ = 0;
}
-void main(int argc, char *argv[], char *envp[])
+int
+main(int argc, char *argv[], char *envp[])
{
int fd;
struct stat st;
@@ -258,7 +259,7 @@ void main(int argc, char *argv[], char *envp[])
setregid(rgid, egid);
setreuid(ruid, euid);
- dbprintf(("ELKSEMU 0.12.0\n"));
+ dbprintf(("ELKSEMU\n"));
elks_init();
/* The Linux vm will deal with not allocating the unused pages */
diff --git a/elksemu/elks.h b/elksemu/elks.h
index 5da93a1..26fa446 100644
--- a/elksemu/elks.h
+++ b/elksemu/elks.h
@@ -24,17 +24,17 @@
struct elks_stat
{
- unsigned short st_dev;
- unsigned short st_inode;
- unsigned short st_mode;
- unsigned short st_nlink;
- unsigned short st_uid;
- unsigned short st_gid;
- unsigned short st_rdev;
- int st_size;
- int st_atime;
- int st_mtime;
- int st_ctime;
+ unsigned short est_dev;
+ unsigned short est_inode;
+ unsigned short est_mode;
+ unsigned short est_nlink;
+ unsigned short est_uid;
+ unsigned short est_gid;
+ unsigned short est_rdev;
+ int est_size;
+ int est_atime;
+ int est_mtime;
+ int est_ctime;
};
diff --git a/elksemu/elks_sys.c b/elksemu/elks_sys.c
index a886e99..5699edc 100644
--- a/elksemu/elks_sys.c
+++ b/elksemu/elks_sys.c
@@ -24,6 +24,8 @@
#include <sys/time.h>
#include "elks.h"
+#include "efile.h"
+
#ifdef DEBUG
#define dbprintf(x) db_printf x
#else
@@ -69,17 +71,17 @@ static void squash_stat(struct stat *s, int bx)
ELKS_POKE(long, bx+26, s->st_ctime);
#else
struct elks_stat * ms = ELKS_PTR(struct elks_stat, bx);
- ms->st_dev=s->st_dev;
- ms->st_inode=(unsigned short)s->st_ino; /* Bits lost */
- ms->st_mode=s->st_mode;
- ms->st_nlink=s->st_nlink;
- ms->st_uid=s->st_uid;
- ms->st_gid=s->st_gid;
- ms->st_rdev=s->st_rdev;
- ms->st_size=s->st_size;
- ms->st_atime=s->st_atime;
- ms->st_mtime=s->st_mtime;
- ms->st_ctime=s->st_ctime;
+ ms->est_dev=s->st_dev;
+ ms->est_inode=(unsigned short)s->st_ino; /* Bits lost */
+ ms->est_mode=s->st_mode;
+ ms->est_nlink=s->st_nlink;
+ ms->est_uid=s->st_uid;
+ ms->est_gid=s->st_gid;
+ ms->est_rdev=s->st_rdev;
+ ms->est_size=s->st_size;
+ ms->est_atime=s->st_atime;
+ ms->est_mtime=s->st_mtime;
+ ms->est_ctime=s->st_ctime;
#endif
}
@@ -142,6 +144,17 @@ static int elks_open(int bx,int cx,int dx,int di,int si)
dbprintf(("open(%s, %d, %d)\n",
dp,cx,dx));
+ /* Nasty hack so /lib/liberror.txt doesn't exist on the host.
+ */
+ if (strcmp(dp, "/lib/liberror.txt") == 0 ) {
+ int fd = open("/tmp/liberror.txt", O_CREAT|O_EXCL|O_RDWR, 0666);
+ if (fd < 0) return fd;
+ unlink("/tmp/liberror.txt");
+ write(fd, efile, sizeof(efile));
+ lseek(fd, 0L, 0);
+ return fd;
+ }
+
if( cx == O_RDONLY )
{
if(stat(dp,&s)==-1)
@@ -451,7 +464,7 @@ static int elks_execve(int bx,int cx,int dx,int di,int si)
ct=0;
if( is_elks )
{
- argp[0]="/lib/elksemu";
+ argp[0]="/usr/bin/elksemu";
/* argp[1]=ELKS_PTR(char, bx); */
ct=1;
}
diff --git a/elksemu/mkefile b/elksemu/mkefile
new file mode 100644
index 0000000..b9e24ee
--- /dev/null
+++ b/elksemu/mkefile
@@ -0,0 +1,11 @@
+#!/bin/sh -
+
+awk '
+BEGIN {
+ printf "char efile[] =\n"
+}
+{ printf " \"%s\\n\"\n", $0 }
+END{
+ printf ";\n";
+}
+' < "$1" > efile.h