unstack - fix ipcvecs
[minix.git] / servers / devman / main.c
blob2cb77b6fc3f6b8f258850a18df0464cc82ab9f20
1 #define _POSIX_SOURCE 1 /* tell headers to include POSIX stuff */
2 #define _MINIX 1 /* tell headers to include MINIX stuff */
3 #define _SYSTEM 1 /* tell headers that this is the kernel */
5 #include <minix/config.h>
6 #include <errno.h>
7 #include <unistd.h>
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <string.h>
11 #include <lib.h>
12 #include <timers.h>
14 #include <minix/callnr.h>
15 #include <minix/type.h>
16 #include <minix/const.h>
17 #include <minix/com.h>
18 #include <minix/syslib.h>
19 #include <minix/sysutil.h>
20 #include <minix/vfsif.h>
21 #include <minix/endpoint.h>
22 #include <minix/sysinfo.h>
23 #include <minix/u64.h>
24 #include <minix/sysinfo.h>
25 #include <minix/type.h>
26 #include <minix/ipc.h>
28 #include <sys/time.h>
29 #include <sys/times.h>
30 #include <sys/types.h>
31 #include <sys/stat.h>
34 #include <minix/vtreefs.h>
35 #include "devman.h"
36 #include "proto.h"
38 static void init_hook(void) {
39 static int first = 1;
41 if (first) {
42 devman_init_devices();
43 first = 0;
48 static int message_hook (message *m)
50 switch (m->m_type) {
51 case DEVMAN_ADD_DEV:
52 return do_add_device(m);
53 case DEVMAN_DEL_DEV:
54 return do_del_device(m);
55 case DEVMAN_BIND:
56 return do_bind_device(m);
57 case DEVMAN_UNBIND:
58 return do_unbind_device(m);
59 default: return -1;
63 static int
64 read_hook
65 (struct inode *inode, off_t offset, char **ptr, size_t *len, cbdata_t cbdata)
67 struct devman_inode *d_inode = (struct devman_inode *) cbdata;
69 return d_inode->read_fn(ptr, len, offset, d_inode->data);
73 int main (int argc, char* argv[])
76 struct fs_hooks hooks;
77 struct inode_stat root_stat;
79 /* fill in the hooks */
80 memset(&hooks, 0, sizeof(hooks));
81 hooks.init_hook = init_hook;
82 hooks.read_hook = read_hook; /* read will never be called */
83 hooks.message_hook = message_hook; /* handle the ds_update call */
85 root_stat.mode = S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH;
86 root_stat.uid = 0;
87 root_stat.gid = 0;
88 root_stat.size = 0;
89 root_stat.dev = NO_DEV;
91 /* limit the number of indexed entries */
92 start_vtreefs(&hooks, 1024 , &root_stat, 0);
93 return 0;