libsys: various updates
- move system calls for use by services from libminlib into libsys; - move srv_fork(2) and srv_kill(2) from RS and into libsys; - replace getprocnr(2) with sef_self(3); - rename previous getnprocnr(2) to getprocnr(2); - clean up getepinfo(2); - change all libsys calls that used _syscall to use _taskcall, so as to avoid going through errno to pass errors; this is already how most calls work anyway, and many of the calls previously using _syscall were already assumed to return the actual error; - initialize request messages to zero, for future compatibility (note that this does not include PCI calls, which are in need of a much bigger overhaul, nor kernel calls); - clean up more of dead DS code as a side effect. Change-Id: I8788f54c68598fcf58e23486e270c2d749780ebb
This commit is contained in:
parent
efd3487bc5
commit
80bd109cd3
82 changed files with 477 additions and 544 deletions
|
@ -166,9 +166,9 @@ do_connect(devminor_t minor, endpoint_t endpt, cp_grant_id_t grant)
|
|||
sizeof(struct sockaddr_un))) != OK)
|
||||
return rc;
|
||||
|
||||
if (checkperms(uds_fd_table[minor].owner, addr.sun_path,
|
||||
UNIX_PATH_MAX) != OK)
|
||||
return -errno;
|
||||
if ((rc = checkperms(uds_fd_table[minor].owner, addr.sun_path,
|
||||
UNIX_PATH_MAX)) != OK)
|
||||
return rc;
|
||||
|
||||
/*
|
||||
* Look for a socket of the same type that is listening on the
|
||||
|
@ -355,9 +355,9 @@ do_bind(devminor_t minor, endpoint_t endpt, cp_grant_id_t grant)
|
|||
if (addr.sun_path[0] == '\0')
|
||||
return ENOENT;
|
||||
|
||||
if (checkperms(uds_fd_table[minor].owner, addr.sun_path,
|
||||
UNIX_PATH_MAX) != OK)
|
||||
return -errno;
|
||||
if ((rc = checkperms(uds_fd_table[minor].owner, addr.sun_path,
|
||||
UNIX_PATH_MAX)) != OK)
|
||||
return rc;
|
||||
|
||||
/* Make sure the address isn't already in use by another socket. */
|
||||
for (i = 0; i < NR_FDS; i++) {
|
||||
|
@ -523,7 +523,7 @@ do_getsockopt_peercred(devminor_t minor, endpoint_t endpt, cp_grant_id_t grant)
|
|||
|
||||
/* Obtain the peer's credentials and copy them out. */
|
||||
if ((rc = getnucred(uds_fd_table[peer_minor].owner, &cred)) < 0)
|
||||
return -errno;
|
||||
return rc;
|
||||
|
||||
return sys_safecopyto(endpt, grant, 0, (vir_bytes) &cred,
|
||||
sizeof(struct uucred));
|
||||
|
@ -611,9 +611,9 @@ do_sendto(devminor_t minor, endpoint_t endpt, cp_grant_id_t grant)
|
|||
if (addr.sun_family != AF_UNIX || addr.sun_path[0] == '\0')
|
||||
return EINVAL;
|
||||
|
||||
if (checkperms(uds_fd_table[minor].owner, addr.sun_path,
|
||||
UNIX_PATH_MAX) != OK)
|
||||
return -errno;
|
||||
if ((rc = checkperms(uds_fd_table[minor].owner, addr.sun_path,
|
||||
UNIX_PATH_MAX)) != OK)
|
||||
return rc;
|
||||
|
||||
memcpy(&uds_fd_table[minor].target, &addr, sizeof(struct sockaddr_un));
|
||||
|
||||
|
@ -645,7 +645,7 @@ send_fds(devminor_t minor, struct msg_control *msg_ctrl,
|
|||
|
||||
/* Obtain this socket's credentials. */
|
||||
if ((rc = getnucred(from_ep, &data->cred)) < 0)
|
||||
return -errno;
|
||||
return rc;
|
||||
|
||||
dprintf(("UDS: minor=%d cred={%d,%d,%d}\n", minor, data->cred.pid,
|
||||
data->cred.uid, data->cred.gid));
|
||||
|
@ -677,8 +677,6 @@ send_fds(devminor_t minor, struct msg_control *msg_ctrl,
|
|||
|
||||
for (i = data->nfiledes; i < totalfds; i++) {
|
||||
if ((rc = copyfd(from_ep, data->fds[i], COPYFD_FROM)) < 0) {
|
||||
rc = -errno;
|
||||
|
||||
printf("UDS: copyfd(COPYFD_FROM) failed: %d\n", rc);
|
||||
|
||||
/* Revert the successful copyfd() calls made so far. */
|
||||
|
@ -747,8 +745,6 @@ recv_fds(devminor_t minor, struct ancillary *data,
|
|||
/* Copy to the target endpoint. */
|
||||
for (i = 0; i < data->nfiledes; i++) {
|
||||
if ((rc = copyfd(to_ep, data->fds[i], COPYFD_TO)) < 0) {
|
||||
rc = -errno;
|
||||
|
||||
printf("UDS: copyfd(COPYFD_TO) failed: %d\n", rc);
|
||||
|
||||
/* Revert the successful copyfd() calls made so far. */
|
||||
|
|
|
@ -384,9 +384,10 @@ vnd_ioctl(devminor_t UNUSED(minor), unsigned long request, endpoint_t endpt,
|
|||
* making the IOCTL call. The result is either a newly
|
||||
* allocated file descriptor or an error.
|
||||
*/
|
||||
if ((state.fd = copyfd(user_endpt, vnd.vnd_fildes,
|
||||
COPYFD_FROM)) == -1)
|
||||
return -errno;
|
||||
if ((r = copyfd(user_endpt, vnd.vnd_fildes, COPYFD_FROM)) < 0)
|
||||
return r;
|
||||
|
||||
state.fd = r;
|
||||
|
||||
/* The target file must be regular. */
|
||||
if (fstat(state.fd, &st) == -1) {
|
||||
|
|
|
@ -36,16 +36,6 @@ void _loadname(const char *_name, message *_msgptr);
|
|||
int _len(const char *_s);
|
||||
void _begsig(int _dummy);
|
||||
|
||||
int getprocnr(void);
|
||||
int getnprocnr(pid_t pid);
|
||||
int getpprocnr(void);
|
||||
int _pm_findproc(char *proc_name, int *proc_nr);
|
||||
int mapdriver(char *label, int major);
|
||||
pid_t getnpid(endpoint_t proc_ep);
|
||||
uid_t getnuid(endpoint_t proc_ep);
|
||||
gid_t getngid(endpoint_t proc_ep);
|
||||
int checkperms(endpoint_t endpt, char *path, size_t size);
|
||||
int copyfd(endpoint_t endpt, int fd, int what);
|
||||
ssize_t pread64(int fd, void *buf, size_t count, u64_t where);
|
||||
ssize_t pwrite64(int fd, const void *buf, size_t count, u64_t where);
|
||||
|
||||
|
|
|
@ -91,7 +91,6 @@
|
|||
#define EXEC_RESTART 102 /* to PM: final part of exec for RS */
|
||||
#define GETPROCNR 104 /* to PM */
|
||||
#define ISSETUGID 106 /* to PM: ask if process is tainted */
|
||||
#define GETEPINFO_O 107 /* to PM: get pid/uid/gid of an endpoint */
|
||||
#define UTIMENS 108 /* to FS: [f]utimens(); also [fl]utimes */
|
||||
#define FCNTL 109 /* to VFS */
|
||||
#define TRUNCATE 110 /* to VFS */
|
||||
|
|
|
@ -895,6 +895,20 @@
|
|||
# define COPYFD_TO 1 /* copy file descriptor to remote process */
|
||||
# define COPYFD_CLOSE 2 /* close file descriptor in remote process */
|
||||
|
||||
/* Field names for the getprocnr(2) call. */
|
||||
#define PM_GETPROCNR_PID m1_i1
|
||||
#define PM_GETPROCNR_ENDPT m1_i1
|
||||
|
||||
/* Field names for the getepinfo(2) call. */
|
||||
#define PM_GETEPINFO_ENDPT m1_i1
|
||||
#define PM_GETEPINFO_UID m1_i1
|
||||
#define PM_GETEPINFO_GID m1_i2
|
||||
|
||||
/* Field names for the mapdriver(2) call. */
|
||||
#define VFS_MAPDRIVER_MAJOR m1_i1
|
||||
#define VFS_MAPDRIVER_LABELLEN m1_i2
|
||||
#define VFS_MAPDRIVER_LABEL m1_p1
|
||||
|
||||
/* Field names for GETRUSAGE related calls */
|
||||
#define RU_ENDPT m1_i1 /* indicates a process for sys_getrusage */
|
||||
#define RU_WHO m1_i1 /* who argument in getrusage call */
|
||||
|
|
|
@ -23,9 +23,6 @@
|
|||
#define DSF_OVERWRITE 0x01000 /* overwrite if entry exists */
|
||||
#define DSF_INITIAL 0x02000 /* check subscriptions immediately */
|
||||
|
||||
#define DSMF_COPY_MAPPED 0x20000 /* copy mapped memory range */
|
||||
#define DSMF_COPY_SNAPSHOT 0x40000 /* copy snapshot */
|
||||
|
||||
/* DS constants. */
|
||||
#define DS_MAX_KEYLEN 80 /* Max length of a key, including '\0'. */
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
/* SEF entry points for system processes. */
|
||||
void sef_startup(void);
|
||||
int sef_receive_status(endpoint_t src, message *m_ptr, int *status_ptr);
|
||||
endpoint_t sef_self(void);
|
||||
void sef_cancel(void);
|
||||
void sef_exit(int status);
|
||||
#define sef_receive(src, m_ptr) sef_receive_status(src, m_ptr, NULL)
|
||||
|
|
|
@ -26,7 +26,6 @@ struct rusage;
|
|||
*==========================================================================*/
|
||||
int _taskcall(endpoint_t who, int syscallnr, message *msgptr);
|
||||
int _kernel_call(int syscallnr, message *msgptr);
|
||||
int _sendcall(endpoint_t who, int type, message *msgptr);
|
||||
|
||||
int sys_abort(int how);
|
||||
int sys_enable_iop(endpoint_t proc_ep);
|
||||
|
@ -261,5 +260,16 @@ int sys_setmcontext(endpoint_t proc, mcontext_t *mcp);
|
|||
/* input */
|
||||
int tty_input_inject(int type, int code, int val);
|
||||
|
||||
/* Miscellaneous calls from servers and drivers. */
|
||||
pid_t srv_fork(uid_t reuid, gid_t regid);
|
||||
int srv_kill(pid_t pid, int sig);
|
||||
int getprocnr(pid_t pid, endpoint_t *proc_ep);
|
||||
int mapdriver(char *label, devmajor_t major);
|
||||
pid_t getnpid(endpoint_t proc_ep);
|
||||
uid_t getnuid(endpoint_t proc_ep);
|
||||
gid_t getngid(endpoint_t proc_ep);
|
||||
int checkperms(endpoint_t endpt, char *path, size_t size);
|
||||
int copyfd(endpoint_t endpt, int fd, int what);
|
||||
|
||||
#endif /* _SYSLIB_H */
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ set -e
|
|||
find_files_and_lines()
|
||||
(
|
||||
find ../lib/libc/sys-minix ../lib/libsys -name '*.c' | \
|
||||
xargs egrep -n '((_sendcall|_syscall|_taskcall)\([^,][^,]*,[ ]*|_kernel_call\()[A-Z_][A-Z0-9_]*,[ ]*&m\)' | \
|
||||
xargs egrep -n '((_syscall|_taskcall)\([^,][^,]*,[ ]*|_kernel_call\()[A-Z_][A-Z0-9_]*,[ ]*&m\)' | \
|
||||
cut -d: -f1,2
|
||||
)
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ void blockdriver_announce(int type)
|
|||
}
|
||||
|
||||
/* Publish a driver up event. */
|
||||
if ((r = ds_retrieve_label_name(label, getprocnr())) != OK)
|
||||
if ((r = ds_retrieve_label_name(label, sef_self())) != OK)
|
||||
panic("blockdriver_init: unable to get own label: %d", r);
|
||||
|
||||
snprintf(key, DS_MAX_KEYLEN, "%s%s", driver_prefix, label);
|
||||
|
|
|
@ -110,7 +110,7 @@ void chardriver_announce(void)
|
|||
panic("chardriver_announce: sys_statectl failed: %d", r);
|
||||
|
||||
/* Publish a driver up event. */
|
||||
if ((r = ds_retrieve_label_name(label, getprocnr())) != OK)
|
||||
if ((r = ds_retrieve_label_name(label, sef_self())) != OK)
|
||||
panic("chardriver_announce: unable to get own label: %d", r);
|
||||
|
||||
snprintf(key, DS_MAX_KEYLEN, "%s%s", driver_prefix, label);
|
||||
|
|
|
@ -26,7 +26,7 @@ i2cdriver_announce(uint32_t bus)
|
|||
}
|
||||
|
||||
/* Publish a driver up event. */
|
||||
r = ds_retrieve_label_name(label, getprocnr());
|
||||
r = ds_retrieve_label_name(label, sef_self());
|
||||
if (r != OK) {
|
||||
panic("unable to get own label: %d\n", r);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ inputdriver_announce(unsigned int type)
|
|||
int r;
|
||||
|
||||
/* Publish a driver up event. */
|
||||
if ((r = ds_retrieve_label_name(label, getprocnr())) != OK)
|
||||
if ((r = ds_retrieve_label_name(label, sef_self())) != OK)
|
||||
panic("libinputdriver: unable to retrieve own label: %d", r);
|
||||
|
||||
snprintf(key, sizeof(key), "%s%s", driver_prefix, label);
|
||||
|
|
|
@ -30,11 +30,6 @@ SRCS+= servxcheck.c
|
|||
# queryparam
|
||||
SRCS+= paramvalue.c
|
||||
|
||||
# Minix servers/drivers syscall. FIXME: these should be moved into libsys.
|
||||
SRCS+= checkperms.c copyfd.c getngid.c getnpid.c getnprocnr.c getnucred.c \
|
||||
getnuid.c getprocnr.c mapdriver.c vm_memctl.c vm_set_priv.c \
|
||||
vm_query_exit.c vm_update.c
|
||||
|
||||
SRCS+= oneC_sum.c
|
||||
|
||||
SUBDIR+= pkgconfig
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
#include <lib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
gid_t getngid(endpoint_t proc_ep)
|
||||
{
|
||||
message m;
|
||||
m.m1_i1 = proc_ep; /* search gid for this process */
|
||||
if (_syscall(PM_PROC_NR, GETEPINFO, &m) < 0) return ( (gid_t) -1);
|
||||
return( (gid_t) m.m2_i2); /* return search result */
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
#include <lib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
pid_t getnpid(endpoint_t proc_ep)
|
||||
{
|
||||
message m;
|
||||
m.m1_i1 = proc_ep; /* search pid for this process */
|
||||
return _syscall(PM_PROC_NR, GETEPINFO, &m);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
#include <lib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
int getnprocnr(pid_t pid)
|
||||
{
|
||||
message m;
|
||||
int t = GETPROCNR;
|
||||
m.m1_i1 = pid; /* pass pid >=0 to search for */
|
||||
m.m1_i2 = 0; /* don't pass name to search for */
|
||||
if (_syscall(PM_PROC_NR, t, &m) < 0) return(-1);
|
||||
return(m.m1_i1); /* return search result */
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
#include <errno.h>
|
||||
#include <lib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/ucred.h>
|
||||
|
||||
int
|
||||
getnucred(endpoint_t proc_ep, struct uucred *ucred)
|
||||
{
|
||||
message m;
|
||||
pid_t pid;
|
||||
|
||||
if (ucred == NULL) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
m.m1_i1 = proc_ep; /* search for this process */
|
||||
|
||||
pid = _syscall(PM_PROC_NR, GETEPINFO, &m);
|
||||
if (pid < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Only two fields are used for now, so ensure the rest is zeroed out. */
|
||||
memset(ucred, 0, sizeof(struct uucred));
|
||||
ucred->cr_uid = m.PM_NUID;
|
||||
ucred->cr_gid = m.PM_NGID;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
#include <lib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
uid_t getnuid(endpoint_t proc_ep)
|
||||
{
|
||||
message m;
|
||||
m.m1_i1 = proc_ep; /* search uid for this process */
|
||||
if (_syscall(PM_PROC_NR, GETEPINFO, &m) < 0) return ( (uid_t) -1);
|
||||
return( (uid_t) m.m2_i1); /* return search result */
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
#include <lib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
int getprocnr()
|
||||
{
|
||||
message m;
|
||||
m.m1_i1 = -1; /* don't pass pid to search for */
|
||||
m.m1_i2 = 0; /* don't pass name to search for */
|
||||
if (_syscall(PM_PROC_NR, GETPROCNR, &m) < 0) return(-1);
|
||||
return(m.m1_i1); /* return own process number */
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#include <lib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
int mapdriver(label, major)
|
||||
char *label;
|
||||
int major;
|
||||
{
|
||||
message m;
|
||||
m.m2_p1 = label;
|
||||
m.m2_l1 = strlen(label);
|
||||
m.m2_i1 = major;
|
||||
if (_syscall(VFS_PROC_NR, MAPDRIVER, &m) < 0) return(-1);
|
||||
return(0);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#include <lib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int vm_memctl(endpoint_t ep, int req)
|
||||
{
|
||||
message m;
|
||||
m.VM_RS_CTL_ENDPT = ep;
|
||||
m.VM_RS_CTL_REQ = req;
|
||||
|
||||
return _syscall(VM_PROC_NR, VM_RS_MEMCTL, &m);
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
#define _SYSTEM 1
|
||||
#include <lib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.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.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
int vm_watch_exit(endpoint_t ep)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VM_WE_EP = ep;
|
||||
return _syscall(VM_PROC_NR, VM_WATCH_EXIT, &m);
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
#include <lib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int vm_set_priv(endpoint_t ep, void *buf, int sys_proc)
|
||||
{
|
||||
message m;
|
||||
m.VM_RS_NR = ep;
|
||||
m.VM_RS_BUF = (long) buf;
|
||||
m.VM_RS_SYS = sys_proc;
|
||||
return _syscall(VM_PROC_NR, VM_RS_SET_PRIV, &m);
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#include <lib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int vm_update(endpoint_t src_e, endpoint_t dst_e)
|
||||
{
|
||||
message m;
|
||||
m.VM_RS_SRC_ENDPT = src_e;
|
||||
m.VM_RS_DST_ENDPT = dst_e;
|
||||
|
||||
return _syscall(VM_PROC_NR, VM_RS_UPDATE, &m);
|
||||
}
|
|
@ -28,7 +28,7 @@ void netdriver_announce()
|
|||
char *driver_prefix = "drv.net.";
|
||||
|
||||
/* Publish a driver up event. */
|
||||
r = ds_retrieve_label_name(label, getprocnr());
|
||||
r = ds_retrieve_label_name(label, sef_self());
|
||||
if (r != OK) {
|
||||
panic("driver_announce: unable to get own label: %d\n", r);
|
||||
}
|
||||
|
|
|
@ -43,8 +43,6 @@ EXTERN gid_t caller_gid;
|
|||
|
||||
EXTERN int req_nr;
|
||||
|
||||
EXTERN endpoint_t SELF_E;
|
||||
|
||||
EXTERN char user_path[PATH_MAX+1]; /* pathname to be processed */
|
||||
|
||||
EXTERN dev_t fs_dev; /* The device that is handled by this FS proc
|
||||
|
|
|
@ -694,7 +694,6 @@ static void sef_local_startup()
|
|||
static int sef_cb_init_fresh(int type, sef_init_info_t *info)
|
||||
{
|
||||
/* Initialize the Minix file server. */
|
||||
SELF_E = getprocnr();
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
@ -769,7 +768,7 @@ static void reply(
|
|||
)
|
||||
{
|
||||
if (OK != send(who, m_out)) /* send the message */
|
||||
lpuffs_debug("libpuffs(%d) was unable to send reply\n", SELF_E);
|
||||
lpuffs_debug("libpuffs(%d) was unable to send reply\n", sef_self());
|
||||
|
||||
last_request_transid = 0;
|
||||
}
|
||||
|
|
|
@ -9,12 +9,16 @@ SRCS+= \
|
|||
alloc_util.c \
|
||||
assert.c \
|
||||
asynsend.c \
|
||||
checkperms.c \
|
||||
copyfd.c \
|
||||
ds.c \
|
||||
env_get_prm.c \
|
||||
env_panic.c \
|
||||
env_parse.c \
|
||||
env_prefix.c \
|
||||
fkey_ctl.c \
|
||||
getepinfo.c \
|
||||
getprocnr.c \
|
||||
getticks.c \
|
||||
getsysinfo.c \
|
||||
getuptime.c \
|
||||
|
@ -22,6 +26,7 @@ SRCS+= \
|
|||
kprintf.c \
|
||||
kputc.c \
|
||||
kputs.c \
|
||||
mapdriver.c \
|
||||
optset.c \
|
||||
panic.c \
|
||||
safecopies.c \
|
||||
|
@ -33,6 +38,8 @@ SRCS+= \
|
|||
sef_ping.c \
|
||||
sef_signal.c \
|
||||
sqrt_approx.c \
|
||||
srv_fork.c \
|
||||
srv_kill.c \
|
||||
stacktrace.c \
|
||||
sys_abort.c \
|
||||
sys_clear.c \
|
||||
|
@ -84,9 +91,13 @@ SRCS+= \
|
|||
vm_fork.c \
|
||||
vm_info.c \
|
||||
vm_map_phys.c \
|
||||
vm_memctl.c \
|
||||
vm_notify_sig.c \
|
||||
vm_umap.c \
|
||||
vm_procctl.c \
|
||||
vm_query_exit.c \
|
||||
vm_set_priv.c \
|
||||
vm_update.c \
|
||||
vprintf.c
|
||||
|
||||
.if ${MKPCI} != "no"
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <lib.h>
|
||||
#include "syslib.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <minix/safecopies.h>
|
||||
|
@ -12,16 +13,16 @@ checkperms(endpoint_t endpt, char *path, size_t size)
|
|||
|
||||
if ((grant = cpf_grant_direct(VFS_PROC_NR, (vir_bytes) path, size,
|
||||
CPF_READ | CPF_WRITE)) == GRANT_INVALID)
|
||||
return -1; /* called function sets errno */
|
||||
return ENOMEM;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VFS_CHECKPERMS_ENDPT = endpt;
|
||||
m.VFS_CHECKPERMS_GRANT = grant;
|
||||
m.VFS_CHECKPERMS_COUNT = size;
|
||||
|
||||
r = _syscall(VFS_PROC_NR, VFS_CHECKPERMS, &m);
|
||||
r = _taskcall(VFS_PROC_NR, VFS_CHECKPERMS, &m);
|
||||
|
||||
cpf_revoke(grant); /* does not touch errno */
|
||||
cpf_revoke(grant);
|
||||
|
||||
return r;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#include <lib.h>
|
||||
#include "syslib.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
|
@ -11,5 +12,5 @@ copyfd(endpoint_t endpt, int fd, int what)
|
|||
m.VFS_COPYFD_FD = fd;
|
||||
m.VFS_COPYFD_WHAT = what;
|
||||
|
||||
return _syscall(VFS_PROC_NR, COPYFD, &m);
|
||||
return _taskcall(VFS_PROC_NR, COPYFD, &m);
|
||||
}
|
|
@ -4,9 +4,7 @@
|
|||
|
||||
#include "syslib.h"
|
||||
|
||||
static message m;
|
||||
|
||||
static int do_invoke_ds(int type, const char *ds_name)
|
||||
static int do_invoke_ds(message *m, int type, const char *ds_name)
|
||||
{
|
||||
cp_grant_id_t g_key;
|
||||
size_t len_key;
|
||||
|
@ -24,12 +22,12 @@ static int do_invoke_ds(int type, const char *ds_name)
|
|||
g_key = cpf_grant_direct(DS_PROC_NR, (vir_bytes) ds_name,
|
||||
len_key, access);
|
||||
if(!GRANT_VALID(g_key))
|
||||
return errno;
|
||||
return ENOMEM;
|
||||
|
||||
m.DS_KEY_GRANT = g_key;
|
||||
m.DS_KEY_LEN = len_key;
|
||||
m->DS_KEY_GRANT = g_key;
|
||||
m->DS_KEY_LEN = len_key;
|
||||
|
||||
r = _taskcall(DS_PROC_NR, type, &m);
|
||||
r = _taskcall(DS_PROC_NR, type, m);
|
||||
|
||||
cpf_revoke(g_key);
|
||||
return r;
|
||||
|
@ -37,34 +35,42 @@ static int do_invoke_ds(int type, const char *ds_name)
|
|||
|
||||
int ds_publish_label(const char *ds_name, endpoint_t endpoint, int flags)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_VAL = (u32_t) endpoint;
|
||||
m.DS_FLAGS = DSF_TYPE_LABEL | flags;
|
||||
return do_invoke_ds(DS_PUBLISH, ds_name);
|
||||
return do_invoke_ds(&m, DS_PUBLISH, ds_name);
|
||||
}
|
||||
|
||||
int ds_publish_u32(const char *ds_name, u32_t value, int flags)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_VAL = value;
|
||||
m.DS_FLAGS = DSF_TYPE_U32 | flags;
|
||||
return do_invoke_ds(DS_PUBLISH, ds_name);
|
||||
return do_invoke_ds(&m, DS_PUBLISH, ds_name);
|
||||
}
|
||||
|
||||
static int ds_publish_raw(const char *ds_name, void *vaddr, size_t length,
|
||||
int flags)
|
||||
{
|
||||
cp_grant_id_t gid;
|
||||
message m;
|
||||
int r;
|
||||
|
||||
/* Grant for memory range. */
|
||||
gid = cpf_grant_direct(DS_PROC_NR, (vir_bytes)vaddr, length, CPF_READ);
|
||||
if(!GRANT_VALID(gid))
|
||||
return errno;
|
||||
return ENOMEM;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_VAL = gid;
|
||||
m.DS_VAL_LEN = length;
|
||||
m.DS_FLAGS = flags;
|
||||
|
||||
r = do_invoke_ds(DS_PUBLISH, ds_name);
|
||||
r = do_invoke_ds(&m, DS_PUBLISH, ds_name);
|
||||
cpf_revoke(gid);
|
||||
|
||||
return r;
|
||||
|
@ -83,36 +89,37 @@ int ds_publish_mem(const char *ds_name, void *vaddr, size_t length, int flags)
|
|||
return ds_publish_raw(ds_name, vaddr, length, flags | DSF_TYPE_MEM);
|
||||
}
|
||||
|
||||
int ds_snapshot_map(const char *ds_name, int *nr_snapshot)
|
||||
{
|
||||
int r;
|
||||
r = do_invoke_ds(DS_SNAPSHOT, ds_name);
|
||||
*nr_snapshot = m.DS_NR_SNAPSHOT;
|
||||
return r;
|
||||
}
|
||||
|
||||
int ds_retrieve_label_name(char *ds_name, endpoint_t endpoint)
|
||||
{
|
||||
message m;
|
||||
int r;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_VAL = (u32_t) endpoint;
|
||||
r = do_invoke_ds(DS_RETRIEVE_LABEL, ds_name);
|
||||
r = do_invoke_ds(&m, DS_RETRIEVE_LABEL, ds_name);
|
||||
return r;
|
||||
}
|
||||
|
||||
int ds_retrieve_label_endpt(const char *ds_name, endpoint_t *endpoint)
|
||||
{
|
||||
message m;
|
||||
int r;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_FLAGS = DSF_TYPE_LABEL;
|
||||
r = do_invoke_ds(DS_RETRIEVE, ds_name);
|
||||
r = do_invoke_ds(&m, DS_RETRIEVE, ds_name);
|
||||
*endpoint = (endpoint_t) m.DS_VAL;
|
||||
return r;
|
||||
}
|
||||
|
||||
int ds_retrieve_u32(const char *ds_name, u32_t *value)
|
||||
{
|
||||
message m;
|
||||
int r;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_FLAGS = DSF_TYPE_U32;
|
||||
r = do_invoke_ds(DS_RETRIEVE, ds_name);
|
||||
r = do_invoke_ds(&m, DS_RETRIEVE, ds_name);
|
||||
*value = m.DS_VAL;
|
||||
return r;
|
||||
}
|
||||
|
@ -120,18 +127,20 @@ int ds_retrieve_u32(const char *ds_name, u32_t *value)
|
|||
static int ds_retrieve_raw(const char *ds_name, char *vaddr, size_t *length,
|
||||
int flags)
|
||||
{
|
||||
message m;
|
||||
cp_grant_id_t gid;
|
||||
int r;
|
||||
|
||||
/* Grant for memory range. */
|
||||
gid = cpf_grant_direct(DS_PROC_NR, (vir_bytes)vaddr, *length, CPF_WRITE);
|
||||
if(!GRANT_VALID(gid))
|
||||
return errno;
|
||||
return ENOMEM;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_VAL = gid;
|
||||
m.DS_VAL_LEN = *length;
|
||||
m.DS_FLAGS = flags;
|
||||
r = do_invoke_ds(DS_RETRIEVE, ds_name);
|
||||
r = do_invoke_ds(&m, DS_RETRIEVE, ds_name);
|
||||
*length = m.DS_VAL_LEN;
|
||||
cpf_revoke(gid);
|
||||
|
||||
|
@ -154,38 +163,56 @@ int ds_retrieve_mem(const char *ds_name, char *vaddr, size_t *length)
|
|||
|
||||
int ds_delete_u32(const char *ds_name)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_FLAGS = DSF_TYPE_U32;
|
||||
return do_invoke_ds(DS_DELETE, ds_name);
|
||||
return do_invoke_ds(&m, DS_DELETE, ds_name);
|
||||
}
|
||||
|
||||
int ds_delete_str(const char *ds_name)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_FLAGS = DSF_TYPE_STR;
|
||||
return do_invoke_ds(DS_DELETE, ds_name);
|
||||
return do_invoke_ds(&m, DS_DELETE, ds_name);
|
||||
}
|
||||
|
||||
int ds_delete_mem(const char *ds_name)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_FLAGS = DSF_TYPE_MEM;
|
||||
return do_invoke_ds(DS_DELETE, ds_name);
|
||||
return do_invoke_ds(&m, DS_DELETE, ds_name);
|
||||
}
|
||||
|
||||
int ds_delete_label(const char *ds_name)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_FLAGS = DSF_TYPE_LABEL;
|
||||
return do_invoke_ds(DS_DELETE, ds_name);
|
||||
return do_invoke_ds(&m, DS_DELETE, ds_name);
|
||||
}
|
||||
|
||||
int ds_subscribe(const char *regexp, int flags)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.DS_FLAGS = flags;
|
||||
return do_invoke_ds(DS_SUBSCRIBE, regexp);
|
||||
return do_invoke_ds(&m, DS_SUBSCRIBE, regexp);
|
||||
}
|
||||
|
||||
int ds_check(char *ds_key, int *type, endpoint_t *owner_e)
|
||||
{
|
||||
message m;
|
||||
int r;
|
||||
r = do_invoke_ds(DS_CHECK, ds_key);
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
r = do_invoke_ds(&m, DS_CHECK, ds_key);
|
||||
if(type) *type = m.DS_FLAGS;
|
||||
if(owner_e) *owner_e = m.DS_OWNER;
|
||||
return r;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "sysutil.h"
|
||||
#include <string.h>
|
||||
|
||||
/*===========================================================================*
|
||||
* fkey_ctl *
|
||||
|
@ -15,6 +16,7 @@ int *sfkeys; /* bit masks for Shift F1-F12 keys */
|
|||
*/
|
||||
message m;
|
||||
int s;
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.FKEY_REQUEST = request;
|
||||
m.FKEY_FKEYS = (fkeys) ? *fkeys : 0;
|
||||
m.FKEY_SFKEYS = (sfkeys) ? *sfkeys : 0;
|
||||
|
|
75
lib/libsys/getepinfo.c
Normal file
75
lib/libsys/getepinfo.c
Normal file
|
@ -0,0 +1,75 @@
|
|||
#include "syslib.h"
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/ucred.h>
|
||||
|
||||
static pid_t
|
||||
getepinfo(endpoint_t proc_ep, uid_t *uid, gid_t *gid)
|
||||
{
|
||||
message m;
|
||||
int r;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.PM_GETEPINFO_ENDPT = proc_ep;
|
||||
|
||||
if ((r = _taskcall(PM_PROC_NR, GETEPINFO, &m)) < 0)
|
||||
return r;
|
||||
|
||||
if (uid != NULL)
|
||||
*uid = m.PM_GETEPINFO_UID;
|
||||
if (gid != NULL)
|
||||
*gid = m.PM_GETEPINFO_GID;
|
||||
return (pid_t) r;
|
||||
}
|
||||
|
||||
pid_t
|
||||
getnpid(endpoint_t proc_ep)
|
||||
{
|
||||
return getepinfo(proc_ep, NULL, NULL);
|
||||
}
|
||||
|
||||
uid_t
|
||||
getnuid(endpoint_t proc_ep)
|
||||
{
|
||||
uid_t uid;
|
||||
int r;
|
||||
|
||||
if ((r = getepinfo(proc_ep, &uid, NULL)) < 0)
|
||||
return (uid_t) r;
|
||||
|
||||
return uid;
|
||||
}
|
||||
|
||||
gid_t
|
||||
getngid(endpoint_t proc_ep)
|
||||
{
|
||||
gid_t gid;
|
||||
int r;
|
||||
|
||||
if ((r = getepinfo(proc_ep, NULL, &gid)) < 0)
|
||||
return (gid_t) r;
|
||||
|
||||
return gid;
|
||||
}
|
||||
|
||||
int
|
||||
getnucred(endpoint_t proc_ep, struct uucred *ucred)
|
||||
{
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
int r;
|
||||
|
||||
if (ucred == NULL)
|
||||
return EFAULT;
|
||||
|
||||
if ((r = getepinfo(proc_ep, &uid, &gid)) < 0)
|
||||
return r;
|
||||
|
||||
/* Only two fields are used for now; ensure the rest is zeroed out. */
|
||||
memset(ucred, 0, sizeof(struct uucred));
|
||||
ucred->cr_uid = uid;
|
||||
ucred->cr_gid = gid;
|
||||
|
||||
return r;
|
||||
}
|
19
lib/libsys/getprocnr.c
Normal file
19
lib/libsys/getprocnr.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include "syslib.h"
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
getprocnr(pid_t pid, endpoint_t *proc_e)
|
||||
{
|
||||
message m;
|
||||
int r;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.PM_GETPROCNR_PID = pid;
|
||||
|
||||
if ((r = _taskcall(PM_PROC_NR, GETPROCNR, &m)) < 0)
|
||||
return r;
|
||||
|
||||
*proc_e = m.PM_GETPROCNR_ENDPT;
|
||||
return r;
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
#include <lib.h>
|
||||
#include "syslib.h"
|
||||
#include <string.h>
|
||||
#include <minix/sysinfo.h>
|
||||
#include <minix/com.h>
|
||||
|
||||
|
@ -11,9 +12,9 @@ int getsysinfo(
|
|||
)
|
||||
{
|
||||
message m;
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.SI_WHAT = what;
|
||||
m.SI_WHERE = where;
|
||||
m.SI_SIZE = size;
|
||||
if (_syscall(who, COMMON_GETSYSINFO, &m) < 0) return(-1);
|
||||
return(0);
|
||||
return _taskcall(who, COMMON_GETSYSINFO, &m);
|
||||
}
|
||||
|
|
17
lib/libsys/mapdriver.c
Normal file
17
lib/libsys/mapdriver.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include "syslib.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
mapdriver(char *label, devmajor_t major)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VFS_MAPDRIVER_LABEL = label;
|
||||
m.VFS_MAPDRIVER_LABELLEN = strlen(label) + 1;
|
||||
m.VFS_MAPDRIVER_MAJOR = major;
|
||||
|
||||
return _taskcall(VFS_PROC_NR, MAPDRIVER, &m);
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
#include <assert.h>
|
||||
#include <machine/archtypes.h>
|
||||
#include <minix/timers.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "kernel/config.h"
|
||||
#include "kernel/const.h"
|
||||
|
@ -24,6 +25,7 @@ int sched_inherit(endpoint_t scheduler_e,
|
|||
assert(maxprio < NR_SCHED_QUEUES);
|
||||
assert(newscheduler_e);
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.SCHEDULING_ENDPOINT = schedulee_e;
|
||||
m.SCHEDULING_PARENT = parent_e;
|
||||
m.SCHEDULING_MAXPRIO = (int) maxprio;
|
||||
|
@ -79,6 +81,7 @@ int sched_start(endpoint_t scheduler_e,
|
|||
}
|
||||
|
||||
/* A user-space scheduler must schedule this process. */
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.SCHEDULING_ENDPOINT = schedulee_e;
|
||||
m.SCHEDULING_PARENT = parent_e;
|
||||
m.SCHEDULING_MAXPRIO = (int) maxprio;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "syslib.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
/*===========================================================================*
|
||||
* sched_stop *
|
||||
|
@ -18,6 +19,7 @@ int sched_stop(endpoint_t scheduler_e, endpoint_t schedulee_e)
|
|||
assert(_ENDPOINT_P(scheduler_e) >= 0);
|
||||
assert(_ENDPOINT_P(schedulee_e) >= 0);
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.SCHEDULING_ENDPOINT = schedulee_e;
|
||||
if ((rv = _taskcall(scheduler_e, SCHEDULING_STOP, &m))) {
|
||||
return rv;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
/* Self variables. */
|
||||
#define SEF_SELF_NAME_MAXLEN 20
|
||||
char sef_self_name[SEF_SELF_NAME_MAXLEN];
|
||||
endpoint_t sef_self_endpoint;
|
||||
endpoint_t sef_self_endpoint = NONE;
|
||||
int sef_self_priv_flags;
|
||||
int sef_self_first_receive_done;
|
||||
int sef_self_receiving;
|
||||
|
@ -68,8 +68,8 @@ void sef_startup()
|
|||
if((sef_self_priv_flags & ROOT_SYS_PROC) && sef_self_endpoint != RS_PROC_NR) {
|
||||
r = vm_update(RS_PROC_NR, sef_self_endpoint);
|
||||
if(r != OK) {
|
||||
panic("unable to update RS from instance %d to %d",
|
||||
RS_PROC_NR, sef_self_endpoint);
|
||||
panic("unable to update RS from instance %d to %d: %d",
|
||||
RS_PROC_NR, sef_self_endpoint, r);
|
||||
}
|
||||
old_endpoint = sef_self_endpoint;
|
||||
sef_self_endpoint = RS_PROC_NR;
|
||||
|
@ -190,6 +190,19 @@ int sef_receive_status(endpoint_t src, message *m_ptr, int *status_ptr)
|
|||
return r;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sef_self *
|
||||
*===========================================================================*/
|
||||
endpoint_t sef_self(void)
|
||||
{
|
||||
/* Return the process's own endpoint number. */
|
||||
|
||||
if (sef_self_endpoint == NONE)
|
||||
panic("sef_self called before initialization");
|
||||
|
||||
return sef_self_endpoint;
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sef_cancel *
|
||||
*===========================================================================*/
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <string.h>
|
||||
|
||||
/* SEF Init callbacks. */
|
||||
static struct sef_cbs {
|
||||
|
@ -62,6 +63,7 @@ static int process_init(int type, sef_init_info_t *info)
|
|||
break;
|
||||
}
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.m_source = sef_self_endpoint;
|
||||
m.m_type = RS_INIT;
|
||||
m.RS_INIT_RESULT = result;
|
||||
|
|
14
lib/libsys/srv_fork.c
Normal file
14
lib/libsys/srv_fork.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include "syslib.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
pid_t
|
||||
srv_fork(uid_t reuid, gid_t regid)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.m1_i1 = (int) reuid;
|
||||
m.m1_i2 = (int) regid;
|
||||
return _taskcall(PM_PROC_NR, SRV_FORK, &m);
|
||||
}
|
14
lib/libsys/srv_kill.c
Normal file
14
lib/libsys/srv_kill.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include "syslib.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
srv_kill(pid_t pid, int sig)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.m1_i1 = pid;
|
||||
m.m1_i2 = sig;
|
||||
return _taskcall(PM_PROC_NR, SRV_KILL, &m);
|
||||
}
|
|
@ -6,13 +6,6 @@
|
|||
#include <lib.h>
|
||||
#include <minix/syslib.h>
|
||||
|
||||
int _sendcall(endpoint_t who, int type, message *msgptr)
|
||||
{
|
||||
msgptr->m_type = type;
|
||||
return send(who, msgptr);
|
||||
}
|
||||
|
||||
|
||||
int _taskcall(who, syscallnr, msgptr)
|
||||
endpoint_t who;
|
||||
int syscallnr;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include "syslib.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <minix/vm.h>
|
||||
|
||||
/*===========================================================================*
|
||||
|
@ -10,6 +11,7 @@ int vm_brk(endpoint_t ep, char *addr)
|
|||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VMB_ENDPOINT = ep;
|
||||
m.VMB_ADDR = (void *) addr;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
#include "syslib.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <minix/vm.h>
|
||||
|
||||
/*===========================================================================*
|
||||
|
@ -11,6 +11,7 @@ int vm_exit(endpoint_t ep)
|
|||
message m;
|
||||
int result;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VME_ENDPOINT = ep;
|
||||
|
||||
result = _taskcall(VM_PROC_NR, VM_EXIT, &m);
|
||||
|
@ -26,6 +27,7 @@ int vm_willexit(endpoint_t ep)
|
|||
message m;
|
||||
int result;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VMWE_ENDPOINT = ep;
|
||||
|
||||
result = _taskcall(VM_PROC_NR, VM_WILLEXIT, &m);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include "syslib.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <minix/vm.h>
|
||||
|
||||
/*===========================================================================*
|
||||
|
@ -11,6 +12,7 @@ int vm_fork(endpoint_t ep, int slot, endpoint_t *childep)
|
|||
message m;
|
||||
int result;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VMF_ENDPOINT = ep;
|
||||
m.VMF_SLOTNO = slot;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include "syslib.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <minix/vm.h>
|
||||
|
||||
/*===========================================================================*
|
||||
|
@ -10,6 +11,7 @@ int vm_info_stats(struct vm_stats_info *vsi)
|
|||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VMI_WHAT = VMIW_STATS;
|
||||
m.VMI_PTR = (void *) vsi;
|
||||
|
||||
|
@ -23,6 +25,7 @@ int vm_info_usage(endpoint_t who, struct vm_usage_info *vui)
|
|||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VMI_WHAT = VMIW_USAGE;
|
||||
m.VMI_EP = who;
|
||||
m.VMI_PTR = (void *) vui;
|
||||
|
@ -39,6 +42,7 @@ int vm_info_region(endpoint_t who, struct vm_region_info *vri,
|
|||
message m;
|
||||
int result;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VMI_WHAT = VMIW_REGION;
|
||||
m.VMI_EP = who;
|
||||
m.VMI_COUNT = count;
|
||||
|
|
|
@ -1,35 +1,36 @@
|
|||
#define _SYSTEM 1
|
||||
#include <lib.h>
|
||||
#include "syslib.h"
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <minix/syslib.h>
|
||||
#include <minix/vm.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
void *vm_map_phys(endpoint_t who, void *phaddr, size_t len)
|
||||
void *
|
||||
vm_map_phys(endpoint_t who, void *phaddr, size_t len)
|
||||
{
|
||||
message m;
|
||||
int r;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VMMP_EP = who;
|
||||
m.VMMP_PHADDR = phaddr;
|
||||
m.VMMP_LEN = len;
|
||||
|
||||
r = _taskcall(VM_PROC_NR, VM_MAP_PHYS, &m);
|
||||
|
||||
if(r != OK) return MAP_FAILED;
|
||||
if (r != OK) return MAP_FAILED;
|
||||
|
||||
return (void *) m.VMMP_VADDR_REPLY;
|
||||
}
|
||||
|
||||
int vm_unmap_phys(endpoint_t who, void *vaddr, size_t len)
|
||||
int
|
||||
vm_unmap_phys(endpoint_t who, void *vaddr, size_t len)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VMUP_EP = who;
|
||||
m.VMUP_VADDR = vaddr;
|
||||
|
||||
return _taskcall(VM_PROC_NR, VM_UNMAP_PHYS, &m);
|
||||
}
|
||||
|
||||
|
|
15
lib/libsys/vm_memctl.c
Normal file
15
lib/libsys/vm_memctl.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include "syslib.h"
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
vm_memctl(endpoint_t ep, int req)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VM_RS_CTL_ENDPT = ep;
|
||||
m.VM_RS_CTL_REQ = req;
|
||||
|
||||
return _taskcall(VM_PROC_NR, VM_RS_MEMCTL, &m);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include "syslib.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <minix/vm.h>
|
||||
|
||||
/*===========================================================================*
|
||||
|
@ -11,6 +12,7 @@ int vm_notify_sig(endpoint_t ep, endpoint_t ipc_ep)
|
|||
message m;
|
||||
int result;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VM_NOTIFY_SIG_ENDPOINT = ep;
|
||||
m.VM_NOTIFY_SIG_IPC = ipc_ep;
|
||||
|
||||
|
|
37
lib/libsys/vm_query_exit.c
Normal file
37
lib/libsys/vm_query_exit.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
#include "syslib.h"
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Return a negative error code if the query itself or the processing of the
|
||||
* query resulted in an error.
|
||||
* Return 1 if there are more processes waiting to be queried.
|
||||
* Return 0 if there are no more processes.
|
||||
* Note that for the return value of 0 and 1, the 'endpt' is set accordingly.
|
||||
*/
|
||||
int
|
||||
vm_query_exit(int *endpt)
|
||||
{
|
||||
message m;
|
||||
int r;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
r = _taskcall(VM_PROC_NR, VM_QUERY_EXIT, &m);
|
||||
if (r != OK)
|
||||
return r;
|
||||
if (endpt == NULL)
|
||||
return EFAULT;
|
||||
|
||||
*endpt = m.VM_QUERY_RET_PT;
|
||||
return (m.VM_QUERY_IS_MORE ? 1 : 0);
|
||||
}
|
||||
|
||||
int
|
||||
vm_watch_exit(endpoint_t ep)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VM_WE_EP = ep;
|
||||
return _taskcall(VM_PROC_NR, VM_WATCH_EXIT, &m);
|
||||
}
|
17
lib/libsys/vm_set_priv.c
Normal file
17
lib/libsys/vm_set_priv.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
#include "syslib.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
vm_set_priv(endpoint_t ep, void *buf, int sys_proc)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VM_RS_NR = ep;
|
||||
m.VM_RS_BUF = (long) buf;
|
||||
m.VM_RS_SYS = sys_proc;
|
||||
|
||||
return _taskcall(VM_PROC_NR, VM_RS_SET_PRIV, &m);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include "syslib.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <minix/vm.h>
|
||||
|
||||
/*===========================================================================*
|
||||
|
@ -11,6 +12,7 @@ int vm_umap(int seg, vir_bytes offset, vir_bytes len, phys_bytes *addr)
|
|||
message m;
|
||||
int result;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VMU_SEG = seg;
|
||||
m.VMU_OFFSET = (char *) offset;
|
||||
m.VMU_LENGTH = (char *) len;
|
||||
|
|
16
lib/libsys/vm_update.c
Normal file
16
lib/libsys/vm_update.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
#include "syslib.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
int
|
||||
vm_update(endpoint_t src_e, endpoint_t dst_e)
|
||||
{
|
||||
message m;
|
||||
|
||||
memset(&m, 0, sizeof(m));
|
||||
m.VM_RS_SRC_ENDPT = src_e;
|
||||
m.VM_RS_DST_ENDPT = dst_e;
|
||||
|
||||
return _taskcall(VM_PROC_NR, VM_RS_UPDATE, &m);
|
||||
}
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#define NR_DS_KEYS (2*NR_SYS_PROCS) /* number of entries */
|
||||
#define NR_DS_SUBS (4*NR_SYS_PROCS) /* number of subscriptions */
|
||||
#define NR_DS_SNAPSHOT 5 /* number of snapshots */
|
||||
|
||||
/* Base 'class' for the following 3 structs. */
|
||||
struct data_store {
|
||||
|
@ -26,13 +25,6 @@ struct data_store {
|
|||
size_t length;
|
||||
size_t reallen;
|
||||
} mem;
|
||||
struct dsi_map {
|
||||
void *data;
|
||||
size_t length;
|
||||
void *realpointer;
|
||||
void *snapshots[NR_DS_SNAPSHOT];
|
||||
int sindex;
|
||||
} map;
|
||||
} u;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@ EXTERN gid_t caller_gid;
|
|||
|
||||
EXTERN int req_nr;
|
||||
|
||||
EXTERN endpoint_t SELF_E;
|
||||
|
||||
EXTERN char user_path[PATH_MAX+1]; /* pathname to be processed */
|
||||
|
||||
EXTERN dev_t fs_dev; /* The device that is handled by this FS proc
|
||||
|
|
|
@ -152,8 +152,6 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
|
||||
init_inode_cache();
|
||||
|
||||
SELF_E = getprocnr();
|
||||
|
||||
/* just a small number before we find out the block size at mount time */
|
||||
lmfs_buf_pool(10);
|
||||
|
||||
|
@ -214,5 +212,5 @@ static void reply(
|
|||
)
|
||||
{
|
||||
if (OK != send(who, m_out)) /* send the message */
|
||||
printf("ext2(%d) was unable to send reply\n", SELF_E);
|
||||
printf("ext2(%d) was unable to send reply\n", sef_self());
|
||||
}
|
||||
|
|
|
@ -44,5 +44,3 @@ void sem_process_vm_notify(void);
|
|||
EXTERN int identifier;
|
||||
EXTERN endpoint_t who_e;
|
||||
EXTERN int call_type;
|
||||
EXTERN endpoint_t SELF_E;
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
int identifier = 0x1234;
|
||||
endpoint_t who_e;
|
||||
int call_type;
|
||||
endpoint_t SELF_E;
|
||||
|
||||
static struct {
|
||||
int type;
|
||||
|
@ -140,10 +139,8 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
{
|
||||
/* Initialize the ipc server. */
|
||||
|
||||
SELF_E = getprocnr();
|
||||
|
||||
if(verbose)
|
||||
printf("IPC: self: %d\n", SELF_E);
|
||||
printf("IPC: self: %d\n", sef_self());
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ int do_semctl(message *m)
|
|||
ds = (struct semid_ds *) opt;
|
||||
if (!ds)
|
||||
return EFAULT;
|
||||
r = sys_datacopy(SELF_E, (vir_bytes) &sem->semid_ds,
|
||||
r = sys_datacopy(SELF, (vir_bytes) &sem->semid_ds,
|
||||
who_e, (vir_bytes) ds, sizeof(struct semid_ds));
|
||||
if (r != OK)
|
||||
return EINVAL;
|
||||
|
@ -325,7 +325,7 @@ int do_semctl(message *m)
|
|||
return EPERM;
|
||||
ds = (struct semid_ds *) opt;
|
||||
r = sys_datacopy(who_e, (vir_bytes) ds,
|
||||
SELF_E, (vir_bytes) &tmp_ds, sizeof(struct semid_ds));
|
||||
SELF, (vir_bytes) &tmp_ds, sizeof(struct semid_ds));
|
||||
if (r != OK)
|
||||
return EINVAL;
|
||||
sem->semid_ds.sem_perm.uid = tmp_ds.sem_perm.uid;
|
||||
|
@ -357,7 +357,7 @@ int do_semctl(message *m)
|
|||
return ENOMEM;
|
||||
for (i = 0; i < sem->semid_ds.sem_nsems; i++)
|
||||
buf[i] = sem->sems[i].semval;
|
||||
r = sys_datacopy(SELF_E, (vir_bytes) buf,
|
||||
r = sys_datacopy(SELF, (vir_bytes) buf,
|
||||
who_e, (vir_bytes) opt,
|
||||
sizeof(unsigned short) * sem->semid_ds.sem_nsems);
|
||||
if (r != OK)
|
||||
|
@ -389,7 +389,7 @@ int do_semctl(message *m)
|
|||
if (!buf)
|
||||
return ENOMEM;
|
||||
r = sys_datacopy(who_e, (vir_bytes) opt,
|
||||
SELF_E, (vir_bytes) buf,
|
||||
SELF, (vir_bytes) buf,
|
||||
sizeof(unsigned short) * sem->semid_ds.sem_nsems);
|
||||
if (r != OK)
|
||||
return EINVAL;
|
||||
|
@ -470,7 +470,7 @@ int do_semop(message *m)
|
|||
if (!sops)
|
||||
goto out_free;
|
||||
r = sys_datacopy(who_e, (vir_bytes) m->SEMOP_OPS,
|
||||
SELF_E, (vir_bytes) sops,
|
||||
SELF, (vir_bytes) sops,
|
||||
sizeof(struct sembuf) * nsops);
|
||||
if (r != OK) {
|
||||
r = EINVAL;
|
||||
|
|
|
@ -76,7 +76,7 @@ int do_shmget(message *m)
|
|||
PROT_READ|PROT_WRITE, MAP_ANON, -1, 0);
|
||||
if (shm->page == (vir_bytes) MAP_FAILED)
|
||||
return ENOMEM;
|
||||
shm->vm_id = vm_getphys(SELF_E, (void *) shm->page);
|
||||
shm->vm_id = vm_getphys(sef_self(), (void *) shm->page);
|
||||
memset((void *)shm->page, 0, size);
|
||||
|
||||
shm->shmid_ds.shm_perm.cuid =
|
||||
|
@ -132,7 +132,7 @@ int do_shmat(message *m)
|
|||
if (!check_perm(&shm->shmid_ds.shm_perm, who_e, flag))
|
||||
return EACCES;
|
||||
|
||||
ret = vm_remap(who_e, SELF_E, (void *)addr, (void *)shm->page,
|
||||
ret = vm_remap(who_e, sef_self(), (void *)addr, (void *)shm->page,
|
||||
shm->shmid_ds.shm_segsz);
|
||||
if (ret == MAP_FAILED)
|
||||
return ENOMEM;
|
||||
|
@ -155,7 +155,7 @@ void update_refcount_and_destroy(void)
|
|||
for (i = 0, j = 0; i < shm_list_nr; i++) {
|
||||
u8_t rc;
|
||||
|
||||
rc = vm_getrefcount(SELF_E, (void *) shm_list[i].page);
|
||||
rc = vm_getrefcount(sef_self(), (void *) shm_list[i].page);
|
||||
if (rc == (u8_t) -1) {
|
||||
printf("IPC: can't find physical region.\n");
|
||||
continue;
|
||||
|
@ -243,7 +243,7 @@ int do_shmctl(message *m)
|
|||
/* check whether it has read permission */
|
||||
if (!check_perm(&shm->shmid_ds.shm_perm, who_e, 0444))
|
||||
return EACCES;
|
||||
r = sys_datacopy(SELF_E, (vir_bytes)&shm->shmid_ds,
|
||||
r = sys_datacopy(SELF, (vir_bytes)&shm->shmid_ds,
|
||||
who_e, (vir_bytes)ds, sizeof(struct shmid_ds));
|
||||
if (r != OK)
|
||||
return EFAULT;
|
||||
|
@ -255,7 +255,7 @@ int do_shmctl(message *m)
|
|||
uid != 0)
|
||||
return EPERM;
|
||||
r = sys_datacopy(who_e, (vir_bytes)ds,
|
||||
SELF_E, (vir_bytes)&tmp_ds, sizeof(struct shmid_ds));
|
||||
SELF, (vir_bytes)&tmp_ds, sizeof(struct shmid_ds));
|
||||
if (r != OK)
|
||||
return EFAULT;
|
||||
shm->shmid_ds.shm_perm.uid = tmp_ds.shm_perm.uid;
|
||||
|
@ -282,7 +282,7 @@ int do_shmctl(message *m)
|
|||
sinfo.shmmni = MAX_SHM_NR;
|
||||
sinfo.shmseg = (unsigned long) -1;
|
||||
sinfo.shmall = (unsigned long) -1;
|
||||
r = sys_datacopy(SELF_E, (vir_bytes)&sinfo,
|
||||
r = sys_datacopy(SELF, (vir_bytes)&sinfo,
|
||||
who_e, (vir_bytes)ds, sizeof(struct shminfo));
|
||||
if (r != OK)
|
||||
return EFAULT;
|
||||
|
@ -302,7 +302,7 @@ int do_shmctl(message *m)
|
|||
s_info.shm_swp = 0;
|
||||
s_info.swap_attempts = 0;
|
||||
s_info.swap_successes = 0;
|
||||
r = sys_datacopy(SELF_E, (vir_bytes)&s_info,
|
||||
r = sys_datacopy(SELF, (vir_bytes)&s_info,
|
||||
who_e, (vir_bytes)ds, sizeof(struct shm_info));
|
||||
if (r != OK)
|
||||
return EFAULT;
|
||||
|
@ -314,7 +314,7 @@ int do_shmctl(message *m)
|
|||
if (id < 0 || id >= shm_list_nr)
|
||||
return EINVAL;
|
||||
shm = &shm_list[id];
|
||||
r = sys_datacopy(SELF_E, (vir_bytes)&shm->shmid_ds,
|
||||
r = sys_datacopy(SELF, (vir_bytes)&shm->shmid_ds,
|
||||
who_e, (vir_bytes)ds, sizeof(struct shmid_ds));
|
||||
if (r != OK)
|
||||
return EFAULT;
|
||||
|
|
|
@ -16,8 +16,6 @@ static message m_out; /* the output message used for reply */
|
|||
static endpoint_t who_e; /* caller's proc number */
|
||||
static int callnr; /* system call number */
|
||||
|
||||
extern int errno; /* error number set by system library */
|
||||
|
||||
/* Declare some local functions. */
|
||||
static void get_work(void);
|
||||
static void reply(int whom, int result);
|
||||
|
|
|
@ -21,8 +21,6 @@ EXTERN gid_t caller_gid;
|
|||
|
||||
EXTERN int req_nr; /* request number to the server */
|
||||
|
||||
EXTERN int SELF_E; /* process number */
|
||||
|
||||
EXTERN short path_processed; /* number of characters processed */
|
||||
EXTERN char user_path[PATH_MAX+1]; /* pathname to be processed */
|
||||
EXTERN char *vfs_slink_storage;
|
||||
|
|
|
@ -102,8 +102,6 @@ static int sef_cb_init_fresh(int type, sef_init_info_t *info)
|
|||
{
|
||||
/* Initialize the iso9660fs server. */
|
||||
|
||||
/* SELF_E will contain the id of this process */
|
||||
SELF_E = getprocnr();
|
||||
/* hash_init(); */ /* Init the table with the ids */
|
||||
setenv("TZ","",1); /* Used to calculate the time */
|
||||
|
||||
|
@ -145,5 +143,5 @@ int who;
|
|||
message *m_out; /* report result */
|
||||
{
|
||||
if (OK != send(who, m_out)) /* send the message */
|
||||
printf("ISOFS(%d) was unable to send reply\n", SELF_E);
|
||||
printf("ISOFS(%d) was unable to send reply\n", sef_self());
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ int fs_access()
|
|||
|
||||
/* Temporarily open the file. */
|
||||
if ( (rip = get_dir_record(fs_m_in.REQ_INODE_NR)) == NULL) {
|
||||
printf("ISOFS(%d) get_dir_record by fs_access() failed\n", SELF_E);
|
||||
printf("ISOFS(%d) get_dir_record by fs_access() failed\n", sef_self());
|
||||
return(EINVAL);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,6 @@ EXTERN gid_t caller_gid;
|
|||
|
||||
EXTERN int req_nr;
|
||||
|
||||
EXTERN endpoint_t SELF_E;
|
||||
|
||||
EXTERN char user_path[PATH_MAX]; /* pathname to be processed */
|
||||
|
||||
EXTERN dev_t fs_dev; /* The device that is handled by this FS proc.
|
||||
|
|
|
@ -117,7 +117,6 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
|
||||
init_inode_cache();
|
||||
|
||||
SELF_E = getprocnr();
|
||||
lmfs_buf_pool(DEFAULT_NR_BUFS);
|
||||
|
||||
return(OK);
|
||||
|
@ -177,7 +176,7 @@ static void reply(
|
|||
)
|
||||
{
|
||||
if (OK != send(who, m_out)) /* send the message */
|
||||
printf("MFS(%d) was unable to send reply\n", SELF_E);
|
||||
printf("MFS(%d) was unable to send reply\n", sef_self());
|
||||
}
|
||||
|
||||
|
||||
|
@ -194,7 +193,7 @@ static void cch_check(void)
|
|||
req_nr != REQ_PUTNODE && req_nr != REQ_READSUPER &&
|
||||
req_nr != REQ_MOUNTPOINT && req_nr != REQ_UNMOUNT &&
|
||||
req_nr != REQ_SYNC && req_nr != REQ_LOOKUP) {
|
||||
printf("MFS(%d) inode(%lu) cc: %d req_nr: %d\n", SELF_E,
|
||||
printf("MFS(%d) inode(%lu) cc: %d req_nr: %d\n", sef_self(),
|
||||
inode[i].i_num, inode[i].i_count - cch[i], req_nr);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* The entry points into this file are:
|
||||
* do_reboot: kill all processes, then reboot system
|
||||
* do_getsysinfo: request copy of PM data structure (Jorrit N. Herder)
|
||||
* do_getprocnr: lookup process slot number (Jorrit N. Herder)
|
||||
* do_getprocnr: lookup endpoint by process ID
|
||||
* do_getepinfo: get the pid/uid/gid of a process given its endpoint
|
||||
* do_getsetpriority: get/set process priority
|
||||
* do_svrctl: process manager control
|
||||
|
@ -171,118 +171,40 @@ int do_getsysinfo()
|
|||
/*===========================================================================*
|
||||
* do_getprocnr *
|
||||
*===========================================================================*/
|
||||
int do_getprocnr()
|
||||
int do_getprocnr(void)
|
||||
{
|
||||
register struct mproc *rmp;
|
||||
static char search_key[PROC_NAME_LEN+1];
|
||||
int key_len;
|
||||
int s;
|
||||
|
||||
/* This call should be moved to DS. */
|
||||
if (mp->mp_effuid != 0)
|
||||
{
|
||||
/* For now, allow non-root processes to request their own endpoint. */
|
||||
if (m_in.pid < 0 && m_in.namelen == 0) {
|
||||
mp->mp_reply.PM_ENDPT = who_e;
|
||||
mp->mp_reply.PM_PENDPT = NONE;
|
||||
return OK;
|
||||
}
|
||||
|
||||
printf("PM: unauthorized call of do_getprocnr by proc %d\n",
|
||||
mp->mp_endpoint);
|
||||
sys_diagctl_stacktrace(mp->mp_endpoint);
|
||||
/* This check should be replaced by per-call ACL checks. */
|
||||
if (who_e != RS_PROC_NR) {
|
||||
printf("PM: unauthorized call of do_getprocnr by %d\n", who_e);
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf("PM: do_getprocnr(%d) call from endpoint %d, %s\n",
|
||||
m_in.pid, mp->mp_endpoint, mp->mp_name);
|
||||
#endif
|
||||
|
||||
if (m_in.pid >= 0) { /* lookup process by pid */
|
||||
if ((rmp = find_proc(m_in.pid)) != NULL) {
|
||||
mp->mp_reply.PM_ENDPT = rmp->mp_endpoint;
|
||||
#if 0
|
||||
printf("PM: pid result: %d\n", rmp->mp_endpoint);
|
||||
#endif
|
||||
return(OK);
|
||||
}
|
||||
if ((rmp = find_proc(m_in.PM_GETPROCNR_PID)) == NULL)
|
||||
return(ESRCH);
|
||||
} else if (m_in.namelen > 0) { /* lookup process by name */
|
||||
key_len = MIN(m_in.namelen, PROC_NAME_LEN);
|
||||
if (OK != (s=sys_datacopy(who_e, (vir_bytes) m_in.PMBRK_ADDR,
|
||||
SELF, (vir_bytes) search_key, key_len)))
|
||||
return(s);
|
||||
search_key[key_len] = '\0'; /* terminate for safety */
|
||||
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
|
||||
if (((rmp->mp_flags & (IN_USE | EXITING)) == IN_USE) &&
|
||||
strncmp(rmp->mp_name, search_key, key_len)==0) {
|
||||
mp->mp_reply.PM_ENDPT = rmp->mp_endpoint;
|
||||
return(OK);
|
||||
}
|
||||
}
|
||||
return(ESRCH);
|
||||
} else { /* return own/parent process number */
|
||||
#if 0
|
||||
printf("PM: endpt result: %d\n", mp->mp_reply.PM_ENDPT);
|
||||
#endif
|
||||
mp->mp_reply.PM_ENDPT = who_e;
|
||||
mp->mp_reply.PM_PENDPT = mproc[mp->mp_parent].mp_endpoint;
|
||||
}
|
||||
|
||||
mp->mp_reply.PM_GETPROCNR_ENDPT = rmp->mp_endpoint;
|
||||
return(OK);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* do_getepinfo *
|
||||
*===========================================================================*/
|
||||
int do_getepinfo()
|
||||
int do_getepinfo(void)
|
||||
{
|
||||
register struct mproc *rmp;
|
||||
struct mproc *rmp;
|
||||
endpoint_t ep;
|
||||
int slot;
|
||||
|
||||
ep = m_in.PM_ENDPT;
|
||||
|
||||
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
|
||||
if ((rmp->mp_flags & IN_USE) && (rmp->mp_endpoint == ep)) {
|
||||
mp->mp_reply.reply_res2 = rmp->mp_effuid;
|
||||
mp->mp_reply.reply_res3 = rmp->mp_effgid;
|
||||
return(rmp->mp_pid);
|
||||
}
|
||||
}
|
||||
|
||||
/* Process not found */
|
||||
ep = m_in.PM_GETEPINFO_ENDPT;
|
||||
if (pm_isokendpt(ep, &slot) != OK)
|
||||
return(ESRCH);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* do_getepinfo_o *
|
||||
*===========================================================================*/
|
||||
int do_getepinfo_o()
|
||||
{
|
||||
register struct mproc *rmp;
|
||||
endpoint_t ep;
|
||||
|
||||
/* This call should be moved to DS. */
|
||||
if (mp->mp_effuid != 0) {
|
||||
printf("PM: unauthorized call of do_getepinfo_o by proc %d\n",
|
||||
mp->mp_endpoint);
|
||||
sys_diagctl_stacktrace(mp->mp_endpoint);
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
ep = m_in.PM_ENDPT;
|
||||
|
||||
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) {
|
||||
if ((rmp->mp_flags & IN_USE) && (rmp->mp_endpoint == ep)) {
|
||||
mp->mp_reply.reply_res2 = (short) rmp->mp_effuid;
|
||||
mp->mp_reply.reply_res3 = (char) rmp->mp_effgid;
|
||||
rmp = &mproc[slot];
|
||||
mp->mp_reply.PM_GETEPINFO_UID = rmp->mp_effuid;
|
||||
mp->mp_reply.PM_GETEPINFO_GID = rmp->mp_effgid;
|
||||
return(rmp->mp_pid);
|
||||
}
|
||||
}
|
||||
|
||||
/* Process not found */
|
||||
return(ESRCH);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
|
|
|
@ -49,7 +49,6 @@ int do_sysuname(void);
|
|||
int do_getsysinfo(void);
|
||||
int do_getprocnr(void);
|
||||
int do_getepinfo(void);
|
||||
int do_getepinfo_o(void);
|
||||
int do_svrctl(void);
|
||||
int do_getsetpriority(void);
|
||||
int do_getrusage(void);
|
||||
|
|
|
@ -118,7 +118,7 @@ int (*call_vec[])(void) = {
|
|||
do_getprocnr, /* 104 = getprocnr */
|
||||
no_sys, /* 105 = unused */
|
||||
do_get, /* 106 = issetugid */
|
||||
do_getepinfo_o, /* 107 = getepinfo XXX: old implementation*/
|
||||
no_sys, /* 107 = unused */
|
||||
no_sys, /* 108 = (utimens) */
|
||||
no_sys, /* 109 = unused */
|
||||
no_sys, /* 110 = unused */
|
||||
|
|
|
@ -413,8 +413,8 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
|
||||
/* Get pid from PM. */
|
||||
rp->r_pid = getnpid(rpub->endpoint);
|
||||
if(rp->r_pid == -1) {
|
||||
panic("unable to get pid");
|
||||
if(rp->r_pid < 0) {
|
||||
panic("unable to get pid: %d", rp->r_pid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -433,11 +433,12 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
|
||||
/* Fork a new RS instance with root:operator. */
|
||||
pid = srv_fork(0, 0);
|
||||
if(pid == -1) {
|
||||
panic("unable to fork a new RS instance");
|
||||
if(pid < 0) {
|
||||
panic("unable to fork a new RS instance: %d", pid);
|
||||
}
|
||||
replica_pid = pid ? pid : getpid();
|
||||
replica_endpoint = getnprocnr(replica_pid);
|
||||
if ((s = getprocnr(replica_pid, &replica_endpoint)) != 0)
|
||||
panic("unable to get replica endpoint: %d", s);
|
||||
replica_rp->r_pid = replica_pid;
|
||||
replica_rp->r_pub->endpoint = replica_endpoint;
|
||||
|
||||
|
|
|
@ -210,30 +210,6 @@ void build_cmd_dep(struct rproc *rp)
|
|||
rpub->proc_name[len]= '\0';
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* srv_fork *
|
||||
*===========================================================================*/
|
||||
pid_t srv_fork(uid_t reuid, gid_t regid)
|
||||
{
|
||||
message m;
|
||||
|
||||
m.m1_i1 = (int) reuid;
|
||||
m.m1_i2 = (int) regid;
|
||||
return _syscall(PM_PROC_NR, SRV_FORK, &m);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* srv_kill *
|
||||
*===========================================================================*/
|
||||
int srv_kill(pid_t pid, int sig)
|
||||
{
|
||||
message m;
|
||||
|
||||
m.m1_i1 = pid;
|
||||
m.m1_i2 = sig;
|
||||
return(_syscall(PM_PROC_NR, SRV_KILL, &m));
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* srv_update *
|
||||
*===========================================================================*/
|
||||
|
@ -481,14 +457,15 @@ struct rproc *rp;
|
|||
if(rs_verbose)
|
||||
printf("RS: forking child with srv_fork()...\n");
|
||||
child_pid= srv_fork(rp->r_uid, 0); /* Force group to operator for now */
|
||||
if(child_pid == -1) {
|
||||
printf("RS: srv_fork() failed (error %d)\n", errno);
|
||||
if(child_pid < 0) {
|
||||
printf("RS: srv_fork() failed (error %d)\n", child_pid);
|
||||
free_slot(rp);
|
||||
return(errno);
|
||||
return(child_pid);
|
||||
}
|
||||
|
||||
/* Get endpoint of the child. */
|
||||
child_proc_nr_e = getnprocnr(child_pid);
|
||||
if ((s = getprocnr(child_pid, &child_proc_nr_e)) != 0)
|
||||
panic("unable to get child endpoint: %d", s);
|
||||
|
||||
/* There is now a child process. Update the system process table. */
|
||||
child_proc_nr_n = _ENDPOINT_P(child_proc_nr_e);
|
||||
|
@ -677,8 +654,8 @@ struct rproc *rp; /* pointer to service slot */
|
|||
*/
|
||||
setuid(0);
|
||||
|
||||
if (mapdriver(rpub->label, rpub->dev_nr) != OK) {
|
||||
return kill_service(rp, "couldn't map driver", errno);
|
||||
if ((r = mapdriver(rpub->label, rpub->dev_nr)) != OK) {
|
||||
return kill_service(rp, "couldn't map driver", r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1133,7 +1110,8 @@ static int run_script(struct rproc *rp)
|
|||
exit(1);
|
||||
default:
|
||||
/* Set the privilege structure for the child process. */
|
||||
endpoint = getnprocnr(pid);
|
||||
if ((r = getprocnr(pid, &endpoint)) != 0)
|
||||
panic("unable to get child endpoint: %d", r);
|
||||
if ((r = sys_privctl(endpoint, SYS_PRIV_SET_USER, NULL))
|
||||
!= OK) {
|
||||
return kill_service(rp,"can't set script privileges",r);
|
||||
|
|
|
@ -34,8 +34,6 @@ int copy_rs_start(endpoint_t src_e, char *src_rs_start, struct rs_start
|
|||
int copy_label(endpoint_t src_e, char *src_label, size_t src_len, char
|
||||
*dst_label, size_t dst_len);
|
||||
void build_cmd_dep(struct rproc *rp);
|
||||
int srv_fork(uid_t reuid, gid_t regid);
|
||||
int srv_kill(pid_t pid, int sig);
|
||||
int srv_update(endpoint_t src_e, endpoint_t dst_e);
|
||||
#define kill_service(rp, errstr, err) \
|
||||
kill_service_debug(__FILE__, __LINE__, rp, errstr, err)
|
||||
|
|
|
@ -123,12 +123,12 @@ int do_mapdriver(message *UNUSED(m_out))
|
|||
/* Only RS can map drivers. */
|
||||
if (who_e != RS_PROC_NR) return(EPERM);
|
||||
|
||||
label_vir = (vir_bytes) job_m_in.md_label;
|
||||
label_len = (size_t) job_m_in.md_label_len;
|
||||
major = job_m_in.md_major;
|
||||
label_vir = (vir_bytes) job_m_in.VFS_MAPDRIVER_LABEL;
|
||||
label_len = (size_t) job_m_in.VFS_MAPDRIVER_LABELLEN;
|
||||
major = job_m_in.VFS_MAPDRIVER_MAJOR;
|
||||
|
||||
/* Get the label */
|
||||
if (label_len+1 > sizeof(label)) { /* Can we store this label? */
|
||||
if (label_len > sizeof(label)) { /* Can we store this label? */
|
||||
printf("VFS: do_mapdriver: label too long\n");
|
||||
return(EINVAL);
|
||||
}
|
||||
|
@ -137,7 +137,10 @@ int do_mapdriver(message *UNUSED(m_out))
|
|||
printf("VFS: do_mapdriver: sys_vircopy failed: %d\n", r);
|
||||
return(EINVAL);
|
||||
}
|
||||
label[label_len] = '\0'; /* Terminate label */
|
||||
if (label[label_len-1] != '\0') {
|
||||
printf("VFS: do_mapdriver: label not null-terminated\n");
|
||||
return(EINVAL);
|
||||
}
|
||||
|
||||
/* Now we know how the driver is called, fetch its endpoint */
|
||||
r = ds_retrieve_label_endpt(label, &endpoint);
|
||||
|
|
|
@ -46,9 +46,6 @@
|
|||
#define whence m2_i2
|
||||
#define svrctl_req m2_i1
|
||||
#define svrctl_argp m2_p1
|
||||
#define md_label m2_p1
|
||||
#define md_label_len m2_l1
|
||||
#define md_major m2_i1
|
||||
|
||||
/* The following names are synonyms for the variables in the output message. */
|
||||
#define reply_type m_type
|
||||
|
|
|
@ -10,8 +10,8 @@ How the test works
|
|||
==================
|
||||
|
||||
`dstest` tests the new DS API (excluding ds_subscribe() and ds_check()).
|
||||
test_u32, test_str, test_mem, test_label, and test_map test U32, STR, MEM, LABEL
|
||||
and MAP type respectively.
|
||||
test_u32, test_str, test_mem, and test_label test U32, STR, MEM, and LABEL
|
||||
type respectively.
|
||||
|
||||
Invalid invokation is tested as well. Erroneous conditions are tested only once.
|
||||
For example, publishing an entry with same label name, but without
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
char *key_u32 = "test_u32";
|
||||
char *key_str = "test_str";
|
||||
char *key_mem = "test_mem";
|
||||
char *key_map = "test_map";
|
||||
char *key_label = "test_label";
|
||||
|
||||
/*===========================================================================*
|
||||
|
@ -128,10 +127,10 @@ void test_label(void)
|
|||
endpoint_t endpoint;
|
||||
|
||||
/* Retrieve own label and endpoint. */
|
||||
r = ds_retrieve_label_name(label, getprocnr());
|
||||
r = ds_retrieve_label_name(label, sef_self());
|
||||
assert(r == OK);
|
||||
r = ds_retrieve_label_endpt(label, &endpoint);
|
||||
assert(r == OK && endpoint == getprocnr());
|
||||
assert(r == OK && endpoint == sef_self());
|
||||
|
||||
/* Publish and delete. */
|
||||
r = ds_publish_label(label, endpoint, 0);
|
||||
|
@ -142,65 +141,6 @@ void test_label(void)
|
|||
printf("DSTEST: LABEL test successful!\n");
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* test_map *
|
||||
*===========================================================================*/
|
||||
void test_map(void)
|
||||
{
|
||||
char buf_buf[CLICK_SIZE * 2];
|
||||
char buf_buf2[CLICK_SIZE * 2];
|
||||
char *buf, *buf2;
|
||||
char get_buf[CLICK_SIZE];
|
||||
int *p;
|
||||
volatile int *p2;
|
||||
int *get_p;
|
||||
size_t get_len;
|
||||
int is;
|
||||
int r;
|
||||
|
||||
buf = (char*) CLICK_CEIL(buf_buf);
|
||||
buf2 = (char*) CLICK_CEIL(buf_buf2);
|
||||
|
||||
p = (int *)buf;
|
||||
p2 = (int *)buf2;
|
||||
get_p = (int *)get_buf;
|
||||
|
||||
*p = 1;
|
||||
r = ds_publish_map(key_map, buf, CLICK_SIZE, 0);
|
||||
assert(r == OK);
|
||||
|
||||
r = ds_snapshot_map(key_map, &is);
|
||||
assert(r == OK);
|
||||
|
||||
/* Copy the mapped memory range.
|
||||
* Set *p=2, then the mapped memory range should change too
|
||||
* and *get_p should be 2.
|
||||
*/
|
||||
*p = 2;
|
||||
get_len = CLICK_SIZE;
|
||||
r = ds_retrieve_map(key_map, get_buf, &get_len, 0, DSMF_COPY_MAPPED);
|
||||
assert(r == OK && get_len == CLICK_SIZE && *get_p == 2);
|
||||
|
||||
/* Copy snapshot, where *get_p should still be 1. */
|
||||
get_len = CLICK_SIZE;
|
||||
r = ds_retrieve_map(key_map, get_buf, &get_len, is, DSMF_COPY_SNAPSHOT);
|
||||
assert(r == OK && get_len == CLICK_SIZE && *get_p == 1);
|
||||
|
||||
/* Map the mapped memory range to @buf2, then set *p=3, which
|
||||
* in turn should let *p2=3.
|
||||
*/
|
||||
get_len = CLICK_SIZE;
|
||||
r = ds_retrieve_map(key_map, buf2, &get_len, 0, DSMF_MAP_MAPPED);
|
||||
assert(r == OK && get_len == CLICK_SIZE);
|
||||
*p = 3;
|
||||
assert(*p2 == 3);
|
||||
|
||||
r = ds_delete_map(key_map);
|
||||
assert(r == OK);
|
||||
|
||||
printf("DSTEST: MAP test successful!\n");
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* sef_cb_init_fresh *
|
||||
*===========================================================================*/
|
||||
|
@ -210,7 +150,6 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
|
|||
test_u32();
|
||||
test_str();
|
||||
test_mem();
|
||||
test_map();
|
||||
test_label();
|
||||
|
||||
return OK;
|
||||
|
|
|
@ -72,8 +72,6 @@ int main(void)
|
|||
if(r != OK)
|
||||
printf("error in ds_retrieve_mem.\n");
|
||||
break;
|
||||
case DSF_TYPE_MAP:
|
||||
break;
|
||||
default:
|
||||
printf("error in type! %d\n", type);
|
||||
}
|
||||
|
|
|
@ -32,13 +32,13 @@ int main(int argc, char **argv)
|
|||
|
||||
/* Get the requestor's endpoint. */
|
||||
read(fid_get, &ep_requestor, sizeof(ep_requestor));
|
||||
dprint("GRANTOR: getting requestor's endpoint: %d\n", ep_requestor);
|
||||
dprint(("GRANTOR: getting requestor's endpoint: %d\n", ep_requestor));
|
||||
|
||||
/* Grant. */
|
||||
gid = cpf_grant_direct(ep_requestor, (long)buf, BUF_SIZE,
|
||||
CPF_READ | CPF_WRITE);
|
||||
ep_self = getprocnr();
|
||||
dprint("GRANTOR: sending my endpoint %d and gid %d\n", ep_self, gid);
|
||||
ep_self = sef_self();
|
||||
dprint(("GRANTOR: sending my endpoint %d and gid %d\n", ep_self, gid));
|
||||
write(fid_send, &ep_self, sizeof(ep_self));
|
||||
write(fid_send, &gid, sizeof(gid));
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <minix/safecopies.h>
|
||||
#include <minix/syslib.h>
|
||||
#include <minix/sysutil.h>
|
||||
#include <minix/minlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* TEST_PAGE_SHIFT =
|
||||
|
@ -44,8 +45,8 @@
|
|||
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
# define dprint printf
|
||||
# define dprint(x) printf x
|
||||
#else
|
||||
# define dprint (void)
|
||||
# define dprint(x)
|
||||
#endif
|
||||
|
||||
|
|
|
@ -63,15 +63,15 @@ int main(int argc, char **argv)
|
|||
/* Sending the endpoint to the granter, in order to let him
|
||||
* create the grant.
|
||||
*/
|
||||
ep_self = getprocnr();
|
||||
ep_self = sef_self();
|
||||
write(fid_send, &ep_self, sizeof(ep_self));
|
||||
dprint("REQUESTOR: sending my endpoint: %d\n", ep_self);
|
||||
dprint(("REQUESTOR: sending my endpoint: %d\n", ep_self));
|
||||
|
||||
/* Getting the granter's endpoint and gid. */
|
||||
read(fid_get, &ep_granter, sizeof(ep_granter));
|
||||
read(fid_get, &gid, sizeof(gid));
|
||||
dprint("REQUESTOR: getting granter's endpoint %d and gid %d\n",
|
||||
ep_granter, gid);
|
||||
dprint(("REQUESTOR: getting granter's endpoint %d and gid %d\n",
|
||||
ep_granter, gid));
|
||||
|
||||
/* Test SAFECOPY. */
|
||||
for(i = 0; i <= TEST_PAGE_SHIFT; i++) {
|
||||
|
|
Loading…
Reference in a new issue