1 /* VTreeFS - mount.c - by Alen Stojanov and David van Moolenbroek */ 2 3 #include "inc.h" 4 5 /*===========================================================================* 6 * fs_readsuper * 7 *===========================================================================*/ 8 int fs_readsuper(void) 9 { 10 /* This function gets the root inode and sends back its details. 11 */ 12 struct inode *root; 13 14 /* Get the device number, for stat requests. */ 15 fs_dev = fs_m_in.m_vfs_fs_readsuper.device; 16 17 /* The VTreeFS must not be mounted as a root file system. */ 18 if (fs_m_in.m_vfs_fs_readsuper.flags & REQ_ISROOT) 19 return EINVAL; 20 21 /* Get the root inode and increase its reference count. */ 22 root = get_root_inode(); 23 ref_inode(root); 24 25 /* The system is now mounted. Call the initialization hook. */ 26 if (vtreefs_hooks->init_hook != NULL) 27 vtreefs_hooks->init_hook(); 28 29 /* Return the root inode's properties. */ 30 fs_m_out.m_fs_vfs_readsuper.inode = get_inode_number(root); 31 fs_m_out.m_fs_vfs_readsuper.mode = root->i_stat.mode; 32 fs_m_out.m_fs_vfs_readsuper.file_size = root->i_stat.size; 33 fs_m_out.m_fs_vfs_readsuper.uid = root->i_stat.uid; 34 fs_m_out.m_fs_vfs_readsuper.gid = root->i_stat.gid; 35 fs_m_out.m_fs_vfs_readsuper.device = NO_DEV; 36 fs_m_out.m_fs_vfs_readsuper.flags = RES_NOFLAGS; 37 38 fs_mounted = TRUE; 39 40 return OK; 41 } 42 43 /*===========================================================================* 44 * fs_unmount * 45 *===========================================================================*/ 46 int fs_unmount(void) 47 { 48 /* Unmount the file system. 49 */ 50 struct inode *root; 51 52 /* Decrease the count of the root inode. */ 53 root = get_root_inode(); 54 55 put_inode(root); 56 57 /* The system is unmounted. Call the cleanup hook. */ 58 if (vtreefs_hooks->cleanup_hook != NULL) 59 vtreefs_hooks->cleanup_hook(); 60 61 /* We can now be shut down safely. */ 62 fs_mounted = FALSE; 63 64 return OK; 65 } 66