2010-08-10 22:05:51 +02:00
|
|
|
/* VTreeFS - mount.c - by Alen Stojanov and David van Moolenbroek */
|
|
|
|
|
|
|
|
#include "inc.h"
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* fs_readsuper *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int fs_readsuper(void)
|
2010-08-10 22:05:51 +02:00
|
|
|
{
|
|
|
|
/* This function gets the root inode and sends back its details.
|
|
|
|
*/
|
|
|
|
struct inode *root;
|
|
|
|
|
|
|
|
/* Get the device number, for stat requests. */
|
2014-04-28 16:45:11 +02:00
|
|
|
fs_dev = fs_m_in.m_vfs_fs_readsuper.device;
|
2010-08-10 22:05:51 +02:00
|
|
|
|
|
|
|
/* The VTreeFS must not be mounted as a root file system. */
|
2014-04-28 16:45:11 +02:00
|
|
|
if (fs_m_in.m_vfs_fs_readsuper.flags & REQ_ISROOT)
|
2010-08-10 22:05:51 +02:00
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
/* Get the root inode and increase its reference count. */
|
|
|
|
root = get_root_inode();
|
|
|
|
ref_inode(root);
|
|
|
|
|
|
|
|
/* The system is now mounted. Call the initialization hook. */
|
|
|
|
if (vtreefs_hooks->init_hook != NULL)
|
|
|
|
vtreefs_hooks->init_hook();
|
|
|
|
|
|
|
|
/* Return the root inode's properties. */
|
2014-04-28 16:45:11 +02:00
|
|
|
fs_m_out.m_fs_vfs_readsuper.inode = get_inode_number(root);
|
|
|
|
fs_m_out.m_fs_vfs_readsuper.mode = root->i_stat.mode;
|
|
|
|
fs_m_out.m_fs_vfs_readsuper.file_size = root->i_stat.size;
|
|
|
|
fs_m_out.m_fs_vfs_readsuper.uid = root->i_stat.uid;
|
|
|
|
fs_m_out.m_fs_vfs_readsuper.gid = root->i_stat.gid;
|
|
|
|
fs_m_out.m_fs_vfs_readsuper.device = NO_DEV;
|
|
|
|
fs_m_out.m_fs_vfs_readsuper.flags = RES_NOFLAGS;
|
2011-08-22 17:02:13 +02:00
|
|
|
|
2010-08-10 22:05:51 +02:00
|
|
|
fs_mounted = TRUE;
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* fs_unmount *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int fs_unmount(void)
|
2010-08-10 22:05:51 +02:00
|
|
|
{
|
|
|
|
/* Unmount the file system.
|
|
|
|
*/
|
|
|
|
struct inode *root;
|
|
|
|
|
|
|
|
/* Decrease the count of the root inode. */
|
|
|
|
root = get_root_inode();
|
|
|
|
|
|
|
|
put_inode(root);
|
|
|
|
|
|
|
|
/* The system is unmounted. Call the cleanup hook. */
|
|
|
|
if (vtreefs_hooks->cleanup_hook != NULL)
|
|
|
|
vtreefs_hooks->cleanup_hook();
|
|
|
|
|
|
|
|
/* We can now be shut down safely. */
|
|
|
|
fs_mounted = FALSE;
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|