1433d6423SLionel Sambuc #define _SYSTEM 1 /* tell headers that this is the kernel */ 2433d6423SLionel Sambuc 3433d6423SLionel Sambuc #include <minix/config.h> 4433d6423SLionel Sambuc #include <errno.h> 5433d6423SLionel Sambuc #include <unistd.h> 6433d6423SLionel Sambuc #include <stdlib.h> 7433d6423SLionel Sambuc #include <stdio.h> 8433d6423SLionel Sambuc #include <string.h> 9433d6423SLionel Sambuc #include <lib.h> 10433d6423SLionel Sambuc #include <minix/timers.h> 11433d6423SLionel Sambuc 12433d6423SLionel Sambuc #include <minix/callnr.h> 13433d6423SLionel Sambuc #include <minix/type.h> 14433d6423SLionel Sambuc #include <minix/const.h> 15433d6423SLionel Sambuc #include <minix/com.h> 16433d6423SLionel Sambuc #include <minix/syslib.h> 17433d6423SLionel Sambuc #include <minix/sysutil.h> 18433d6423SLionel Sambuc #include <minix/vfsif.h> 19433d6423SLionel Sambuc #include <minix/endpoint.h> 20433d6423SLionel Sambuc #include <minix/sysinfo.h> 21433d6423SLionel Sambuc #include <minix/u64.h> 22433d6423SLionel Sambuc #include <minix/sysinfo.h> 23433d6423SLionel Sambuc #include <minix/type.h> 24433d6423SLionel Sambuc #include <minix/ipc.h> 25433d6423SLionel Sambuc 26433d6423SLionel Sambuc #include <sys/time.h> 27433d6423SLionel Sambuc #include <sys/times.h> 28433d6423SLionel Sambuc #include <sys/types.h> 29433d6423SLionel Sambuc #include <sys/stat.h> 30433d6423SLionel Sambuc 31433d6423SLionel Sambuc 32433d6423SLionel Sambuc #include <minix/vtreefs.h> 33433d6423SLionel Sambuc #include "devman.h" 34433d6423SLionel Sambuc #include "proto.h" 35433d6423SLionel Sambuc 36433d6423SLionel Sambuc static void init_hook(void) { 37433d6423SLionel Sambuc static int first = 1; 38433d6423SLionel Sambuc 39433d6423SLionel Sambuc if (first) { 40433d6423SLionel Sambuc devman_init_devices(); 41433d6423SLionel Sambuc first = 0; 42433d6423SLionel Sambuc } 43433d6423SLionel Sambuc } 44433d6423SLionel Sambuc 45433d6423SLionel Sambuc 46*5eefd0feSDavid van Moolenbroek static void message_hook(message *m, int __unused ipc_status) 47433d6423SLionel Sambuc { 48433d6423SLionel Sambuc switch (m->m_type) { 49433d6423SLionel Sambuc case DEVMAN_ADD_DEV: 50*5eefd0feSDavid van Moolenbroek do_add_device(m); 51433d6423SLionel Sambuc case DEVMAN_DEL_DEV: 52*5eefd0feSDavid van Moolenbroek do_del_device(m); 53433d6423SLionel Sambuc case DEVMAN_BIND: 54*5eefd0feSDavid van Moolenbroek do_bind_device(m); 55433d6423SLionel Sambuc case DEVMAN_UNBIND: 56*5eefd0feSDavid van Moolenbroek do_unbind_device(m); 57433d6423SLionel Sambuc } 58433d6423SLionel Sambuc } 59433d6423SLionel Sambuc 60*5eefd0feSDavid van Moolenbroek static ssize_t 61433d6423SLionel Sambuc read_hook 62*5eefd0feSDavid van Moolenbroek (struct inode *inode, char *ptr, size_t len, off_t offset, cbdata_t cbdata) 63433d6423SLionel Sambuc { 64433d6423SLionel Sambuc struct devman_inode *d_inode = (struct devman_inode *) cbdata; 65433d6423SLionel Sambuc 66433d6423SLionel Sambuc return d_inode->read_fn(ptr, len, offset, d_inode->data); 67433d6423SLionel Sambuc } 68433d6423SLionel Sambuc 69433d6423SLionel Sambuc 70433d6423SLionel Sambuc int main (int argc, char* argv[]) 71433d6423SLionel Sambuc { 72433d6423SLionel Sambuc 73433d6423SLionel Sambuc struct fs_hooks hooks; 74433d6423SLionel Sambuc struct inode_stat root_stat; 75433d6423SLionel Sambuc 76433d6423SLionel Sambuc /* fill in the hooks */ 77433d6423SLionel Sambuc memset(&hooks, 0, sizeof(hooks)); 78433d6423SLionel Sambuc hooks.init_hook = init_hook; 79*5eefd0feSDavid van Moolenbroek hooks.read_hook = read_hook; 80433d6423SLionel Sambuc hooks.message_hook = message_hook; /* handle the ds_update call */ 81433d6423SLionel Sambuc 82433d6423SLionel Sambuc root_stat.mode = S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH; 83433d6423SLionel Sambuc root_stat.uid = 0; 84433d6423SLionel Sambuc root_stat.gid = 0; 85433d6423SLionel Sambuc root_stat.size = 0; 86433d6423SLionel Sambuc root_stat.dev = NO_DEV; 87433d6423SLionel Sambuc 88433d6423SLionel Sambuc /* limit the number of indexed entries */ 89*5eefd0feSDavid van Moolenbroek start_vtreefs(&hooks, 1024, &root_stat, 0, BUF_SIZE); 90433d6423SLionel Sambuc return 0; 91433d6423SLionel Sambuc } 92433d6423SLionel Sambuc 93