home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
3
/
3949
< prev
next >
Wrap
Text File
|
1991-08-31
|
13KB
|
444 lines
Xref: wupost comp.unix.xenix.sco:4165 alt.sources:3949
Path: wupost!uunet!mcsun!ukc!stl!robobar!ronald
From: ronald@robobar.co.uk (Ronald S H Khoo)
Newsgroups: comp.unix.xenix.sco,alt.sources
Subject: XENIX 2.3.4 syscalls (Re: What is newest Xenix Dev System Release?)
Summary: source code included
Keywords: xenix OS 2.3.4 / DS 2.3.1
Message-ID: <1991Aug31.182326.6506@robobar.co.uk>
Date: 31 Aug 91 18:23:26 GMT
References: <19385@scorn.sco.COM>
Followup-To: comp.unix.xenix.sco
Organization: Robobar Ltd., Perivale, Middx., ENGLAND.
Lines: 429
Archive-Name: Xenix/dumpsys
timr@sco.COM (Tim Ruckle) writes:
> There are no new system calls in the 2.3.4 kernel.
This is, of course, not true, as has already been observed. scoinfo()
and eacess() being mentioned in the released notes.
You can use a generic cxenix() system call interface to call these routines
of course. More of that below.
> You've got the latest release of the XENIX Dev Sys with Release 2.3.1
> and lng244.
This is again, only true "in a sense". Yes, it's the latest Development
System from SCO that is labeled "for XENIX". However, it is useful to note
that the SCO Unix development system's XENIX cross-development package
is newer, and of course it will run on a current SCO XENIX. *Many
Times* in the past Sean F has mentioned in the past that he used to do
exactly that. (So if it don't work, blame him, not me :-)
In the old version (I only have 3.2.0f, I can't speak for the current
version) eaccess is in /lib/386/Slib3.2.a, but a cursory glance does not
seem to reveal scoinfo. Doesn't matter. See below.
OK, so you want the generic cxenix() call, and the syscall numbers for
eaccess() and scoinfo(). I could just tell you what they are, but it's
much more useful to give you my "dumpsys" program that will extract
the numbers out of your link-kit, just in case SCO upgrades XENIX again
and puts more system calls in which you want to call. You will need
GCC/GAS as recently posted here (or ftp them from unix.secs.oakland.edu)
because I don't use the Microsoft rubbish, and so the stuff below needs
GCC/GAS.
The shar below contains the source and Makefile to generate the dumpsys
program that reveals the system call numbers. If you have access to
a SCO UNIX development system, this information is also available
in /usr/include/sys.s, but dumpsys will tell you what calls are
actually implemented on your kernel. I am grateful to
Keith "Pax" Gabryelski <ag@cbmvax.commodore.com> for his news
article <38@elgar.UUCP> (dated 24 Jan 89) for the information which
led to dumpsys.
Having run dumpsys on a XENIX 2.3.4 system, you will find that eaccess()
is cxenix(37) and scoinfo() is cxenix(50). Now for the calling sequence.
By guesswork, you can intuit that eaccess() is called the same way as
access() and I suppose scoinfo() is probably called the same way as
uname() (but I can't check because it's the weekend, and the 2.3.4
machine is at the office)
To use the generic cxenix() call, just say stuff like cxenix(37, file, mode)
instead of eaccess(file, mode). Look, I'll even throw in a eaccess(1)
command sample, just do
gcc eaccess.c syscall.S -o eaccess
to compile it. It even has a usage: line when invoked with no args,
but no manual page. Hey, this is my weekend! :-)
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# Makefile
# dumpsys.c
# eaccess.c
# sizes.sh
# syscall.S
# This archive created: Sat Aug 31 19:16:04 1991
export PATH; PATH=/bin:$PATH
echo shar: extracting "'Makefile'" '(1946 characters)'
if test -f 'Makefile'
then
echo shar: will not over-write existing file "'Makefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Makefile'
X# /*
X# * @begin{boilerplate}
X# * Copyright 1991 Ronald Khoo <ronald@ibmpcug.co.uk>
X# * This is Really Free Software.
X# * Permission granted to use this software for any purpose provided that
X# * the author be held free from any blame for anything that may occur as a
X# * result of this software being used; that this notice be preserved in all
X# * copies of this software and derived works, and the documentation therof;
X# * and that any modifications be clearly marked as such.
X# * @end{boilerplate}
X# */
XCC= /usr/local/bin/gcc
XMDEP= /usr/sys/mdep
XE= sysent.o cxenix.o
XO= $(OO) $E
XOO= dumpsys.o stubs.o
X
Xdumpsys: $O
X $(CC) $(CFLAGS) $O -o $@
X
Xstubs.c: $E Makefile
X nm -g $E | sed -n '/ * U _\([a-z][^ ]*\)/s//\1/p' | sort -u > T
X sed -n -e '/^write$$/{s//extern write();/p;d;}' \
X -e '/^cxenix$$/{s//extern cxenix();/p;d;}' \
X -e '/^utssys$$/{s//extern utssys();/p;d;}' \
X -e 's/.*/&(){}/p' T > $@
X echo "struct { int (*func)(); char *name; } functab[] = {" >> $@
X sed 's/.*/ { &, "&" },/' T >> $@
X echo "0 };" >> $@
X nm -g $E | sed -n '/.* _\([a-z][^ ]*ent\) *$$/s//\1/p' | sort -u > T
X nm -g $E | sed -n '/.* _\([a-z][^ ]*entry\) *$$/s//\1/p' | sort -u >> T
X sed 's/.*/extern struct sysent &[];/' T >> $@
X echo '#include "stubs.h"' >> $@
X echo '#include <sys/types.h>' >> $@
X echo '#include <sys/systm.h>' >> $@
X echo "struct { struct sysent *sysent; char *name; int nent; } systab[] = {" >> $@
X sed 's/.*/ { &, "&", SIZE_& \/ sizeof (struct sysent) },/' T >> $@
X echo "};" >> $@
X echo "int nsysent = sizeof systab / sizeof *systab;" >> $@
X rm -f T
X
Xstubs.o: stubs.h
X
Xstubs.h: $E Makefile
X echo int fred = 5\; > x.c
X -$(CC) $E x.c -o x
X : yes, i did expect all those link errors
X nm -n x | \
X sed -n '/^....:\([0-9a-zA-Z]*\) *D _\(.*\)$$/s//\1 \2/p' | \
X sh sizes.sh > stubs.h
X rm -f x x.c
X
Xclean:
X rm -f x a.out core $(OO) stubs.* x.c
X
Xrealclean: clean
X rm -f $E dumpsys
X
X$E: $(MDEP)/libmdep.a
X ar x $? $@
SHAR_EOF
if test 1946 -ne "`wc -c < 'Makefile'`"
then
echo shar: error transmitting "'Makefile'" '(should have been 1946 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'dumpsys.c'" '(2588 characters)'
if test -f 'dumpsys.c'
then
echo shar: will not over-write existing file "'dumpsys.c'"
else
sed 's/^X//' << \SHAR_EOF > 'dumpsys.c'
X/*
X * @begin{boilerplate}
X * Copyright 1991 Ronald Khoo <ronald@ibmpcug.co.uk>
X * This is Really Free Software.
X * Permission granted to use this software for any purpose provided that
X * the author be held free from any blame for anything that may occur as a
X * result of this software being used; that this notice be preserved in all
X * copies of this software and derived works, and the documentation therof;
X * and that any modifications be clearly marked as such.
X * @end{boilerplate}
X */
X#include <sys/types.h>
X#include <sys/systm.h>
X
Xextern struct { int (*func)(); char *name; } functab[];
Xextern struct { struct sysent *sysent; char *name; int nent; } systab[];
Xextern int nsysent;
Xextern nosys();
X
X#if 0
Xmain()
X{
X int i, j, k;
X register struct sysent *s;
X
X printf("dumpsys: %d sysent tables found\n", nsysent);
X
X for (i = 0; i < nsysent; i++) {
X printf("\n%s:\n", systab[i].name);
X for (s = systab[i].sysent; s < systab[i].sysent + systab[i].nent; s++) {
X printf ("% 4d | ", s - systab[i].sysent);
X printf("% 3d | % 3d | % 2d | % 2d | %#08o | ",
Xs->sy_ret, s->sy_arg386, s->sy_nlarg286, s->sy_nmarg286, s->sy_argmask);
X k = 1;
X for (j = 0; functab[j].func; j++)
X if (functab[j].func == s->sy_call) {
X printf("%s\n", functab[j].name);
X k = 0;
X break;
X }
X if (k) printf("%#04x\n", s->sy_call);
X }
X }
X}
X#endif
X
Xextern struct sysent sysent[], cxentry[], svidsysent[];
Xint sysent_count, cxentry_count, svidsysent_count;
X
Xstruct { char *name; int *count; } tab2[] = {
X { "sysent", &sysent_count },
X { "cxentry", &cxentry_count },
X { "svidsysent", &svidsysent_count },
X 0
X};
X
X#include <stdio.h>
Xmain()
X{
X int i, j;
X
X for (i = 0; i < nsysent; i++)
X for (j=0; tab2[j].name; j++)
X if (strcmp(tab2[j].name, systab[i].name) == 0)
X tab2[j].count[0] = systab[i].nent;
X
X /* don't ask me how or why this redirection works */
X /* it just seems to (on xenix 386 2.3.3 anyway) */
X for (i=0; i < sysent_count; i++)
X if (sysent[i].sy_call == 0)
X sysent[i] = svidsysent[sysent[i].sy_arg386];
X
X printf("sysent:\n\n");
X printsys(sysent, sysent_count);
X printf("\n\ncxentry:\n\n");
X printsys(cxentry, cxentry_count);
X exit(0);
X}
X
Xprintsys(ent, count)
X struct sysent *ent;
X{
X int i, j;
X
X for (i = 0; i < count; i++) {
X register struct sysent *s = ent + i;
X if (s->sy_call == nosys)
X continue;
X printf ("% 4d | ", i);
X printf("% 3d | % 3d | %#08o | ",
X s->sy_ret, s->sy_arg386, s->sy_argmask);
X for (j = 0; functab[j].func; j++)
X if (functab[j].func == s->sy_call) {
X printf("%s", functab[j].name);
X break;
X }
X putchar('\n');
X }
X}
SHAR_EOF
if test 2588 -ne "`wc -c < 'dumpsys.c'`"
then
echo shar: error transmitting "'dumpsys.c'" '(should have been 2588 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'eaccess.c'" '(1215 characters)'
if test -f 'eaccess.c'
then
echo shar: will not over-write existing file "'eaccess.c'"
else
sed 's/^X//' << \SHAR_EOF > 'eaccess.c'
X/*
X * eaccess(C) command -- sample usage of cxenix() system call
X */
X/*
X * @begin{boilerplate}
X * Copyright 1991 Ronald Khoo <ronald@ibmpcug.co.uk>
X * This is Really Free Software.
X * Permission granted to use this software for any purpose provided that
X * the author be held free from any blame for anything that may occur as a
X * result of this software being used; that this notice be preserved in all
X * copies of this software and derived works, and the documentation therof;
X * and that any modifications be clearly marked as such.
X * @end{boilerplate}
X */
X
X#define CXENIX_eaccess 37 /* from dumpsys's output */
X
X#include <stdio.h>
X#include <unistd.h>
X#include <errno.h>
X#include <string.h>
X
Xmain(argc, argv)
X char **argv;
X{
X char *errstr;
X int mode;
X
X if (argc != 3)
X usage();
X
X switch(argv[2][0]) {
X case 'R': case 'r': mode = R_OK; break;
X case 'W': case 'w': mode = W_OK; break;
X case 'X': case 'x': mode = X_OK; break;
X case 'F': case 'f': mode = F_OK; break;
X default: usage();
X }
X if (cxenix(CXENIX_eaccess, argv[1], mode) < 0)
X errstr = strerror(errno);
X else
X errstr = "OK";
X
X printf("%s: %s\n", argv[1], errstr);
X}
X
Xusage()
X{
X fprintf(stderr, "usage: eaccess file R | W | X | F\n");
X exit(1);
X}
SHAR_EOF
if test 1215 -ne "`wc -c < 'eaccess.c'`"
then
echo shar: error transmitting "'eaccess.c'" '(should have been 1215 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'sizes.sh'" '(876 characters)'
if test -f 'sizes.sh'
then
echo shar: will not over-write existing file "'sizes.sh'"
else
sed 's/^X//' << \SHAR_EOF > 'sizes.sh'
X# /*
X# * @begin{boilerplate}
X# * Copyright 1991 Ronald Khoo <ronald@ibmpcug.co.uk>
X# * This is Really Free Software.
X# * Permission granted to use this software for any purpose provided that
X# * the author be held free from any blame for anything that may occur as a
X# * result of this software being used; that this notice be preserved in all
X# * copies of this software and derived works, and the documentation therof;
X# * and that any modifications be clearly marked as such.
X# * @end{boilerplate}
X# */
Xwhile read addr symbol
Xdo
X test "$endsym" && eval "$endsym=$addr"
X case "$symbol" in
X *ent*) endsym=end$symbol
X eval "begin$symbol=$addr"
X syms="$syms $symbol"
X ;;
X *) endsym=
X ;;
X esac
Xdone
X
Xfor i in $syms
Xdo
X eval "end=\$end$i"
X eval "begin=\$begin$i"
X size="`echo 16i $end $begin -p | tr '[a-f]' '[A-F]' | dc`"
X echo "#define SIZE_$i\t$size"
Xdone
SHAR_EOF
if test 876 -ne "`wc -c < 'sizes.sh'`"
then
echo shar: error transmitting "'sizes.sh'" '(should have been 876 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'syscall.S'" '(1053 characters)'
if test -f 'syscall.S'
then
echo shar: will not over-write existing file "'syscall.S'"
else
sed 's/^X//' << \SHAR_EOF > 'syscall.S'
X/ /*
X/ * @begin{boilerplate}
X/ * Copyright 1991 Ronald Khoo <ronald@ibmpcug.co.uk>
X/ * This is Really Free Software.
X/ * Permission granted to use this software for any purpose provided that
X/ * the author be held free from any blame for anything that may occur as a
X/ * result of this software being used; that this notice be preserved in all
X/ * copies of this software and derived works, and the documentation therof;
X/ * and that any modifications be clearly marked as such.
X/ * @end{boilerplate}
X/ */
X .file "syscall.s"
X .globl _cxenix
X .globl _syscall
X .globl _errno
X .align 2
X_syscall:
X popl %edx
X popl %eax
X pushl %edx
X / call far 0x7:0x0
X .byte 0x9a,0,0,0,0,7,0
X jb .L1
X popl %edx
X pushl %edx
X pushl %edx
X ret
X.L1: movl %eax,_errno
X movl $-1,%eax
X popl %edx
X pushl %edx
X pushl %edx
X ret
X_cxenix:
X popl %edx
X popl %eax
X pushl %edx
X sall $8,%eax
X leal 40(%eax),%eax
X / call far 0x7:0x0
X .byte 0x9a,0,0,0,0,7,0
X jb .L2
X popl %edx
X pushl %edx
X pushl %edx
X ret
X.L2: movl %eax,_errno
X movl $-1,%eax
X popl %edx
X pushl %edx
X pushl %edx
X ret
SHAR_EOF
if test 1053 -ne "`wc -c < 'syscall.S'`"
then
echo shar: error transmitting "'syscall.S'" '(should have been 1053 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
--
Ronald Khoo <ronald@robobar.co.uk> +44 81 991 1142 (O) +44 71 229 7741 (H)