Disabled building rescue driver (no longer needed). Moved allocmem from

library to the memory driver. Always put output from within TTY directly on
the console. Removed second include of driver.h from tty.c. Made tty_inrepcode
bigger. First step to move PM and FS calls that are not regular (API)
system calls out of callnr.h (renumbered them, and removed them from the
table.c files). Imported the Minix-vmd uname implementation. This provides
a more stable ABI than the current implementation. Added a bit of security
checking. Unfortunately not nearly enough to get a secure system. Fixed a
bug related to the sizes of the programs in the image (in PM patch_mem_chunks).
This commit is contained in:
Philip Homburg
2006-05-19 12:19:37 +00:00
parent c3cf4ef460
commit e9aabcf2f8
27 changed files with 425 additions and 153 deletions

View File

@@ -5,11 +5,9 @@ CFLAGS="-O -D_MINIX -D_POSIX_SOURCE -I../../servers"
LIBRARIES=libc
libc_FILES=" \
_allocmem.c \
_brk.c \
_devctl.c \
__pm_findproc.c \
_freemem.c \
_getnpid.c \
_getsigset.c \
_getnprocnr.c \
@@ -18,6 +16,7 @@ libc_FILES=" \
_getsysinfo.c \
_reboot.c \
_seekdir.c \
_sysuname.c \
_svrctl.c \
asynchio.c \
basename.c \

26
lib/other/_sysuname.c Normal file
View File

@@ -0,0 +1,26 @@
/* sysuname(2) - transfer uname(3) strings. Author: Kees J. Bot
* 5 Dec 1992
*/
#define sysuname _sysuname
#include <lib.h>
int sysuname(int req, int field, char *value, size_t len)
{
message m;
m.m1_i1 = req;
m.m1_i2 = field;
m.m1_i3 = len;
m.m1_p1 = value;
/* Clear unused fields */
m.m1_p2 = NULL;
m.m1_p3 = NULL;
return _syscall(MM, SYSUNAME, &m);
}
/*
* $PchId: _sysuname.c,v 1.4 1995/11/27 19:42:09 philip Exp $
*/

View File

@@ -1,59 +1,62 @@
/* uname() - get system info Author: Kees J. Bot
* 7 Nov 1994
* Returns information about the Minix system. Alas most
* of it is gathered at compile time, so machine is wrong, and
* release and version become wrong if not recompiled.
* More chip types and Minix versions need to be added.
/* uname(3) - describe the machine. Author: Kees J. Bot
* 5 Dec 1992
*/
#define uname _uname
#define open _open
#define read _read
#define close _close
#define uname _uname
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <minix/config.h>
#include <minix/com.h>
#include <minix/minlib.h>
int uname(name) struct utsname *name;
#define uts_get(field, string) \
if (sysuname(_UTS_GET, field, name->string, sizeof(name->string)) < 0) \
return -1; \
name->string[sizeof(name->string)-1]= 0;
int uname(name)
struct utsname *name;
{
int hf, n, err;
struct kinfo kinfo;
char *nl;
int hf, n, err;
char *nl;
/* Read the node name from /etc/hostname.file. */
if ((hf = open("/etc/hostname.file", O_RDONLY)) < 0) {
if (errno != ENOENT) return(-1);
strcpy(name->nodename, "noname");
} else {
n = read(hf, name->nodename, sizeof(name->nodename) - 1);
err = errno;
close(hf);
errno = err;
if (n < 0) return(-1);
name->nodename[n] = 0;
if ((nl = strchr(name->nodename, '\n')) != NULL) {
memset(nl, 0, (name->nodename + sizeof(name->nodename)) - nl);
/* Get each of the strings with a sysuname call. Null terminate them,
* because the buffers in the kernel may grow before this and the
* programs are recompiled.
*/
uts_get(_UTS_SYSNAME, sysname);
uts_get(_UTS_NODENAME, nodename);
uts_get(_UTS_RELEASE, release);
uts_get(_UTS_VERSION, version);
uts_get(_UTS_MACHINE, machine);
uts_get(_UTS_ARCH, arch);
#if 0
uts_get(_UTS_KERNEL, kernel);
uts_get(_UTS_HOSTNAME, hostname);
uts_get(_UTS_BUS, bus);
#endif
/* Try to read the node name from /etc/hostname.file. This information
* should be stored in the kernel.
*/
if ((hf = open("/etc/hostname.file", O_RDONLY)) < 0) {
if (errno != ENOENT) return(-1);
} else {
n = read(hf, name->nodename, sizeof(name->nodename) - 1);
err = errno;
close(hf);
errno = err;
if (n < 0) return(-1);
name->nodename[n] = 0;
if ((nl = strchr(name->nodename, '\n')) != NULL) {
memset(nl, 0, (name->nodename +
sizeof(name->nodename)) - nl);
}
}
}
getsysinfo(PM_PROC_NR, SI_KINFO, &kinfo);
strcpy(name->sysname, "Minix");
strcpy(name->release, kinfo.release);
strcpy(name->version, kinfo.version);
#if (CHIP == INTEL)
name->machine[0] = 'i';
strcpy(name->machine + 1, itoa(getprocessor()));
#if _WORD_SIZE == 4
strcpy(name->arch, "i386");
#else
strcpy(name->arch, "i86");
#endif
#endif
return(0);
return 0;
}
/*
* $PchId: _uname.c,v 1.4 1995/11/27 20:09:08 philip Exp $
*/

View File

@@ -7,7 +7,6 @@ libc_FILES=" \
_pm_findproc.s \
access.s \
alarm.s \
allocmem.s \
brk.s \
cfgetispeed.s \
cfgetospeed.s \
@@ -34,7 +33,6 @@ libc_FILES=" \
fcntl.s \
fork.s \
fpathconf.s \
freemem.s \
fstat.s \
fstatfs.s \
getcwd.s \
@@ -96,6 +94,7 @@ libc_FILES=" \
svrctl.s \
symlink.s \
sync.s \
sysuname.s \
tcdrain.s \
tcflow.s \
tcflush.s \

7
lib/syscall/sysuname.s Normal file
View File

@@ -0,0 +1,7 @@
.sect .text
.extern __sysuname
.define _sysuname
.align 2
_sysuname:
jmp __sysuname