more pid queries; PM field macros; vm stubs

This commit is contained in:
Ben Gras 2009-09-21 14:44:00 +00:00
parent 348978e64a
commit b2adf0c1ae
7 changed files with 64 additions and 2 deletions

View file

@ -14,6 +14,8 @@ libc_FILES=" \
_getdents.c \
_getdma.c \
_getnpid.c \
_getnuid.c \
_getngid.c \
_getnprocnr.c \
_getpprocnr.c \
_getprocnr.c \
@ -29,6 +31,8 @@ libc_FILES=" \
_svrctl.c \
_sysuname.c \
_vm_dmacalls.c \
_vm_set_priv.c \
_vm_query_exit.c \
asynchio.c \
basename.c \
bcmp.c \
@ -62,6 +66,7 @@ libc_FILES=" \
lrand.c \
lsearch.c \
memccpy.c \
minix_rs.c \
mstats.c \
mtab.c \
nlist.c \

View file

@ -20,7 +20,7 @@ char *addr;
message m;
if (addr != _brksize) {
m.m1_p1 = addr;
m.PMBRK_ADDR = addr;
if (_syscall(MM, BRK, &m) < 0) return(-1);
_brksize = m.m2_p1;
}

11
lib/other/_getngid.c Normal file
View file

@ -0,0 +1,11 @@
#include <lib.h>
#define getngid _getngid
#include <unistd.h>
PUBLIC gid_t getngid(int proc_nr)
{
message m;
m.m1_i1 = proc_nr; /* search gid for this process */
if (_syscall(MM, GETGID, &m) < 0) return ( (gid_t) -1);
return( (gid_t) m.m2_i2); /* return search result */
}

View file

@ -6,6 +6,6 @@ PUBLIC pid_t getnpid(int proc_nr)
{
message m;
m.m1_i1 = proc_nr; /* search pid for this process */
if (_syscall(MM, GETPID, &m) < 0) return ( (pid_t) -1);
if (_syscall(MM, MINIX_GETPID, &m) < 0) return ( (pid_t) -1);
return( (pid_t) m.m2_i2); /* return search result */
}

11
lib/other/_getnuid.c Normal file
View file

@ -0,0 +1,11 @@
#include <lib.h>
#define getnuid _getnuid
#include <unistd.h>
PUBLIC uid_t getnuid(int proc_nr)
{
message m;
m.m1_i1 = proc_nr; /* search uid for this process */
if (_syscall(MM, GETUID, &m) < 0) return ( (uid_t) -1);
return( (uid_t) m.m2_i2); /* return search result */
}

View file

@ -0,0 +1,24 @@
#define _SYSTEM 1
#include <lib.h>
#define vm_query_exit _vm_query_exit
#include <unistd.h>
/* return -1, when the query itself or the processing of query has errors.
* return 1, when there are more processes waiting to be queried.
* return 0, when there are no more processes.
* note that for the return value of 0 and 1, the 'endpt' is set accordingly.
*/
PUBLIC int vm_query_exit(int *endpt)
{
message m;
int r;
r = _syscall(VM_PROC_NR, VM_QUERY_EXIT, &m);
if (r != OK)
return -1;
if (endpt == NULL)
return -1;
*endpt = m.VM_QUERY_RET_PT;
return (m.VM_QUERY_IS_MORE ? 1 : 0);
}

11
lib/other/_vm_set_priv.c Normal file
View file

@ -0,0 +1,11 @@
#include <lib.h>
#define vm_set_priv _vm_set_priv
#include <unistd.h>
PUBLIC int vm_set_priv(int nr, void *buf)
{
message m;
m.VM_RS_NR = nr;
m.VM_RS_BUF = (long) buf;
return _syscall(VM_PROC_NR, VM_RS_SET_PRIV, &m);
}