Added run time options.
New utssys handling.
This commit is contained in:
parent
e190dfa9b4
commit
46d7e202c2
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
Thu Jan 14 22:30:13 GMT/BST 1999
|
||||
|
||||
* Added a run time options (setable with the ibcs_options
|
||||
program) that control run-time behaviour of iBCS.
|
||||
Currently this just allows SCO utsname to either return
|
||||
Linux information from the running kernel or pretend
|
||||
to be a real SCO OpenServer 5 system - which is, for
|
||||
instance, necessary if you want to install the SCO
|
||||
version of Informix Dynamic Server (but not necessary
|
||||
to actually run it, just install it!)
|
||||
-- Mike
|
||||
|
||||
* Fixed utssys() handling so it both returns the old
|
||||
v7_utsname struct (function 0) and performs a ustat
|
||||
(function 3). Other function values probably do other
|
||||
things but I don't know what...
|
||||
-- Mike
|
||||
|
||||
|
||||
Thu Jan 14 21:36:51 GMT/BST 1999
|
||||
|
||||
* If we are passed a bogus flags value in a getmsg call
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
#
|
||||
# ibcs/Tools/Makefile
|
||||
#
|
||||
# $Id: Makefile,v 1.10 1998/10/11 11:00:18 jaggy Exp $
|
||||
# $Id: Makefile,v 1.11 1999/01/14 22:37:18 jaggy Exp $
|
||||
# $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/Tools/Makefile,v $
|
||||
#
|
||||
|
||||
|
||||
all: lnxstamp trace
|
||||
all: lnxstamp trace options
|
||||
|
||||
install: all
|
||||
cp trace /usr/sbin/ibcs_trace
|
||||
chmod 755 /usr/sbin/ibcs_trace
|
||||
cp options /usr/sbin/ibcs_options
|
||||
chmod 755 /usr/sbin/ibcs_options
|
||||
cp mkmnttab /usr/bin/mkmnttab
|
||||
chmod 755 /usr/bin/mkmnttab
|
||||
|
||||
clean:
|
||||
rm -f trace lnxstamp
|
||||
rm -f trace lnxstamp options
|
||||
|
||||
|
||||
lnxstamp: lnxstamp.c
|
||||
|
@ -22,6 +26,9 @@ lnxstamp: lnxstamp.c
|
|||
trace: trace.c
|
||||
cc -O -fomit-frame-pointer -o trace -I../include trace.c
|
||||
|
||||
options: options.c
|
||||
cc -O -fomit-frame-pointer -o options -I../include options.c
|
||||
|
||||
dep:
|
||||
$(CPP) -M -I../include $(CFLAGS) *.c > .depend
|
||||
|
||||
|
|
140
Tools/options.c
Normal file
140
Tools/options.c
Normal file
|
@ -0,0 +1,140 @@
|
|||
/*
|
||||
* little utility to change run time options for iBCS
|
||||
*
|
||||
* Copyright (C) 1999 Mike Jagdis (jaggy@purplet.demon.co.uk)
|
||||
*
|
||||
* $Id: options.c,v 1.1 1999/01/14 22:37:18 jaggy Exp $
|
||||
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/Tools/options.c,v $
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include <features.h>
|
||||
|
||||
#include <linux/personality.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if __GLIBC__ >= 2
|
||||
# include <syscall.h>
|
||||
# include <unistd.h>
|
||||
#else
|
||||
# include <linux/unistd.h>
|
||||
#endif
|
||||
|
||||
#include <ibcs/options.h>
|
||||
|
||||
|
||||
#if __GLIBC__ >= 2
|
||||
# define personality(X) syscall(__NR_personality, (X))
|
||||
#else
|
||||
_syscall1(int, personality, int, pers);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __sparc__
|
||||
static int
|
||||
set_options(int val)
|
||||
{
|
||||
int res;
|
||||
|
||||
__asm__ volatile ("mov %1,%%o0\n\t"
|
||||
"mov 195,%%g1\n\t"
|
||||
"t 8\n\t"
|
||||
"mov %%o0,%0" : "=r" (res) : "r" (val) : "o0", "g1");
|
||||
return res;
|
||||
}
|
||||
|
||||
#else /* __sparc__ */
|
||||
|
||||
static int
|
||||
set_options(int val)
|
||||
{
|
||||
int res;
|
||||
|
||||
__asm__ volatile ("mov\t$0x02FF,%%eax\n\t"
|
||||
".byte\t0x9a,0,0,0,0,7,0\n\t"
|
||||
: "=a" (res));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
#endif /* __sparc__ */
|
||||
|
||||
|
||||
struct o_code {
|
||||
char *name;
|
||||
int code;
|
||||
};
|
||||
|
||||
struct o_code codes[] = {
|
||||
{ "sco-id-sco", OPTION_SCO_ID_SCO },
|
||||
{ "sco-id-os5", OPTION_SCO_ID_OS5 }
|
||||
};
|
||||
|
||||
|
||||
static int
|
||||
get_code(char *s)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i<sizeof(codes)/sizeof(codes[0]); i++)
|
||||
if (!strcmp(s, codes[i].name))
|
||||
return codes[i].code;
|
||||
|
||||
fprintf(stderr, "%s not recognised - ignored\n", s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf(stderr,
|
||||
"usage: trace n - set options to n\n"
|
||||
" or [+|-]code - where code could be:\n"
|
||||
" query\n"
|
||||
" off\n");
|
||||
|
||||
for (i=0; i<sizeof(codes)/sizeof(codes[0]); i++)
|
||||
fprintf(stderr, " %s\n", codes[i].name);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int old_options_val, options_val, i;
|
||||
|
||||
if (argc == 1) {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* We need to be in a non-native personality to get access to
|
||||
* the emulator's trace facilities.
|
||||
*/
|
||||
personality(PER_SVR3);
|
||||
|
||||
old_options_val = options_val = set_options(-1);
|
||||
for (i=1; i<argc; i++) {
|
||||
if (!strcmp(argv[i], "query")) {
|
||||
printf("iBCS options code is 0x%lx\n", set_options(-1));
|
||||
} else if (!strcmp(argv[i], "off")) {
|
||||
options_val = 0;
|
||||
} else if (argv[i][0] == '+') {
|
||||
options_val |= get_code(argv[i]+1);
|
||||
} else if (argv[i][0] == '-') {
|
||||
options_val &= (~get_code(argv[i]+1));
|
||||
} else {
|
||||
options_val |= get_code(argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (options_val != old_options_val)
|
||||
printf("iBCS options code is 0x%lx\n",
|
||||
set_options(options_val));
|
||||
|
||||
exit(0);
|
||||
}
|
|
@ -24,7 +24,7 @@
|
|||
* the Linux TCP/IP stack.
|
||||
* -- Mike Jagdis (jaggy@purplet.demon.co.uk)
|
||||
*
|
||||
* $Id: emulate.c,v 1.41 1998/06/29 21:52:38 jaggy Exp $
|
||||
* $Id: emulate.c,v 1.42 1999/01/14 22:37:19 jaggy Exp $
|
||||
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/iBCSemul/emulate.c,v $
|
||||
*/
|
||||
|
||||
|
@ -64,6 +64,7 @@
|
|||
static void plist(int id, char *name, char *args, int *list);
|
||||
static void fail(int id, long eax, char *name);
|
||||
int ibcs_trace = 0;
|
||||
int ibcs_options = 0;
|
||||
int ibcs_id = 0;
|
||||
|
||||
static char *sig_names[] = {
|
||||
|
@ -116,6 +117,8 @@ char kernel_version[] = UTS_RELEASE;
|
|||
MODULE_AUTHOR("Mike Jagdis <jaggy@purplet.demon.co.uk>");
|
||||
MODULE_DESCRIPTION("Support for non-Linux programs");
|
||||
MODULE_SUPPORTED_DEVICE("socksys");
|
||||
MODULE_PARM(ibcs_options, "i");
|
||||
MODULE_PARM_DESC(ibcs_options, "iBCS options");
|
||||
MODULE_PARM(sco_serial, "1-10s");
|
||||
MODULE_PARM_DESC(sco_serial, "SCO Serial Number");
|
||||
#ifdef IBCS_TRACE
|
||||
|
@ -359,6 +362,17 @@ ibcs_syscall(struct pt_regs *regs)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int ibcs_options_set(int arg)
|
||||
{
|
||||
if (arg != -1) {
|
||||
ibcs_options = arg;
|
||||
printk(KERN_DEBUG "iBCS: options code set to 0x%x\n",
|
||||
ibcs_options);
|
||||
}
|
||||
|
||||
return ibcs_options;
|
||||
}
|
||||
|
||||
#ifdef IBCS_TRACE
|
||||
int ibcs_trace_set(int arg)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* to resolve a syscall or when changing trace settings.
|
||||
* Careful!
|
||||
*
|
||||
* $Id: callmap.inc,v 1.74 1998/10/08 21:32:57 jaggy Exp $
|
||||
* $Id: callmap.inc,v 1.75 1999/01/14 22:37:19 jaggy Exp $
|
||||
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/iBCSemul/maps/callmap.inc,v $
|
||||
*/
|
||||
|
||||
|
@ -39,7 +39,7 @@ static IBCS_func Unused[] = {
|
|||
static IBCS_func LNX_func_0x00[] = {
|
||||
{ ibcs_trace_set, 1 ITR(0, "trace", "d") }, /* 0 */
|
||||
{ ibcs_trace_func, 3 ITR(0, "trace", "ddd") }, /* 1 */
|
||||
{ 0, Ukn ITR(1, "?", "") }, /* 2 */
|
||||
{ ibcs_options_set, 1 ITR(0, "options", "x") }, /* 2 */
|
||||
{ 0, Ukn ITR(1, "?", "") }, /* 3 */
|
||||
{ 0, Ukn ITR(1, "?", "") }, /* 4 */
|
||||
{ 0, Ukn ITR(1, "?", "") }, /* 5 */
|
||||
|
@ -310,7 +310,7 @@ static IBCS_func iBCS_func_0x30[] = {
|
|||
};
|
||||
static IBCS_func iBCS_func_0x38[] = {
|
||||
{ 0, Ukn ITR(1, "?", "") }, /* 56 */
|
||||
{ v7_utsname, 1 ITR(0, "utsys", "x") }, /* 57 */
|
||||
{ v7_utsname, 3 ITR(0, "utsys", "xdd") }, /* 57 */
|
||||
{ SC(fsync), -1 ITR(0, "fsync", "d") }, /* 58 */
|
||||
{ ibcs_exec, Spl ITR(0, "execv", "spp") }, /* 59 */
|
||||
{ SC(umask), -1 ITR(0, "umask", "o") }, /* 60 */
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <linux/utsname.h>
|
||||
|
||||
#include <ibcs/ibcs.h>
|
||||
#include <ibcs/options.h>
|
||||
|
||||
char sco_serial[10] = "public";
|
||||
|
||||
|
@ -58,7 +59,7 @@ struct svr4_utsname {
|
|||
|
||||
|
||||
#define set_utsfield(to, from, dotchop) \
|
||||
{ \
|
||||
do { \
|
||||
char *p; \
|
||||
int i, len = (sizeof(to) > sizeof(from) ? sizeof(from) : sizeof(to)); \
|
||||
__copy_to_user(to, from, len); \
|
||||
|
@ -67,7 +68,7 @@ struct svr4_utsname {
|
|||
else \
|
||||
i = len - 1; \
|
||||
__put_user('\0', to+i); \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
|
||||
int
|
||||
|
@ -87,17 +88,15 @@ sco_utsname(unsigned long addr)
|
|||
down(&uts_sem);
|
||||
error = verify_area(VERIFY_WRITE, it, sizeof (struct sco_utsname));
|
||||
if (!error) {
|
||||
#if 0
|
||||
set_utsfield(it->sysname, system_utsname.nodename, 1);
|
||||
#else
|
||||
set_utsfield(it->sysname, "SCO_SV", 0);
|
||||
#endif
|
||||
if (ibcs_options & OPTION_SCO_ID_SCO)
|
||||
set_utsfield(it->sysname, "SCO_SV", 0);
|
||||
else
|
||||
set_utsfield(it->sysname, system_utsname.nodename, 1);
|
||||
set_utsfield(it->nodename, system_utsname.nodename, 1);
|
||||
#if 0
|
||||
set_utsfield(it->release, system_utsname.release, 0);
|
||||
#else
|
||||
set_utsfield(it->release, "3.2v5.0.0\0", 0);
|
||||
#endif
|
||||
if (ibcs_options & OPTION_SCO_ID_OS5)
|
||||
set_utsfield(it->release, "3.2v5.0.0\0", 0);
|
||||
else
|
||||
set_utsfield(it->release, system_utsname.release, 0);
|
||||
set_utsfield(it->kernelid, system_utsname.version, 0);
|
||||
set_utsfield(it->machine, system_utsname.machine, 0);
|
||||
if (EISA_bus) {
|
||||
|
@ -118,23 +117,44 @@ sco_utsname(unsigned long addr)
|
|||
|
||||
|
||||
int
|
||||
v7_utsname(unsigned long addr)
|
||||
v7_utsname(unsigned long addr, unsigned long dev, int flag)
|
||||
{
|
||||
int error;
|
||||
struct v7_utsname *it = (struct v7_utsname *)addr;
|
||||
switch (flag) {
|
||||
case 0: {
|
||||
/* v7 utsname call, return the basic utsname struct. */
|
||||
int error;
|
||||
struct v7_utsname *it = (struct v7_utsname *)addr;
|
||||
|
||||
down(&uts_sem);
|
||||
error = verify_area(VERIFY_WRITE, it, sizeof (struct v7_utsname));
|
||||
if (!error) {
|
||||
set_utsfield(it->sysname, system_utsname.nodename, 1);
|
||||
set_utsfield(it->nodename, system_utsname.nodename, 1);
|
||||
set_utsfield(it->release, system_utsname.release, 0);
|
||||
set_utsfield(it->version, system_utsname.version, 0);
|
||||
set_utsfield(it->machine, system_utsname.machine, 0);
|
||||
down(&uts_sem);
|
||||
error = verify_area(VERIFY_WRITE,
|
||||
it, sizeof(struct v7_utsname));
|
||||
if (!error) {
|
||||
set_utsfield(it->sysname,
|
||||
system_utsname.nodename, 1);
|
||||
set_utsfield(it->nodename,
|
||||
system_utsname.nodename, 1);
|
||||
set_utsfield(it->release,
|
||||
system_utsname.release, 0);
|
||||
set_utsfield(it->version,
|
||||
system_utsname.version, 0);
|
||||
set_utsfield(it->machine,
|
||||
system_utsname.machine, 0);
|
||||
}
|
||||
up(&uts_sem);
|
||||
return error;
|
||||
}
|
||||
|
||||
case 3: {
|
||||
/* ustat call, return filesystem information for
|
||||
* the device whose major/minor is given by dev.
|
||||
*/
|
||||
return SYS(ustat)(dev, (struct ustat *)addr);
|
||||
}
|
||||
}
|
||||
up(&uts_sem);
|
||||
|
||||
return error;
|
||||
printk(KERN_ERR "iBCS: utssys %ld unsupported\n",
|
||||
(unsigned long)flag);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Function prototypes used by the iBCS2 emulator
|
||||
*
|
||||
* $Id: ibcs.h,v 1.58 1998/11/05 21:50:32 jaggy Exp $
|
||||
* $Id: ibcs.h,v 1.59 1999/01/14 22:37:19 jaggy Exp $
|
||||
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/include/ibcs/ibcs.h,v $
|
||||
*/
|
||||
#include <linux/ptrace.h> /* for pt_regs */
|
||||
|
@ -18,6 +18,11 @@
|
|||
#endif
|
||||
|
||||
|
||||
/* Used for run time options - see <ibcs/options.h> */
|
||||
extern int ibcs_options;
|
||||
extern int ibcs_options_set(int arg);
|
||||
|
||||
|
||||
/* This should probably be defined in the kernel's personality.h
|
||||
* along with the other PER_* stuff but this is pretty new so
|
||||
* won't appear until sometime in the 2.1.x series (where x > 36
|
||||
|
@ -289,7 +294,7 @@ extern int ibcs_setrlimit(int cmd, void *val);
|
|||
/* utsname.c */
|
||||
extern int abi_utsname(unsigned long addr);
|
||||
extern int sco_utsname(unsigned long addr);
|
||||
extern int v7_utsname(unsigned long addr);
|
||||
extern int v7_utsname(unsigned long addr, unsigned long dev, int flag);
|
||||
|
||||
/* wysev386.c */
|
||||
extern int wv386_gethostname(char *name, int len);
|
||||
|
|
17
include/ibcs/options.h
Normal file
17
include/ibcs/options.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* ibcs trace -- mask of trace values
|
||||
*
|
||||
* $Id: options.h,v 1.1 1999/01/14 22:37:19 jaggy Exp $
|
||||
* $Source: /nfs4/sophia/home/mjagdis/src/ibcs.cvs/ibcs/include/ibcs/options.h,v $
|
||||
*/
|
||||
|
||||
/* If set the SCO utsname call will return "SCO_SV". Otherwise it
|
||||
* will return the real Linux nodename.
|
||||
*/
|
||||
#define OPTION_SCO_ID_SCO 0x00000001
|
||||
|
||||
/* If set the SCO utsname call will return "3.2v5.0.0" as does
|
||||
* SCO OpenServer 5. Otherwise it will return the real Linux
|
||||
* version number.
|
||||
*/
|
||||
#define OPTION_SCO_ID_OS5 0x00000002
|
Loading…
Reference in a new issue