vfs: pm_dumpcore: always clean up process
[minix.git] / lib / libvtreefs / mount.c
blob70bb84cd530e2bc02e84bbf24d8a1becdf2f0bf9
1 /* VTreeFS - mount.c - by Alen Stojanov and David van Moolenbroek */
3 #include "inc.h"
5 /*===========================================================================*
6 * fs_readsuper *
7 *===========================================================================*/
8 int fs_readsuper(void)
10 /* This function gets the root inode and sends back its details.
12 struct inode *root;
14 /* Get the device number, for stat requests. */
15 fs_dev = fs_m_in.REQ_DEV;
17 /* The VTreeFS must not be mounted as a root file system. */
18 if (fs_m_in.REQ_FLAGS & REQ_ISROOT)
19 return EINVAL;
21 /* Get the root inode and increase its reference count. */
22 root = get_root_inode();
23 ref_inode(root);
25 /* The system is now mounted. Call the initialization hook. */
26 if (vtreefs_hooks->init_hook != NULL)
27 vtreefs_hooks->init_hook();
29 /* Return the root inode's properties. */
30 fs_m_out.RES_INODE_NR = get_inode_number(root);
31 fs_m_out.RES_MODE = root->i_stat.mode;
32 fs_m_out.RES_FILE_SIZE_HI = 0;
33 fs_m_out.RES_FILE_SIZE_LO = root->i_stat.size;
34 fs_m_out.RES_UID = root->i_stat.uid;
35 fs_m_out.RES_GID = root->i_stat.gid;
36 fs_m_out.RES_DEV = NO_DEV;
38 fs_m_out.RES_CONREQS = 1;/* We can handle only 1 request at a time */
40 fs_mounted = TRUE;
42 return OK;
45 /*===========================================================================*
46 * fs_unmount *
47 *===========================================================================*/
48 int fs_unmount(void)
50 /* Unmount the file system.
52 struct inode *root;
54 /* Decrease the count of the root inode. */
55 root = get_root_inode();
57 put_inode(root);
59 /* The system is unmounted. Call the cleanup hook. */
60 if (vtreefs_hooks->cleanup_hook != NULL)
61 vtreefs_hooks->cleanup_hook();
63 /* We can now be shut down safely. */
64 fs_mounted = FALSE;
66 return OK;