1 /* VTreeFS - mount.c - mounting and unmounting */ 2 3 #include "inc.h" 4 #include <minix/vfsif.h> 5 6 /* 7 * Mount the file system. Obtain the root inode and send back its details. 8 */ 9 int fs_mount(dev_t __unused dev,unsigned int flags,struct fsdriver_node * root_node,unsigned int * res_flags)10fs_mount(dev_t __unused dev, unsigned int flags, 11 struct fsdriver_node * root_node, unsigned int * res_flags) 12 { 13 struct inode *root; 14 15 /* VTreeFS must not be mounted as a root file system. */ 16 if (flags & REQ_ISROOT) 17 return EINVAL; 18 19 /* Get the root inode and increase its reference count. */ 20 root = get_root_inode(); 21 ref_inode(root); 22 23 /* The system is now mounted. Call the initialization hook. */ 24 if (vtreefs_hooks->init_hook != NULL) 25 vtreefs_hooks->init_hook(); 26 27 /* Return the root inode's properties. */ 28 root_node->fn_ino_nr = get_inode_number(root); 29 root_node->fn_mode = root->i_stat.mode; 30 root_node->fn_size = root->i_stat.size; 31 root_node->fn_uid = root->i_stat.uid; 32 root_node->fn_gid = root->i_stat.gid; 33 root_node->fn_dev = NO_DEV; 34 35 *res_flags = RES_NOFLAGS; 36 37 return OK; 38 } 39 40 /* 41 * Unmount the file system. 42 */ 43 void fs_unmount(void)44fs_unmount(void) 45 { 46 struct inode *root; 47 48 /* Decrease the count of the root inode. */ 49 root = get_root_inode(); 50 51 put_inode(root); 52 53 /* The system is unmounted. Call the cleanup hook. */ 54 if (vtreefs_hooks->cleanup_hook != NULL) 55 vtreefs_hooks->cleanup_hook(); 56 } 57