if [ $# -gt 0 ]
then ARGS="-args $@"
fi
-/bin/service up /sbin/readclock.drv -config /etc/drivers.conf -script /etc/rs.single $ARGS
+/bin/service up /sbin/readclock.drv -config /etc/system.conf -script /etc/rs.single $ARGS
# Start our own driver.
service down $LABEL
sleep 10 # Allow driver to die
-service up $EXE -script `pwd`/rs.restart_imm -config /etc/drivers.conf -period 3HZ
+service up $EXE -script `pwd`/rs.restart_imm -config /etc/system.conf -period 3HZ
i=0
i=4000
# Start our own driver.
service down $LABEL
sleep 2 # Allow driver to die
-service up $EXE -script `pwd`/rs.restart_imm -config /etc/drivers.conf -period 3HZ $DEV
+service up $EXE -script `pwd`/rs.restart_imm -config /etc/system.conf -period 3HZ $DEV
i=0
while [ $i -lt "$count" ]
# Start our own driver.
service down $LABEL
sleep 10 # Allow driver to die
-service up $EXE -script `pwd`/rs.restart_imm -config /etc/drivers.conf -period 3HZ
+service up $EXE -script `pwd`/rs.restart_imm -config /etc/system.conf -period 3HZ
i=0
while [ $i -lt "$count" ]
-
+20091212:
+ /etc/drivers.conf has been renamed to /etc/system.conf.
+ user "service" has been added to password file /etc/passwd.
20060818:
You need flex in your $PATH, which has become part of the base
system. This needs bigger binaries.
PROGRAMS=at_wini bios_wini cdprobe dev2name floppy loadramdisk newroot \
pci sh service sysenv mfs
-EXTRA=drivers.conf passwd
+EXTRA=system.conf passwd
MAKEDEV=/usr/bin/MAKEDEV
../../../servers/mfs/mfs:
cd ../../../servers/mfs && make
-drivers.conf: ../../../etc/drivers.conf
+system.conf: ../../../etc/system.conf
install -s ../../../etc/$@ $@
passwd: ../../../etc/passwd
@DEV@
$
etc d--755 0 0
- drivers.conf ---644 0 0 drivers.conf
+ system.conf ---644 0 0 system.conf
mtab ---644 0 0 mtab
passwd ---644 0 0 passwd
rc ---755 0 0 rc
exec 2>/dev/log
exec </dev/null
-/bin/service up /bin/pci -config /etc/drivers.conf
-/bin/service -c up /bin/floppy -config /etc/drivers.conf -dev /dev/fd0
+/bin/service up /bin/pci -config /etc/system.conf
+/bin/service -c up /bin/floppy -config /etc/system.conf -dev /dev/fd0
if [ X`/bin/sysenv bios_wini` = Xyes ]
then
echo Using bios_wini.
/bin/service -c up /bin/bios_wini -dev /dev/c0d0
else
- /bin/service -c up /bin/at_wini -dev /dev/c0d0 -config /etc/drivers.conf -label at_wini_0
- /bin/service -c up /bin/at_wini -dev /dev/c1d0 -config /etc/drivers.conf -label at_wini_1 -args ata_instance=1
+ /bin/service -c up /bin/at_wini -dev /dev/c0d0 -config /etc/system.conf -label at_wini_0
+ /bin/service -c up /bin/at_wini -dev /dev/c1d0 -config /etc/system.conf -label at_wini_1 -args ata_instance=1
fi
rootdev=`sysenv rootdev` || echo 'No rootdev?'
/usr/src/commands/dhcpd/devices.c
(see the docs directory for more information)
Furthermore, the script will patch 1 configuration file:
- /etc/drivers.conf
+ /etc/system.conf
(adding an entry for 'orinoco')
and 1 script file:
/usr/etc/rc
FILES1=fstab group hostname.file inet.conf motd.install mtab passwd profile \
protocols rc services termcap ttytab utmp rc.cd binary_sizes \
binary_sizes.big binary_sizes.xxl rc.rescue syslog.conf \
- rc.daemons.dist rs.inet rs.single make.conf drivers.conf
+ rc.daemons.dist rs.inet rs.single make.conf system.conf
FILES2=shadow
FILES3=daily dhcptags.conf rc
www:*:9:9:World Wide Web:/usr/www:
driver:*:10:10:Device Drivers:/:
server:*:11:11:OS Servers:/:
+service:*:12:12:System Services:/:
sshd:*:22:22:sshd:/:
smtpd:*:25:25:smtpd:/:
games:*:9998:98::/:
-driver floppy
+service floppy
{
irq 6;
io 3f0:8
SAFECOPYFROM # 31
SAFECOPYTO # 32
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
};
-driver dp8390
+service dp8390
{
system
IRQCTL # 19
DEVIO # 21
SDEVIO # 22
SETALARM # 24
+ TIMES # 25
GETINFO # 26
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
pci device 10ec/8029;
uid 0;
};
-driver dpeth
+service dpeth
{
system
IRQCTL # 19
DEVIO # 21
SDEVIO # 22
SETALARM # 24
+ TIMES # 25
GETINFO # 26
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
uid 0;
};
-driver lance
+service lance
{
system
UMAP # 14
SAFECOPYTO # 32
SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
pci device 1022/2000;
uid 0;
};
-driver rtl8139
+service rtl8139
{
system
UMAP # 14
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
- MAPDMA # 41
PROFBUF # 38
- SYSCTL
+ MAPDMA # 41
+ SYSCTL # 44
;
pci device 10ec/8139;
pci device 02ac/1012;
;
};
-driver fxp
+service fxp
{
system
UMAP # 14
SAFECOPYTO # 32
SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
pci device 8086/103d;
pci device 8086/1064;
;
};
-driver dumpcore
+service dumpcore
{
system
TRACE # 5
VIRCOPY # 15
+ TIMES # 25
GETINFO # 26
SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
};
-driver inet
+service inet
{
system
SETALARM # 24
VSAFECOPY # 33
SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
uid 0;
};
-driver random
+service random
{
system
UMAP # 14
SETALARM # 24
+ TIMES # 25
GETINFO # 26
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
};
-driver readclock.drv
+service readclock.drv
{
io 70:2;
system
DEVIO # 21
TIMES # 25
GETINFO # 26
+ SAFECOPYFROM # 31
SAFECOPYTO # 32
- SAFECOPYFROM # 32
SETGRANT # 34
READBIOS # 35
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
uid 0;
};
-driver is
+service is
{
system
TIMES # 25
GETINFO # 26
SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
vm
CTL
uid 0;
};
-driver pci
+service pci
{
io cf8:8 # PCI bus controller
4d0:2 # PIIX
system
PRIVCTL # 4
DEVIO # 21
+ TIMES # 25
GETINFO # 26
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
uid 0;
};
-driver at_wini
+service at_wini
{
io 1f0:8 # Controller 0
3f6 # Also controller 0
SETGRANT # 34
READBIOS # 35
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
pci class
1/1 # Mass storage / IDE
;
};
-driver bios_wini
+service bios_wini
{
system
UMAP # 14
+ INT86 # 20
SETALARM # 24
TIMES # 25
GETINFO # 26
SETGRANT # 34
READBIOS # 35
PROFBUF # 38
- SYSCTL
- INT86
+ SYSCTL # 44
;
};
-driver mfs
+service mfs
{
system
TIMES # 25
+ GETINFO # 26
SAFECOPYFROM # 31
SAFECOPYTO # 32
- GETINFO
SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
uid 0;
};
-driver isofs
+service isofs
{
system
+ UMAP # 14
TIMES # 25
+ GETINFO # 26
SAFECOPYFROM # 31
SAFECOPYTO # 32
- GETINFO
SETGRANT # 34
- UMAP # 14
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
uid 0;
};
-driver printer
+service printer
{
io 378:4 # LPT1
278:4 # LPT2
7 # PRINTER_IRQ
;
system
- KILL # 6
- SETGRANT # 34
- UMAP # 14
- VIRCOPY # 15
- IRQCTL # 19
- DEVIO # 21
- VDEVIO # 23
- GETINFO # 26
- SAFECOPYFROM # 31
- SAFECOPYTO # 32
+ KILL # 6
+ UMAP # 14
+ VIRCOPY # 15
+ IRQCTL # 19
+ DEVIO # 21
+ VDEVIO # 23
+ TIMES # 25
+ GETINFO # 26
+ SAFECOPYFROM # 31
+ SAFECOPYTO # 32
+ SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
};
-driver orinoco
+service orinoco
{
system
PRIVCTL # 4
- DEVIO # 21
- GETINFO # 26
UMAP # 14
IRQCTL # 19
DEVIO # 21
SETALARM # 24
TIMES # 25
GETINFO # 26
+ VM_MAP # 30
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
- VM_MAP # 30
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
pci device 1260/3873;
pci device 1186/1300;
uid 0;
};
-driver es1370
+service es1370
{
system
- SAFECOPYFROM
- SAFECOPYTO
- UMAP
- GETINFO
- SETGRANT
+ UMAP # 14
IRQCTL # 19
DEVIO # 21
+ TIMES # 25
+ GETINFO # 26
+ SAFECOPYFROM # 31
+ SAFECOPYTO # 32
+ SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
pci device 1274/5000;
};
-driver es1371
+service es1371
{
system
SAFECOPYFROM
SAFECOPYTO
UMAP
SETGRANT
+ TIMES # 25
GETINFO
IRQCTL # 19
DEVIO # 21
pci device 1274/1371;
};
-driver amddev
+service amddev
{
pci device 1022/1103;
system
UMAP # 14
+ TIMES # 25
+ GETINFO # 26
SETGRANT # 34
- GETINFO
- REGDEV # 40
PROFBUF # 38
- SYSCTL
+ REGDEV # 40
+ SYSCTL # 44
;
uid 0;
};
-driver ipc
+service ipc
{
system
- UMAP
- PROFBUF
- SAFECOPYFROM
- SAFECOPYTO
- VIRCOPY
- SETGRANT
- SYSCTL
+ UMAP # 14
+ VIRCOPY # 15
+ TIMES # 25
+ GETINFO # 26
+ SAFECOPYFROM # 31
+ SAFECOPYTO # 32
+ SETGRANT # 34
+ PROFBUF # 38
+ SYSCTL # 44
;
uid 0;
ipc
;
};
-driver osscore
+service osscore
{
system
PRIVCTL # 4
- DEVIO # 21
UMAP # 14
IRQCTL # 19
DEVIO # 21
SAFECOPYTO # 32
SETGRANT # 34
PROFBUF # 38
- SYSCTL
+ SYSCTL # 44
;
pci class
4/1 # Multimedia / Audio device
uid 0;
};
-driver rtl8169
+service rtl8169
{
system
UMAP # 14
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
- MAPDMA # 41
PROFBUF # 38
- SYSCTL
+ MAPDMA # 41
+ SYSCTL # 44
;
pci device 10ec/8129;
pci device 10ec/8167;
;
};
-driver filter
+service filter
{
system
SETALARM # 24
;
};
-driver e1000
+service e1000
{
system
UMAP # 14
SAFECOPYFROM # 31
SAFECOPYTO # 32
SETGRANT # 34
- SYSCTL
+ SYSCTL # 44
;
pci device 8086/100e;
pci device 8086/107c;
#define PM_PROC_NR 0 /* process manager */
#define FS_PROC_NR 1 /* file system */
#define VFS_PROC_NR FS_PROC_NR /* FS has been renamed to VFS. */
-#define RS_PROC_NR 2 /* memory driver (RAM disk, null, etc.) */
+#define RS_PROC_NR 2 /* reincarnation server */
#define MEM_PROC_NR 3 /* memory driver (RAM disk, null, etc.) */
#define LOG_PROC_NR 4 /* log device driver */
#define TTY_PROC_NR 5 /* terminal (TTY) driver */
#define RS_DOWN (RS_RQ_BASE + 1) /* stop system service */
#define RS_REFRESH (RS_RQ_BASE + 2) /* refresh system service */
#define RS_RESTART (RS_RQ_BASE + 3) /* restart system service */
-#define RS_SHUTDOWN (RS_RQ_BASE + 5) /* alert about shutdown */
-#define RS_UP_COPY (RS_RQ_BASE + 6) /* start system service and
- * keep the binary in memory
- */
-#define RS_START (RS_RQ_BASE + 7) /* start a driver/service
- * arguments are passed in
- * a struct rs_start
- */
+#define RS_SHUTDOWN (RS_RQ_BASE + 4) /* alert about shutdown */
+
#define RS_LOOKUP (RS_RQ_BASE + 8) /* lookup server name */
# define RS_CMD_ADDR m1_p1 /* command string */
#define _PATH_BSHELL "/bin/sh"
#define _PATH_SERVICE "/bin/service"
-#define _PATH_DRIVERS_CONF "/etc/drivers.conf"
+#define _PATH_SYSTEM_CONF "/etc/system.conf"
#endif
}
if(strlen(_PATH_SERVICE)+strlen(path)+strlen(label)+
- strlen(_PATH_DRIVERS_CONF)+strlen(args)+50 >= sizeof(cmd)) {
+ strlen(_PATH_SYSTEM_CONF)+strlen(args)+50 >= sizeof(cmd)) {
errno = E2BIG;
return -1;
}
- sprintf(cmd, _PATH_SERVICE " %sup %s -label '%s' -config " _PATH_DRIVERS_CONF
+ sprintf(cmd, _PATH_SERVICE " %sup %s -label '%s' -config " _PATH_SYSTEM_CONF
" -args '%s%s' -printep yes",
reuse ? "-r ": "", path, label, args[0] ? "-o " : "", args);
/* Space reserved for program and arguments. */
#define MAX_COMMAND_LEN 512 /* maximum argument string length */
#define MAX_LABEL_LEN 16 /* Unique name of (this instance of)
- * the driver
+ * the service
*/
#define MAX_SCRIPT_LEN 256 /* maximum restart script name length */
#define MAX_NR_ARGS 4 /* maximum number of arguments */
#define RS_IN_USE 0x001 /* set when process slot is in use */
#define RS_EXITING 0x004 /* set when exit is expected */
#define RS_REFRESHING 0x008 /* set when refresh must be done */
-#define RS_NOPINGREPLY 0x010 /* driver failed to reply to a ping request */
-#define RS_KILLED 0x020 /* driver is killed */
-#define RS_CRASHED 0x040 /* driver crashed */
+#define RS_NOPINGREPLY 0x010 /* service failed to reply to a ping request */
+#define RS_KILLED 0x020 /* service is killed */
+#define RS_CRASHED 0x040 /* service crashed */
#define RS_LATEREPLY 0x080 /* no reply sent to RS_DOWN caller yet */
-#define RS_SIGNALED 0x100 /* driver crashed */
+#define RS_SIGNALED 0x100 /* service crashed */
/* Sys flag values. */
#define SF_CORE_PROC 0x001 /* set for core system processes
if (is_notify(m.m_type)) {
switch (who_p) {
case CLOCK:
- do_period(&m); /* check drivers status */
+ do_period(&m); /* check services status */
continue;
case PM_PROC_NR:
sig_handler();
/* Handler functions are responsible for permission checking. */
switch(call_nr) {
- case RS_UP: result = do_up(&m, FALSE, 0); break;
- case RS_UP_COPY: result = do_up(&m, TRUE, 0); break;
- case RS_START: result = do_start(&m); break;
+ case RS_UP: result = do_up(&m); break;
case RS_DOWN: result = do_down(&m); break;
case RS_REFRESH: result = do_refresh(&m); break;
case RS_RESTART: result = do_restart(&m); break;
rp->r_dev_nr = boot_image_dev->dev_nr; /* major device number */
rp->r_dev_style = boot_image_dev->dev_style; /* device style */
rp->r_period = boot_image_dev->period; /* heartbeat period */
+
+ /* Get label. */
+ strcpy(rp->r_label, ip->proc_name);
+
+ /* Get command settings. */
+ rp->r_cmd[0]= '\0';
+ rp->r_argv[0] = rp->r_cmd;
+ rp->r_argv[1] = NULL;
+ rp->r_argc = 1;
+ rp->r_script[0]= '\0';
+
+ /* Get some settings from the boot image table. */
+ rp->r_nice = ip->priority;
+ rp->r_proc_nr_e = ip->endpoint;
+
+ /* Set some defaults. */
+ rp->r_uid = 0; /* root */
+ rp->r_check_tm = 0; /* not checked yet */
+ getuptime(&rp->r_alive_tm); /* currently alive */
+ rp->r_stop_tm = 0; /* not exiting yet */
+ rp->r_restarts = 0; /* no restarts so far */
+ rp->r_set_resources = 0; /* don't set resources */
+
+ /* Mark as in use. */
+ rp->r_flags = RS_IN_USE;
+ rproc_ptr[_ENDPOINT_P(rp->r_proc_nr_e)]= rp;
}
/* - Step 2: allow every system service in the boot image to run.
}
}
- /* - Step 3: all the system services in the boot image are now running. Use
- * the boot image table from the kernel and PM process table to complete
- * the initialization of the system process table.
+ /* - Step 3: all the system services in the boot image are now running.
+ * Complete the initialization of the system process table in collaboration
+ * with other system processes.
*/
if ((s = getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc)) != OK) {
panic("RS", "unable to get copy of PM process table", s);
continue;
}
- /* Lookup the corresponding entry in the boot image table. */
- boot_image_info_lookup(boot_image_priv->endpoint, image,
- &ip, NULL, NULL, NULL);
+ /* Lookup the corresponding slot in the system process table. */
rp = &rproc[boot_image_priv - boot_image_priv_table];
- /* Get label. */
- strcpy(rp->r_label, ip->proc_name);
-
- /* Get command settings. */
- rp->r_cmd[0]= '\0';
- rp->r_argv[0] = rp->r_cmd;
- rp->r_argv[1] = NULL;
- rp->r_argc = 1;
- rp->r_script[0]= '\0';
-
- /* Get settings from the boot image table. */
- rp->r_nice = ip->priority;
- rp->r_proc_nr_e = ip->endpoint;
-
/* Get pid from PM process table. */
rp->r_pid = NO_PID;
for (j = 0; j < NR_PROCS; j++) {
panic("RS", "unable to get pid", NO_NUM);
}
- /* Set some defaults. */
- rp->r_uid = 0; /* root */
- rp->r_check_tm = 0; /* not checked yet */
- getuptime(&rp->r_alive_tm); /* currently alive */
- rp->r_stop_tm = 0; /* not exiting yet */
- rp->r_restarts = 0; /* no restarts so far */
- rp->r_set_resources = 0; /* no resources */
-
- /* Mark as in use. */
- rp->r_flags = RS_IN_USE;
- rproc_ptr[_ENDPOINT_P(rp->r_proc_nr_e)]= rp;
-
- /* Publish the new system service. */
+ /* Publish the new system service.
+ * XXX FIXME. Possible race condition. We should publish labels before
+ * allowing other processes to run.
+ */
s = publish_service(rp);
if (s != OK) {
panic("RS", "unable to publish boot system service", s);
dst_label[len] = 0;
if (rs_verbose)
- printf("RS: do_start: using label (custom) '%s'\n", dst_label);
+ printf("RS: copy_label: using label (custom) '%s'\n", dst_label);
return OK;
}
/*===========================================================================*
- * do_up *
+ * do_up *
*===========================================================================*/
-PUBLIC int do_up(m_ptr, do_copy, flags)
-message *m_ptr; /* request message pointer */
-int do_copy; /* keep copy in memory */
-int flags; /* extra flags, if any */
-{
-/* A request was made to start a new system service. Dismember the request
- * message and gather all information needed to start the service. Starting
- * is done by a helper routine.
- */
- register struct rproc *rp; /* system process table */
- int slot_nr; /* local table entry */
- int arg_count; /* number of arguments */
- char *cmd_ptr; /* parse command string */
- char *label; /* unique name of command */
- enum dev_style dev_style; /* device style */
- int s; /* status variable */
- int len; /* length of string */
- int r;
- endpoint_t ep; /* new endpoint no. */
-
- /* This call requires special privileges. */
- if (!caller_is_root(m_ptr->m_source)) return(EPERM);
-
- /* See if there is a free entry in the table with system processes. */
- for (slot_nr = 0; slot_nr < NR_SYS_PROCS; slot_nr++) {
- rp = &rproc[slot_nr]; /* get pointer to slot */
- if (! rp->r_flags & RS_IN_USE) /* check if available */
- break;
- }
-
- /* Obtain command name and parameters. This is a space-separated string
- * that looks like "/sbin/service arg1 arg2 ...". Arguments are optional.
- */
- if (m_ptr->RS_CMD_LEN > MAX_COMMAND_LEN) return(E2BIG);
- if (OK!=(s=sys_datacopy(m_ptr->m_source, (vir_bytes) m_ptr->RS_CMD_ADDR,
- SELF, (vir_bytes) rp->r_cmd, m_ptr->RS_CMD_LEN))) return(s);
- rp->r_cmd[m_ptr->RS_CMD_LEN] = '\0'; /* ensure it is terminated */
- if (rp->r_cmd[0] != '/') return(EINVAL); /* insist on absolute path */
-
- rp->r_script[0]= '\0';
-
- /* Build argument vector to be passed to execute call. The format of the
- * arguments vector is: path, arguments, NULL.
- */
- arg_count = 0; /* initialize arg count */
- rp->r_argv[arg_count++] = rp->r_cmd; /* start with path */
- cmd_ptr = rp->r_cmd; /* do some parsing */
- while(*cmd_ptr != '\0') { /* stop at end of string */
- if (*cmd_ptr == ' ') { /* next argument */
- *cmd_ptr = '\0'; /* terminate previous */
- while (*++cmd_ptr == ' ') ; /* skip spaces */
- if (*cmd_ptr == '\0') break; /* no arg following */
- if (arg_count>MAX_NR_ARGS+1) break; /* arg vector full */
- rp->r_argv[arg_count++] = cmd_ptr; /* add to arg vector */
- }
- cmd_ptr ++; /* continue parsing */
- }
- rp->r_argv[arg_count] = NULL; /* end with NULL pointer */
- rp->r_argc = arg_count;
-
- /* Default label for the driver */
- label= strrchr(rp->r_argv[0], '/');
- if (label)
- label++;
- else
- label= rp->r_argv[0];
- len= strlen(label);
- if (len > MAX_LABEL_LEN-1)
- len= MAX_LABEL_LEN-1; /* truncate name */
- memcpy(rp->r_label, label, len);
- rp->r_label[len]= '\0';
- if(rs_verbose) printf("RS: do_up: using label '%s'\n", rp->r_label);
-
- rp->r_uid= 0;
- rp->r_nice= 0;
-
- rp->r_sys_flags = DSRV_SF;
- rp->r_exec= NULL;
-
- if (do_copy)
- {
- s= read_exec(rp);
- if (s != OK)
- return s;
-
- rp->r_sys_flags |= SF_USE_COPY;
- }
-
- /* Initialize some fields. */
- rp->r_period = m_ptr->RS_PERIOD;
- rp->r_dev_nr = m_ptr->RS_DEV_MAJOR;
- rp->r_dev_style = STYLE_DEV;
- rp->r_restarts = -1; /* will be incremented */
- rp->r_set_resources= 0; /* old style */
-
- /* All information was gathered. Now try to start the system service. */
-
- r = start_service(rp, flags, &ep);
- m_ptr->RS_ENDPOINT = ep;
- return r;
-}
-
-
-/*===========================================================================*
- * do_start *
- *===========================================================================*/
-PUBLIC int do_start(m_ptr)
+PUBLIC int do_up(m_ptr)
message *m_ptr; /* request message pointer */
{
/* A request was made to start a new system service.
}
if (slot_nr >= NR_SYS_PROCS)
{
- printf("rs`do_start: driver table full\n");
+ printf("RS: do_up: system process table full\n");
return ENOMEM;
}
rp->r_argc = arg_count;
if(rs_start.rss_label.l_len > 0) {
- /* RS_START caller has supplied a custom label for this driver. */
+ /* RS_UP caller has supplied a custom label for this service. */
int s = copy_label(m_ptr->m_source, &rs_start.rss_label,
rp->r_label, sizeof(rp->r_label));
if(s != OK)
return s;
if(rs_verbose)
- printf("RS: do_start: using label (custom) '%s'\n", rp->r_label);
+ printf("RS: do_up: using label (custom) '%s'\n", rp->r_label);
} else {
- /* Default label for the driver. */
+ /* Default label for the service. */
label= strrchr(rp->r_argv[0], '/');
if (label)
label++;
memcpy(rp->r_label, label, len);
rp->r_label[len]= '\0';
if(rs_verbose)
- printf("RS: do_start: using label (from binary %s) '%s'\n",
+ printf("RS: do_up: using label (from binary %s) '%s'\n",
rp->r_argv[0], rp->r_label);
}
int i, s;
if (rs_start.rss_nr_control > RSS_NR_CONTROL)
{
- printf("RS: do_start: too many control labels\n");
+ printf("RS: do_up: too many control labels\n");
return EINVAL;
}
for (i=0; i<rs_start.rss_nr_control; i++) {
rp->r_nr_control = rs_start.rss_nr_control;
if (rs_verbose) {
- printf("RS: do_start: control labels:");
+ printf("RS: do_up: control labels:");
for (i=0; i<rp->r_nr_control; i++)
printf(" %s", rp->r_control[i]);
printf("\n");
/* Copy granted resources */
if (rs_start.rss_nr_irq > NR_IRQ)
{
- printf("RS: do_start: too many IRQs requested\n");
+ printf("RS: do_up: too many IRQs requested\n");
return EINVAL;
}
rp->r_priv.s_nr_irq= rs_start.rss_nr_irq;
{
rp->r_priv.s_irq_tab[i]= rs_start.rss_irq[i];
if(rs_verbose)
- printf("RS: do_start: IRQ %d\n", rp->r_priv.s_irq_tab[i]);
+ printf("RS: do_up: IRQ %d\n", rp->r_priv.s_irq_tab[i]);
}
if (rs_start.rss_nr_io > NR_IO_RANGE)
{
- printf("RS: do_start: too many I/O ranges requested\n");
+ printf("RS: do_up: too many I/O ranges requested\n");
return EINVAL;
}
rp->r_priv.s_nr_io_range= rs_start.rss_nr_io;
rp->r_priv.s_io_tab[i].ior_limit=
rs_start.rss_io[i].base+rs_start.rss_io[i].len-1;
if(rs_verbose)
- printf("RS: do_start: I/O [%x..%x]\n",
+ printf("RS: do_up: I/O [%x..%x]\n",
rp->r_priv.s_io_tab[i].ior_base,
rp->r_priv.s_io_tab[i].ior_limit);
}
if (rs_start.rss_nr_pci_id > RSS_NR_PCI_ID)
{
- printf("RS: do_start: too many PCI device IDs\n");
+ printf("RS: do_up: too many PCI device IDs\n");
return EINVAL;
}
rp->r_nr_pci_id= rs_start.rss_nr_pci_id;
rp->r_pci_id[i].vid= rs_start.rss_pci_id[i].vid;
rp->r_pci_id[i].did= rs_start.rss_pci_id[i].did;
if(rs_verbose)
- printf("RS: do_start: PCI %04x/%04x\n",
+ printf("RS: do_up: PCI %04x/%04x\n",
rp->r_pci_id[i].vid, rp->r_pci_id[i].did);
}
if (rs_start.rss_nr_pci_class > RSS_NR_PCI_CLASS)
{
- printf("RS: do_start: too many PCI class IDs\n");
+ printf("RS: do_up: too many PCI class IDs\n");
return EINVAL;
}
rp->r_nr_pci_class= rs_start.rss_nr_pci_class;
rp->r_pci_class[i].class= rs_start.rss_pci_class[i].class;
rp->r_pci_class[i].mask= rs_start.rss_pci_class[i].mask;
if(rs_verbose)
- printf("RS: do_start: PCI class %06x mask %06x\n",
+ printf("RS: do_up: PCI class %06x mask %06x\n",
rp->r_pci_class[i].class, rp->r_pci_class[i].mask);
}
else
{
printf(
- "RS: do_start: internal inconsistency: bad size of r_call_mask\n");
+ "RS: do_up: internal inconsistency: bad size of r_call_mask\n");
memset(rp->r_call_mask, '\0', sizeof(rp->r_call_mask));
}
rp->r_dev_nr = rs_start.rss_major;
rp->r_dev_style = STYLE_DEV;
rp->r_restarts = -1; /* will be incremented */
- rp->r_set_resources= 1; /* new style, enforce
- * I/O resources
- */
+ rp->r_set_resources= 1; /* set resources */
+
if (sizeof(rp->r_vm) == sizeof(rs_start.rss_vm) &&
sizeof(rp->r_vm[0]) == sizeof(rs_start.rss_vm[0]))
{
}
else
{
- printf("RS: do_start: internal inconsistency: bad size of r_vm\n");
+ printf("RS: do_up: internal inconsistency: bad size of r_vm\n");
memset(rp->r_vm, '\0', sizeof(rp->r_vm));
}
rproc_ptr[proc] = NULL; /* invalidate */
rp->r_pid= -1;
- pci_del_acl(rp->r_proc_nr_e); /* Ignore errors */
+ /* If PCI properties are set, inform the PCI driver. */
+ if(rp->r_nr_pci_id || rp->r_nr_pci_class) {
+ pci_del_acl(rp->r_proc_nr_e);
+ }
if ((rp->r_flags & RS_EXITING) || shutting_down) {
/* No reply sent to RS_DOWN yet. */
else if (rp->r_period > 0) {
/* Check if an answer to a status request is still pending. If
- * the driver didn't respond within time, kill it to simulate
+ * the service didn't respond within time, kill it to simulate
* a crash. The failure will be detected and the service will
* be restarted automatically.
*/
pid_t child_pid; /* child's process id */
char *file_only;
int s, use_copy, slot_nr;
- struct priv *privp;
bitchunk_t *vm_mask;
message m;
char * null_env = NULL;
}
}
- privp= NULL;
- vm_mask = NULL;
+ /* Set resources when asked to. */
if (rp->r_set_resources)
{
+ /* Initialize privilege structure. */
init_privs(rp, &rp->r_priv);
- privp= &rp->r_priv;
-
- /* Inform the PCI server about the driver */
- init_pci(rp, child_proc_nr_e);
+ /* Tell VM about allowed calls. */
vm_mask = &rp->r_vm[0];
+ if ((s = vm_set_priv(child_proc_nr_e, vm_mask)) < 0) {
+ report("RS", "vm_set_priv call failed", s);
+ kill(child_pid, SIGKILL);
+ rp->r_flags |= RS_EXITING;
+ return (s);
+ }
}
- /* Tell VM about allowed calls, before actually letting the process run. */
- if ((s = vm_set_priv(child_proc_nr_e, vm_mask)) < 0) {
- report("RS", "vm_set_priv call failed", s);
- kill(child_pid, SIGKILL);
- rp->r_flags |= RS_EXITING;
- return (s);
- }
-
- /* Set the privilege structure for the child process.
- * That will also cause the child process to start running.
- * This call should succeed: we tested number in use above.
- */
- if ((s = set_privs(child_proc_nr_e, privp, SYS_PRIV_SET_SYS)) != OK) {
- report("RS","set_privs failed", s);
- kill(child_pid, SIGKILL); /* kill driver */
- rp->r_flags |= RS_EXITING; /* expect exit */
- return(s); /* return error */
+ /* If PCI properties are set, inform the PCI driver about the new service. */
+ if(rp->r_nr_pci_id || rp->r_nr_pci_class) {
+ init_pci(rp, child_proc_nr_e);
}
/* The purpose of non-blocking forks is to avoid involving VFS in the forking
if ((s=mapdriver5(rp->r_label, strlen(rp->r_label),
rp->r_dev_nr, rp->r_dev_style, !!use_copy /* force */)) < 0) {
report("RS", "couldn't map driver (continuing)", errno);
-#if 0
- kill(child_pid, SIGKILL); /* kill driver */
- rp->r_flags |= RS_EXITING; /* expect exit */
- return(s); /* return error */
-#endif
}
}
+ /* Set the privilege structure for the child process.
+ * That will also cause the child process to start running.
+ * This call should succeed: we tested number in use above.
+ */
+ if ((s = set_privs(child_proc_nr_e, &rp->r_priv, SYS_PRIV_SET_SYS)) != OK) {
+ report("RS","set_privs failed", s);
+ kill(child_pid, SIGKILL); /* kill the service */
+ rp->r_flags |= RS_EXITING; /* expect exit */
+ return(s); /* return error */
+ }
+
if(rs_verbose)
printf("RS: started '%s', major %d, pid %d, endpoint %d, proc %d\n",
rp->r_cmd, rp->r_dev_nr, child_pid,
struct rproc *rp;
int endpoint;
{
- /* Tell the PCI driver about the new driver */
+ /* Inform the PCI driver about the new service. */
size_t len;
int i, r;
struct rs_pci rs_pci;
_PROTOTYPE( int main, (void));
/* manager.c */
-_PROTOTYPE( int do_up, (message *m, int do_copy, int flags));
-_PROTOTYPE( int do_start, (message *m));
+_PROTOTYPE( int do_up, (message *m));
_PROTOTYPE( int do_down, (message *m));
_PROTOTYPE( int do_refresh, (message *m));
_PROTOTYPE( int do_restart, (message *m));
"down",
"refresh",
"restart",
- "-unused",
"shutdown",
- "upcopy", /* fill for RS_UP_COPY */
"catch for illegal requests"
};
#define ILLEGAL_REQUEST sizeof(known_requests)/sizeof(char *)
#define RUN_CMD "run"
#define RUN_SCRIPT "/etc/rs.single" /* Default script for 'run' */
-#define PATH_CONFIG _PATH_DRIVERS_CONF /* Default config file */
+#define PATH_CONFIG _PATH_SYSTEM_CONF /* Default config file */
/* Define names for arguments provided to this utility. The first few
* arguments are required and have a known index. Thereafter, some optional
#define ARG_DEV "-dev" /* major device number for drivers */
#define ARG_PERIOD "-period" /* heartbeat period in ticks */
#define ARG_SCRIPT "-script" /* name of the script to restart a
- * driver
+ * system service
*/
#define ARG_LABELNAME "-label" /* custom label name */
#define ARG_CONFIG "-config" /* name of the file with the resource
*/
#define ARG_PRINTEP "-printep" /* print endpoint number after start */
-#define DRIVER_LOGIN "driver" /* Passwd file entry for drivers */
+#define SERVICE_LOGIN "service" /* passwd file entry for services */
#define MAX_CLASS_RECURS 100 /* Max nesting level for classes */
}
if (req_nr == RS_UP) {
- req_nr= RS_START;
-
rs_start.rss_flags= RF_IPC_VALID;
if (c_flag)
rs_start.rss_flags |= RF_COPY;
{
/* Set default recovery script for RUN */
req_script = RUN_SCRIPT;
- req_nr = RS_START;
}
-#if 0
- if (req_nr == RS_UP && c_flag)
- req_nr= RS_UP_COPY;
-#endif
-
/* Verify argument count. */
if (argc - 1 < optind+ARG_PATH) {
print_usage(argv[ARG_NAME], "action requires a binary to start");
}
else if (strcmp(argv[i], ARG_SCRIPT)==0) {
req_script = argv[i+1];
- req_nr = RS_START;
}
else if (strcmp(argv[i], ARG_LABELNAME)==0) {
req_label = argv[i+1];
- req_nr = RS_START;
}
else if (strcmp(argv[i], ARG_CONFIG)==0) {
req_config = argv[i+1];
- req_nr = RS_START;
}
else if (strcmp(argv[i], ARG_PRINTEP)==0) {
req_printep = 1;
exit(1);
}
-#define KW_DRIVER "driver"
+#define KW_SERVICE "service"
#define KW_UID "uid"
#define KW_NICE "nice"
#define KW_IRQ "irq"
#define KW_VM "vm"
#define KW_CONTROL "control"
-FORWARD void do_driver(config_t *cpe, config_t *config);
+FORWARD void do_service(config_t *cpe, config_t *config);
PRIVATE void do_class(config_t *cpe, config_t *config)
{
cp1->file, cp1->line);
}
- /* At this place we expect the word 'driver' */
- if (strcmp(cp1->word, KW_DRIVER) != 0)
+ /* At this place we expect the word KW_SERVICE */
+ if (strcmp(cp1->word, KW_SERVICE) != 0)
fatal("do_class: exected word '%S' at %s:%d",
- KW_DRIVER, cp1->file, cp1->line);
+ KW_SERVICE, cp1->file, cp1->line);
cp1= cp1->next;
if ((cp1->flags & CFG_STRING) ||
cp1->file, cp1->line);
}
- /* At this place we expect the name of the driver */
+ /* At this place we expect the name of the service */
if (strcmp(cp1->word, cpe->word) == 0)
break;
}
"do_class: no entry found for class '%s' at %s:%d",
cpe->word, cpe->file, cpe->line);
}
- do_driver(cp1->next, config);
+ do_service(cp1->next, config);
}
class_recurs--;
}
}
-PRIVATE void do_driver(config_t *cpe, config_t *config)
+PRIVATE void do_service(config_t *cpe, config_t *config)
{
config_t *cp;
*/
if (!(cpe->flags & CFG_SUBLIST))
{
- fatal("do_driver: expected list at %s:%d",
+ fatal("do_service: expected list at %s:%d",
cpe->file, cpe->line);
}
if (cpe->next != NULL)
{
cpe= cpe->next;
- fatal("do_driver: expected end of list at %s:%d",
+ fatal("do_service: expected end of list at %s:%d",
cpe->file, cpe->line);
}
cpe= cpe->list;
{
if (!(cp->flags & CFG_SUBLIST))
{
- fatal("do_driver: expected list at %s:%d",
+ fatal("do_service: expected list at %s:%d",
cp->file, cp->line);
}
cpe= cp->list;
if ((cpe->flags & CFG_STRING) || (cpe->flags & CFG_SUBLIST))
{
- fatal("do_driver: expected word at %s:%d",
+ fatal("do_service: expected word at %s:%d",
cpe->file, cpe->line);
}
exit(1);
}
- /* Find an entry for our driver */
+ /* Find an entry for our service */
for (cp= config; cp; cp= cp->next)
{
if (!(cp->flags & CFG_SUBLIST))
cpe->file, cpe->line);
}
- /* At this place we expect the word 'driver' */
- if (strcmp(cpe->word, KW_DRIVER) != 0)
+ /* At this place we expect the word KW_SERVICE */
+ if (strcmp(cpe->word, KW_SERVICE) != 0)
fatal("do_config: exected word '%S' at %s:%d",
- KW_DRIVER, cpe->file, cpe->line);
+ KW_SERVICE, cpe->file, cpe->line);
cpe= cpe->next;
if ((cpe->flags & CFG_STRING) || (cpe->flags & CFG_SUBLIST))
cpe->file, cpe->line);
}
- /* At this place we expect the name of the driver */
+ /* At this place we expect the name of the service. */
if (strcmp(cpe->word, label) == 0)
break;
}
if (cp == NULL)
{
- fprintf(stderr, "service: driver '%s' not found in config\n",
+ fprintf(stderr, "service: service '%s' not found in config\n",
label);
exit(1);
}
cpe= cpe->next;
- do_driver(cpe, config);
+ do_service(cpe, config);
}
/* Main program.
*/
switch(request) {
case RS_UP:
- case RS_UP_COPY:
- /* Build space-separated command string to be passed to RS server. */
- strcpy(command, req_path);
- command[strlen(req_path)] = ' ';
- strcpy(command+strlen(req_path)+1, req_args);
-
- /* Build request message and send the request. */
- m.RS_CMD_ADDR = command;
- m.RS_CMD_LEN = strlen(command);
- m.RS_DEV_MAJOR = req_major;
- m.RS_PERIOD = req_period;
- if (OK != (s=_taskcall(RS_PROC_NR, request, &m)))
- failure(-s);
- result = m.m_type;
- break;
- case RS_START:
/* Build space-separated command string to be passed to RS server. */
strcpy(command, req_path);
command[strlen(req_path)] = ' ';
else
rs_start.rss_scriptlen= 0;
- pw= getpwnam(DRIVER_LOGIN);
+ pw= getpwnam(SERVICE_LOGIN);
if (pw == NULL)
- fatal("no passwd file entry for '%s'", DRIVER_LOGIN);
+ fatal("no passwd file entry for '%s'", SERVICE_LOGIN);
rs_start.rss_uid= pw->pw_uid;
- /* The name of the driver */
+ /* The name of the system service. */
(label= strrchr(req_path, '/')) ? label++ : (label= req_path);
if (req_config) {
char *r_exec; /* Executable image */
size_t r_exec_len; /* Length of image */
- char r_label[MAX_LABEL_LEN]; /* unique name of this driver */
+ char r_label[MAX_LABEL_LEN]; /* unique name of this service */
char r_cmd[MAX_COMMAND_LEN]; /* raw command plus arguments */
char r_script[MAX_SCRIPT_LEN]; /* name of the restart script executable */
char *r_argv[MAX_NR_ARGS+2]; /* parsed arguments vector */