#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
+#include <sys/vm.h>
#include <minix/dmap.h>
#include <minix/ds.h>
#include <minix/endpoint.h>
rp->r_set_resources= 1; /* new style, enforece
* I/O resources
*/
-
+ if (sizeof(rp->r_vm) == sizeof(rs_start.rss_vm) &&
+ sizeof(rp->r_vm[0]) == sizeof(rs_start.rss_vm[0]))
+ {
+ memcpy(rp->r_vm, rs_start.rss_vm, sizeof(rp->r_vm));
+ }
+ else
+ {
+ printf("RS: do_start: internal inconsistency: bad size of r_vm\n");
+ memset(rp->r_vm, '\0', sizeof(rp->r_vm));
+ }
+
/* All information was gathered. Now try to start the system service. */
r = start_service(rp, 0, &ep);
m_ptr->RS_ENDPOINT = ep;
run_script(rp);
else {
start_service(rp, 0, &ep); /* direct restart */
- m_ptr->RS_ENDPOINT = ep;
+ if(m_ptr)
+ m_ptr->RS_ENDPOINT = ep;
}
}
else if (rp->r_flags & RS_EXECFAILED) {
else {
printf("RS: restarting %s\n", rp->r_cmd);
start_service(rp, 0, &ep); /* direct restart */
- m_ptr->RS_ENDPOINT = ep;
+ if(m_ptr)
+ m_ptr->RS_ENDPOINT = ep;
/* Do this even if no I/O happens with the ioctl, in
* order to disambiguate requests with DEV_IOCTL_S.
*/
char *file_only;
int s, use_copy, slot_nr;
struct priv *privp;
+ bitchunk_t *vm_mask;
message m;
+ char * null_env = NULL;
use_copy= (rp->r_exec != NULL);
cpf_reload(); /* Tell kernel about grant table */
if (!use_copy)
{
- execve(rp->r_argv[0], rp->r_argv, NULL); /* POSIX execute */
+ execve(rp->r_argv[0], rp->r_argv, &null_env); /* POSIX execute */
file_only = strrchr(rp->r_argv[0], '/') + 1;
- execve(file_only, rp->r_argv, NULL); /* POSIX execute */
+ execve(file_only, rp->r_argv, &null_env); /* POSIX execute */
}
printf("RS: exec failed for %s: %d\n", rp->r_argv[0], errno);
slot_nr= rp-rproc;
}
privp= NULL;
+ vm_mask = NULL;
if (rp->r_set_resources)
{
init_privs(rp, &rp->r_priv);
/* Inform the PCI server about the driver */
init_pci(rp, child_proc_nr_e);
+
+ vm_mask = &rp->r_vm[0];
}
/* Set the privilege structure for the child process to let is run.
return(s); /* return error */
}
+ if ((s = vm_set_priv(child_proc_nr_e, vm_mask)) < 0) {
+ report("RS", "vm_set_priv call failed", s);
+ rp->r_flags |= RS_EXITING;
+ if (child_pid > 0) kill(child_pid, SIGKILL);
+ else report("RS", "didn't kill pid", child_pid);
+ return (s);
+ }
+
s= ds_publish_u32(rp->r_label, child_proc_nr_e);
if (s != OK)
printf("RS: start_service: ds_publish_u32 failed: %d\n", s);
pid_t pid;
char *reason;
char incarnation_str[20]; /* Enough for a counter? */
+ char *envp[1] = { NULL };
if (rp->r_flags & RS_EXITING)
reason= "exit";
break;
case 0:
execle(rp->r_script, rp->r_script, rp->r_label, reason,
- incarnation_str, NULL, NULL);
+ incarnation_str, NULL, envp);
printf("RS: run_script: execl '%s' failed: %s\n",
rp->r_script, strerror(errno));
exit(1);
#include <errno.h>
#include <pwd.h>
#include <unistd.h>
+#include <limits.h>
#include <minix/config.h>
#include <minix/com.h>
#include <minix/const.h>
#include <minix/rs.h>
#include <minix/syslib.h>
#include <minix/sysinfo.h>
+#include <minix/bitmap.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <configfile.h>
#define KW_CLASS "class"
#define KW_SYSTEM "system"
#define KW_IPC "ipc"
+#define KW_VM "vm"
FORWARD void do_driver(config_t *cpe, config_t *config);
{ "VMCTL", SYS_VMCTL },
{ "PROFBUF", SYS_PROFBUF },
{ "SYSCTL", SYS_SYSCTL },
+ { "INT86", SYS_INT86 },
{ NULL, 0 }
};
req_ipc= list;
}
+struct
+{
+ char *label;
+ int call_nr;
+} vm_table[] =
+{
+ { "REMAP", VM_REMAP },
+ { "UNREMAP", VM_SHM_UNMAP },
+ { "GETPHYS", VM_GETPHYS },
+ { "GETREFCNT", VM_GETREF },
+ { "QUERYEXIT", VM_QUERY_EXIT },
+ { "CTL", VM_CTL },
+ { NULL, 0 },
+};
+
+PRIVATE void do_vm(config_t *cpe)
+{
+ int i;
+
+ for (; cpe; cpe = cpe->next)
+ {
+ if (cpe->flags & CFG_SUBLIST)
+ {
+ fatal("do_vm: unexpected sublist at %s:%d",
+ cpe->file, cpe->line);
+ }
+ if (cpe->flags & CFG_STRING)
+ {
+ fatal("do_vm: unexpected string at %s:%d",
+ cpe->file, cpe->line);
+ }
+
+ for (i = 0; vm_table[i].label != NULL; i++)
+ if (!strcmp(cpe->word, vm_table[i].label))
+ break;
+ if (vm_table[i].label == NULL)
+ fatal("do_vm: unknown call '%s' at %s:%d",
+ cpe->word, cpe->file, cpe->line);
+ SET_BIT(rs_start.rss_vm, vm_table[i].call_nr - VM_RQ_BASE);
+ }
+}
+
PRIVATE void do_system(config_t *cpe)
{
int i, call_nr, word, bits_per_word;
do_ipc(cpe->next);
continue;
}
+ if (strcmp(cpe->word, KW_VM) == 0)
+ {
+ do_vm(cpe->next);
+ continue;
+ }
}
}