xref: /minix3/minix/fs/procfs/service.c (revision ef8d499e2d2af900e9b2ab297171d7b088652482)
131b6611aSDavid van Moolenbroek /* ProcFS - service.c - the service subdirectory */
231b6611aSDavid van Moolenbroek 
331b6611aSDavid van Moolenbroek #include "inc.h"
431b6611aSDavid van Moolenbroek 
531b6611aSDavid van Moolenbroek #include <minix/rs.h>
631b6611aSDavid van Moolenbroek #include "rs/const.h"
731b6611aSDavid van Moolenbroek #include "rs/type.h"
831b6611aSDavid van Moolenbroek 
941ba8c04SLionel Sambuc enum policy {
1041ba8c04SLionel Sambuc 	POL_NONE	= 0x00,	/*     user	| endpoint	*/
1141ba8c04SLionel Sambuc 	POL_RESET	= 0x01,	/* visible	|  change	*/
1241ba8c04SLionel Sambuc 	POL_RESTART	= 0x02,	/* transparent	| preserved	*/
1341ba8c04SLionel Sambuc 	POL_LIVE_UPDATE	= 0x04	/* transparent	| preserved	*/
1441ba8c04SLionel Sambuc };
1541ba8c04SLionel Sambuc 
1641ba8c04SLionel Sambuc struct policies {
1741ba8c04SLionel Sambuc 	#define MAX_POL_FORMAT_SZ 20
1841ba8c04SLionel Sambuc 	char formatted[MAX_POL_FORMAT_SZ];
1941ba8c04SLionel Sambuc 	enum policy supported;
2041ba8c04SLionel Sambuc };
2141ba8c04SLionel Sambuc 
22129adfebSDavid van Moolenbroek typedef struct {
230eabb93cSDavid van Moolenbroek 	struct rproc proc[NR_SYS_PROCS];
240eabb93cSDavid van Moolenbroek 	struct rprocpub pub[NR_SYS_PROCS];
25129adfebSDavid van Moolenbroek } ixfer_rproc_t;
26129adfebSDavid van Moolenbroek static ixfer_rproc_t rproc;
270eabb93cSDavid van Moolenbroek 
2841ba8c04SLionel Sambuc static struct policies policies[NR_SYS_PROCS];
2931b6611aSDavid van Moolenbroek 
3031b6611aSDavid van Moolenbroek static struct inode *service_node;
3131b6611aSDavid van Moolenbroek 
3241ba8c04SLionel Sambuc /* Updates the policies state from RS. Always returns an ASCIIZ string.  */
3341ba8c04SLionel Sambuc static const char *
service_get_policies(struct policies * pol,index_t slot)3441ba8c04SLionel Sambuc service_get_policies(struct policies * pol, index_t slot)
3531b6611aSDavid van Moolenbroek {
3641ba8c04SLionel Sambuc #if 1 /* The following should be retrieved from RS and formated instead. */
3741ba8c04SLionel Sambuc 	int pos;
3841ba8c04SLionel Sambuc 	char *ref_label;
3941ba8c04SLionel Sambuc 	static const struct {
4041ba8c04SLionel Sambuc 		const char *label;
4141ba8c04SLionel Sambuc 		const char *policy_str;
4241ba8c04SLionel Sambuc 	} def_pol[] = {
4341ba8c04SLionel Sambuc 		/* audio */
4486fd71a2SJia-Ju Bai 		{ .label = "als4000", .policy_str = "reset" },
4537e23b1cSJia-Ju Bai 		{ .label = "cmi8738", .policy_str = "reset" },
468acfcfc3SJia-Ju Bai 		{ .label = "cs4281", .policy_str = "reset" },
4741ba8c04SLionel Sambuc 		{ .label = "es1370", .policy_str = "reset" },
4841ba8c04SLionel Sambuc 		{ .label = "es1371", .policy_str = "reset" },
4941ba8c04SLionel Sambuc 		{ .label = "sb16", .policy_str = "reset" },
50eecf6d23SJia-Ju Bai 		{ .label = "trident", .policy_str = "reset" },
5141ba8c04SLionel Sambuc 		/* bus */
5241ba8c04SLionel Sambuc 		{ .label = "i2c", .policy_str = "restart" },
5341ba8c04SLionel Sambuc 		{ .label = "pci", .policy_str = "restart" },
5441ba8c04SLionel Sambuc 		{ .label = "ti1225", .policy_str = "restart" },
5541ba8c04SLionel Sambuc 		/* clock */
5641ba8c04SLionel Sambuc 		{ .label = "readclock.drv", .policy_str = "restart" },
5741ba8c04SLionel Sambuc 		/* eeprom */
5841ba8c04SLionel Sambuc 		{ .label = "cat24c256", .policy_str = "restart" },
5941ba8c04SLionel Sambuc 		/* examples */
6041ba8c04SLionel Sambuc 		{ .label = "hello", .policy_str = "restart" },
6141ba8c04SLionel Sambuc 		/* hid */
6241ba8c04SLionel Sambuc 		{ .label = "pckbd", .policy_str = "reset" },
6341ba8c04SLionel Sambuc 		/* iommu */
6441ba8c04SLionel Sambuc 		{ .label = "amddev", .policy_str = "" },
6541ba8c04SLionel Sambuc 		/* net */
660c474453SCristiano Giuffrida 		{ .label = "3c90x", .policy_str = "reset" },
670c474453SCristiano Giuffrida 		{ .label = "atl2", .policy_str = "reset" },
680c474453SCristiano Giuffrida 		{ .label = "dec21140A", .policy_str = "reset" },
690c474453SCristiano Giuffrida 		{ .label = "dp8390", .policy_str = "reset" },
700c474453SCristiano Giuffrida 		{ .label = "dpeth", .policy_str = "reset" },
710c474453SCristiano Giuffrida 		{ .label = "e1000", .policy_str = "reset" },
720c474453SCristiano Giuffrida 		{ .label = "fxp", .policy_str = "reset" },
738d98f2e5SJia-Ju Bai 		{ .label = "ip1000", .policy_str = "reset" },
740c474453SCristiano Giuffrida 		{ .label = "lance", .policy_str = "reset" },
750c474453SCristiano Giuffrida 		{ .label = "lan8710a", .policy_str = "reset" },
760c474453SCristiano Giuffrida 		{ .label = "orinoco", .policy_str = "reset" },
770c474453SCristiano Giuffrida 		{ .label = "rtl8139", .policy_str = "reset" },
780c474453SCristiano Giuffrida 		{ .label = "rtl8169", .policy_str = "reset" },
7941ba8c04SLionel Sambuc 		{ .label = "uds", .policy_str = "reset" },
800c474453SCristiano Giuffrida 		{ .label = "virtio_net", .policy_str = "reset" },
81022136b3SJia-Ju Bai 		{ .label = "vt6105", .policy_str = "reset" },
8241ba8c04SLionel Sambuc 		/* power */
8341ba8c04SLionel Sambuc 		{ .label = "acpi", .policy_str = "" },
8441ba8c04SLionel Sambuc 		{ .label = "tps65217", .policy_str = "" },
8541ba8c04SLionel Sambuc 		{ .label = "tps65590", .policy_str = "" },
8641ba8c04SLionel Sambuc 		/* printer */
8741ba8c04SLionel Sambuc 		{ .label = "printer", .policy_str = "restart" },
8841ba8c04SLionel Sambuc 		/* sensors */
8941ba8c04SLionel Sambuc 		{ .label = "bmp085", .policy_str = "" },
9041ba8c04SLionel Sambuc 		{ .label = "sht21", .policy_str = "restart" },
9141ba8c04SLionel Sambuc 		{ .label = "tsl2550", .policy_str = "restart" },
9241ba8c04SLionel Sambuc 		/* storage */
9341ba8c04SLionel Sambuc 		{ .label = "ahci", .policy_str = "reset" },
9441ba8c04SLionel Sambuc 		{ .label = "at_wini", .policy_str = "reset" },
9541ba8c04SLionel Sambuc 		{ .label = "fbd", .policy_str = "reset" },
9641ba8c04SLionel Sambuc 		{ .label = "filter", .policy_str = "reset" },
9741ba8c04SLionel Sambuc 		{ .label = "floppy", .policy_str = "reset" },
9841ba8c04SLionel Sambuc 		{ .label = "memory", .policy_str = "restart" },
9941ba8c04SLionel Sambuc 		{ .label = "mmc", .policy_str = "reset" },
10041ba8c04SLionel Sambuc 		{ .label = "virtio_blk", .policy_str = "reset" },
10141ba8c04SLionel Sambuc 		{ .label = "vnd", .policy_str = "reset" },
10241ba8c04SLionel Sambuc 		/* system */
10341ba8c04SLionel Sambuc 		{ .label = "gpio", .policy_str = "restart" },
10467b47183SLionel Sambuc 		{ .label = "log", .policy_str = "reset" },
10541ba8c04SLionel Sambuc 		{ .label = "random", .policy_str = "restart" },
10641ba8c04SLionel Sambuc 		/* tty */
10741ba8c04SLionel Sambuc 		{ .label = "pty", .policy_str = "restart" },
1080c474453SCristiano Giuffrida 		{ .label = "tty", .policy_str = "restart" },
10941ba8c04SLionel Sambuc 		/* usb */
11041ba8c04SLionel Sambuc 		{ .label = "usbd", .policy_str = "" },
11141ba8c04SLionel Sambuc 		{ .label = "usb_hub", .policy_str = "" },
11241ba8c04SLionel Sambuc 		{ .label = "usb_storage", .policy_str = "" },
11341ba8c04SLionel Sambuc 		/* video */
11441ba8c04SLionel Sambuc 		{ .label = "fb", .policy_str = "" },
11541ba8c04SLionel Sambuc 		{ .label = "tda19988", .policy_str = "" },
11641ba8c04SLionel Sambuc 		/* vmm_guest */
11741ba8c04SLionel Sambuc 		{ .label = "vbox", .policy_str = "" },
11841ba8c04SLionel Sambuc 		/* fs */
11941ba8c04SLionel Sambuc 		{ .label = "ext2", .policy_str = "" },
12041ba8c04SLionel Sambuc 		{ .label = "hgfs", .policy_str = "" },
12141ba8c04SLionel Sambuc 		{ .label = "isofs", .policy_str = "" },
1220c474453SCristiano Giuffrida 		{ .label = "mfs", .policy_str = "restart" },
1230c474453SCristiano Giuffrida 		{ .label = "pfs", .policy_str = "restart" },
1240c474453SCristiano Giuffrida 		{ .label = "procfs", .policy_str = "restart" },
125da21d850SDavid van Moolenbroek 		{ .label = "ptyfs", .policy_str = "" },
12641ba8c04SLionel Sambuc 		{ .label = "vbfs", .policy_str = "" },
12741ba8c04SLionel Sambuc 		/* net */
128*ef8d499eSDavid van Moolenbroek 		{ .label = "lwip", .policy_str = "reset" },
12941ba8c04SLionel Sambuc 		/* servers */
1300c474453SCristiano Giuffrida 		{ .label = "devman", .policy_str = "restart" },
1310c474453SCristiano Giuffrida 		{ .label = "ds", .policy_str = "restart" },
13241ba8c04SLionel Sambuc 		{ .label = "input", .policy_str = "reset" },
13341ba8c04SLionel Sambuc 		{ .label = "ipc", .policy_str = "restart" },
13441ba8c04SLionel Sambuc 		{ .label = "is", .policy_str = "restart" },
135e4e21ee1SDavid van Moolenbroek 		{ .label = "mib", .policy_str = "restart" },
1360c474453SCristiano Giuffrida 		{ .label = "pm", .policy_str = "restart" },
1370c474453SCristiano Giuffrida 		{ .label = "rs", .policy_str = "restart" },
1380c474453SCristiano Giuffrida 		{ .label = "sched", .policy_str = "restart" },
1390c474453SCristiano Giuffrida 		{ .label = "vfs", .policy_str = "restart" },
1408b0f8559SLionel Sambuc 		{ .label = "vm", .policy_str = "restart" },
14141ba8c04SLionel Sambuc 		//{ .label = "", .policy_str = "" },
14241ba8c04SLionel Sambuc 	};
14331b6611aSDavid van Moolenbroek 
14441ba8c04SLionel Sambuc 	/* Find the related policy, based on the file name of the service. */
1450eabb93cSDavid van Moolenbroek 	ref_label = strrchr(rproc.pub[slot].proc_name, '/');
14641ba8c04SLionel Sambuc 	if (NULL == ref_label)
1470eabb93cSDavid van Moolenbroek 		ref_label = rproc.pub[slot].proc_name;
14831b6611aSDavid van Moolenbroek 
14941ba8c04SLionel Sambuc 	memset(pol[slot].formatted, 0, MAX_POL_FORMAT_SZ);
15041ba8c04SLionel Sambuc 	for(pos = 0; pos < (sizeof(def_pol) / sizeof(def_pol[0])); pos++) {
15141ba8c04SLionel Sambuc 		if (0 == strcmp(ref_label, def_pol[pos].label)) {
152f5321d8dSDavid van Moolenbroek 			(void)strncpy(pol[slot].formatted,
153f5321d8dSDavid van Moolenbroek 			    def_pol[pos].policy_str, MAX_POL_FORMAT_SZ);
15441ba8c04SLionel Sambuc 			pol[slot].formatted[MAX_POL_FORMAT_SZ-1] = '\0';
15541ba8c04SLionel Sambuc 			break;
15641ba8c04SLionel Sambuc 		}
15741ba8c04SLionel Sambuc 	}
15841ba8c04SLionel Sambuc #else
15941ba8c04SLionel Sambuc 	/* Should do something sensible, based on flags from RS/SEF. */
16041ba8c04SLionel Sambuc #endif
16131b6611aSDavid van Moolenbroek 
16241ba8c04SLionel Sambuc 	return pol[slot].formatted;
16331b6611aSDavid van Moolenbroek }
16431b6611aSDavid van Moolenbroek 
1650c474453SCristiano Giuffrida /* Returns a ASCIIZ string encoding RS flags.  */
1660c474453SCristiano Giuffrida static const char *
service_get_flags(index_t slot)1670c474453SCristiano Giuffrida service_get_flags(index_t slot)
1680c474453SCristiano Giuffrida {
1690c474453SCristiano Giuffrida 	static char str[10];
1700c474453SCristiano Giuffrida 	int flags, sys_flags;
1710c474453SCristiano Giuffrida 
1720c474453SCristiano Giuffrida 	flags = rproc.proc[slot].r_flags;
1730c474453SCristiano Giuffrida 	sys_flags = rproc.pub[slot].sys_flags;
1740c474453SCristiano Giuffrida 
1750c474453SCristiano Giuffrida 	str[0] = (flags & RS_ACTIVE)        ? 'A' : '-';
1760c474453SCristiano Giuffrida 	str[1] = (flags & RS_UPDATING)      ? 'U' : '-';
1770c474453SCristiano Giuffrida 	str[2] = (flags & RS_EXITING)       ? 'E' : '-';
1780c474453SCristiano Giuffrida 	str[3] = (flags & RS_NOPINGREPLY)   ? 'N' : '-';
1790c474453SCristiano Giuffrida 	str[4] = (sys_flags & SF_USE_COPY)  ? 'C' : '-';
1800c474453SCristiano Giuffrida 	str[5] = (sys_flags & SF_USE_REPL)  ? 'R' : '-';
1810c474453SCristiano Giuffrida 	str[6] = (sys_flags & SF_NEED_COPY) ? 'c' : '-';
1820c474453SCristiano Giuffrida 	str[7] = (sys_flags & SF_NEED_REPL) ? 'r' : '-';
1830c474453SCristiano Giuffrida 	str[8] = (sys_flags & SF_CORE_SRV)  ? 's' : '-';
1840c474453SCristiano Giuffrida 	str[9] = '\0';
1850c474453SCristiano Giuffrida 
1860c474453SCristiano Giuffrida 	return str;
1870c474453SCristiano Giuffrida }
1880c474453SCristiano Giuffrida 
18931b6611aSDavid van Moolenbroek /*
190f5321d8dSDavid van Moolenbroek  * Return whether a slot is in use and active.  The purpose of this check is
191f5321d8dSDavid van Moolenbroek  * to ensure that after eliminating all slots that do not pass this check, we
192f5321d8dSDavid van Moolenbroek  * are left with a set of live services each with a unique label.
193f5321d8dSDavid van Moolenbroek  */
194f5321d8dSDavid van Moolenbroek static int
service_active(index_t slot)195f5321d8dSDavid van Moolenbroek service_active(index_t slot)
196f5321d8dSDavid van Moolenbroek {
197f5321d8dSDavid van Moolenbroek 
198fefec20eSDavid van Moolenbroek 	/*
199fefec20eSDavid van Moolenbroek 	 * Init is in RS's process tables as the representation of user
200fefec20eSDavid van Moolenbroek 	 * processes.  It is not a system service.
201fefec20eSDavid van Moolenbroek 	 */
202f5321d8dSDavid van Moolenbroek 	return ((rproc.proc[slot].r_flags & (RS_IN_USE | RS_ACTIVE)) ==
203fefec20eSDavid van Moolenbroek 	    (RS_IN_USE | RS_ACTIVE) &&
204fefec20eSDavid van Moolenbroek 	   rproc.pub[slot].endpoint != INIT_PROC_NR);
205f5321d8dSDavid van Moolenbroek }
206f5321d8dSDavid van Moolenbroek 
207f5321d8dSDavid van Moolenbroek /*
20831b6611aSDavid van Moolenbroek  * Update the contents of the service directory, by first updating the RS
20931b6611aSDavid van Moolenbroek  * tables and then updating the directory contents.
21031b6611aSDavid van Moolenbroek  */
21141ba8c04SLionel Sambuc static void
service_update(void)21231b6611aSDavid van Moolenbroek service_update(void)
21331b6611aSDavid van Moolenbroek {
21431b6611aSDavid van Moolenbroek 	struct inode *node;
21531b6611aSDavid van Moolenbroek 	struct inode_stat stat;
21631b6611aSDavid van Moolenbroek 	index_t slot;
2170eabb93cSDavid van Moolenbroek 	static int warned = FALSE;
2180eabb93cSDavid van Moolenbroek 	int r;
21931b6611aSDavid van Moolenbroek 
2200eabb93cSDavid van Moolenbroek 	/* There is not much we can do if this call fails. */
2210eabb93cSDavid van Moolenbroek 	r = getsysinfo(RS_PROC_NR, SI_PROCALL_TAB, &rproc, sizeof(rproc));
2220eabb93cSDavid van Moolenbroek 	if (r != OK && !warned) {
2230eabb93cSDavid van Moolenbroek 		printf("PROCFS: unable to obtain RS tables (%d)\n", r);
2240eabb93cSDavid van Moolenbroek 		warned = TRUE;
2250eabb93cSDavid van Moolenbroek 	}
22631b6611aSDavid van Moolenbroek 
22731b6611aSDavid van Moolenbroek 	/*
22831b6611aSDavid van Moolenbroek 	 * As with PIDs, we make two passes.  Delete first, then add.  This
22931b6611aSDavid van Moolenbroek 	 * prevents problems in the hypothetical case that between updates, one
23031b6611aSDavid van Moolenbroek 	 * slot ends up with the label name of a previous, different slot.
23131b6611aSDavid van Moolenbroek 	 */
23231b6611aSDavid van Moolenbroek 	for (slot = 0; slot < NR_SYS_PROCS; slot++) {
23331b6611aSDavid van Moolenbroek 		if ((node = get_inode_by_index(service_node, slot)) == NULL)
23431b6611aSDavid van Moolenbroek 			continue;
23531b6611aSDavid van Moolenbroek 
23631b6611aSDavid van Moolenbroek 		/*
23731b6611aSDavid van Moolenbroek 		 * If the slot is no longer in use, or the label name does not
23831b6611aSDavid van Moolenbroek 		 * match, the node must be deleted.
23931b6611aSDavid van Moolenbroek 		 */
240f5321d8dSDavid van Moolenbroek 		if (!service_active(slot) ||
2410eabb93cSDavid van Moolenbroek 		    strcmp(get_inode_name(node), rproc.pub[slot].label))
24231b6611aSDavid van Moolenbroek 			delete_inode(node);
24331b6611aSDavid van Moolenbroek 	}
24431b6611aSDavid van Moolenbroek 
24531b6611aSDavid van Moolenbroek 	memset(&stat, 0, sizeof(stat));
24631b6611aSDavid van Moolenbroek 	stat.mode = REG_ALL_MODE;
24731b6611aSDavid van Moolenbroek 	stat.uid = SUPER_USER;
24831b6611aSDavid van Moolenbroek 	stat.gid = SUPER_USER;
24931b6611aSDavid van Moolenbroek 
25031b6611aSDavid van Moolenbroek 	for (slot = 0; slot < NR_SYS_PROCS; slot++) {
251f5321d8dSDavid van Moolenbroek 		if (!service_active(slot) ||
25231b6611aSDavid van Moolenbroek 		    get_inode_by_index(service_node, slot) != NULL)
25331b6611aSDavid van Moolenbroek 			continue;
25431b6611aSDavid van Moolenbroek 
2550eabb93cSDavid van Moolenbroek 		node = add_inode(service_node, rproc.pub[slot].label, slot,
25631b6611aSDavid van Moolenbroek 		    &stat, (index_t)0, (cbdata_t)slot);
25731b6611aSDavid van Moolenbroek 
25831b6611aSDavid van Moolenbroek 		if (node == NULL)
25931b6611aSDavid van Moolenbroek 			out_of_inodes();
26031b6611aSDavid van Moolenbroek 	}
26131b6611aSDavid van Moolenbroek }
26231b6611aSDavid van Moolenbroek 
26331b6611aSDavid van Moolenbroek /*
26441ba8c04SLionel Sambuc  * Initialize the service directory.
26541ba8c04SLionel Sambuc  */
26641ba8c04SLionel Sambuc void
service_init(void)26741ba8c04SLionel Sambuc service_init(void)
26841ba8c04SLionel Sambuc {
26941ba8c04SLionel Sambuc 	struct inode *root, *node;
27041ba8c04SLionel Sambuc 	struct inode_stat stat;
27141ba8c04SLionel Sambuc 
27241ba8c04SLionel Sambuc 	root = get_root_inode();
27341ba8c04SLionel Sambuc 
27441ba8c04SLionel Sambuc 	memset(&stat, 0, sizeof(stat));
27541ba8c04SLionel Sambuc 	stat.mode = DIR_ALL_MODE;
27641ba8c04SLionel Sambuc 	stat.uid = SUPER_USER;
27741ba8c04SLionel Sambuc 	stat.gid = SUPER_USER;
27841ba8c04SLionel Sambuc 
27941ba8c04SLionel Sambuc 	service_node = add_inode(root, "service", NO_INDEX, &stat,
28041ba8c04SLionel Sambuc 	    NR_SYS_PROCS, NULL);
28141ba8c04SLionel Sambuc 
28241ba8c04SLionel Sambuc 	if (service_node == NULL)
28341ba8c04SLionel Sambuc 		panic("unable to create service node");
28441ba8c04SLionel Sambuc }
28541ba8c04SLionel Sambuc 
28641ba8c04SLionel Sambuc /*
28731b6611aSDavid van Moolenbroek  * A lookup request is being performed.  If it is in the service directory,
28831b6611aSDavid van Moolenbroek  * update the tables.  We do this lazily, to reduce overhead.
28931b6611aSDavid van Moolenbroek  */
29031b6611aSDavid van Moolenbroek void
service_lookup(struct inode * parent,clock_t now)29131b6611aSDavid van Moolenbroek service_lookup(struct inode * parent, clock_t now)
29231b6611aSDavid van Moolenbroek {
29331b6611aSDavid van Moolenbroek 	static clock_t last_update = 0;
29431b6611aSDavid van Moolenbroek 
29531b6611aSDavid van Moolenbroek 	if (parent != service_node)
29631b6611aSDavid van Moolenbroek 		return;
29731b6611aSDavid van Moolenbroek 
29831b6611aSDavid van Moolenbroek 	if (last_update != now) {
29931b6611aSDavid van Moolenbroek 		service_update();
30031b6611aSDavid van Moolenbroek 
30131b6611aSDavid van Moolenbroek 		last_update = now;
30231b6611aSDavid van Moolenbroek 	}
30331b6611aSDavid van Moolenbroek }
30431b6611aSDavid van Moolenbroek 
30531b6611aSDavid van Moolenbroek /*
30631b6611aSDavid van Moolenbroek  * A getdents request is being performed.  If it is in the service directory,
30731b6611aSDavid van Moolenbroek  * update the tables.
30831b6611aSDavid van Moolenbroek  */
30931b6611aSDavid van Moolenbroek void
service_getdents(struct inode * node)31031b6611aSDavid van Moolenbroek service_getdents(struct inode * node)
31131b6611aSDavid van Moolenbroek {
31231b6611aSDavid van Moolenbroek 
31331b6611aSDavid van Moolenbroek 	if (node != service_node)
31431b6611aSDavid van Moolenbroek 		return;
31531b6611aSDavid van Moolenbroek 
31631b6611aSDavid van Moolenbroek 	service_update();
31731b6611aSDavid van Moolenbroek }
31831b6611aSDavid van Moolenbroek 
31931b6611aSDavid van Moolenbroek /*
32031b6611aSDavid van Moolenbroek  * A read request is being performed.  If it is on a file in the service
32131b6611aSDavid van Moolenbroek  * directory, process the read request.  We rely on the fact that any read
32231b6611aSDavid van Moolenbroek  * call will have been preceded by a lookup, so its table entry has been
32331b6611aSDavid van Moolenbroek  * updated very recently.
32431b6611aSDavid van Moolenbroek  */
32531b6611aSDavid van Moolenbroek void
service_read(struct inode * node)32631b6611aSDavid van Moolenbroek service_read(struct inode * node)
32731b6611aSDavid van Moolenbroek {
32831b6611aSDavid van Moolenbroek 	struct inode *parent;
32931b6611aSDavid van Moolenbroek 	index_t slot;
33031b6611aSDavid van Moolenbroek 	struct rprocpub *rpub;
33131b6611aSDavid van Moolenbroek 	struct rproc *rp;
33231b6611aSDavid van Moolenbroek 
33331b6611aSDavid van Moolenbroek 	if (get_parent_inode(node) != service_node)
33431b6611aSDavid van Moolenbroek 		return;
33531b6611aSDavid van Moolenbroek 
33631b6611aSDavid van Moolenbroek 	slot = get_inode_index(node);
3370eabb93cSDavid van Moolenbroek 	rpub = &rproc.pub[slot];
3380eabb93cSDavid van Moolenbroek 	rp = &rproc.proc[slot];
33931b6611aSDavid van Moolenbroek 
34031b6611aSDavid van Moolenbroek 	/* TODO: add a large number of other fields! */
34141ba8c04SLionel Sambuc 	buf_printf("filename: %s\n", rpub->proc_name);
34241ba8c04SLionel Sambuc 	buf_printf("endpoint: %d\n", rpub->endpoint);
343a8f606deSCristiano Giuffrida 	buf_printf("pid:      %d\n", rp->r_pid);
34441ba8c04SLionel Sambuc 	buf_printf("restarts: %d\n", rp->r_restarts);
3450c474453SCristiano Giuffrida 	buf_printf("flags:    %s\n", service_get_flags(slot));
34641ba8c04SLionel Sambuc 	buf_printf("policies: %s\n", service_get_policies(policies, slot));
347e4d99eb9SDavid van Moolenbroek 	buf_printf("ASRcount: %u\n", rp->r_asr_count);
34831b6611aSDavid van Moolenbroek }
349