2011-11-14 12:53:05 +01:00
|
|
|
/* Created (MFS based):
|
|
|
|
* June 2011 (Evgeniy Ivanov)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fs.h"
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <minix/vfsif.h>
|
|
|
|
|
|
|
|
#include "puffs_priv.h"
|
|
|
|
|
|
|
|
/*===========================================================================*
|
2014-08-24 11:51:35 +02:00
|
|
|
* fs_mount *
|
2011-11-14 12:53:05 +01:00
|
|
|
*===========================================================================*/
|
2014-08-24 11:51:35 +02:00
|
|
|
int fs_mount(dev_t dev, unsigned int flags, struct fsdriver_node *root_node,
|
|
|
|
unsigned int *res_flags)
|
2011-11-14 12:53:05 +01:00
|
|
|
{
|
|
|
|
struct vattr *root_va;
|
|
|
|
|
2014-08-24 11:51:35 +02:00
|
|
|
fs_dev = dev;
|
|
|
|
is_readonly_fs = !!(flags & REQ_RDONLY);
|
2011-11-14 12:53:05 +01:00
|
|
|
|
|
|
|
/* Open root pnode */
|
|
|
|
global_pu->pu_pn_root->pn_count = 1;
|
|
|
|
|
|
|
|
/* Root pnode properties */
|
|
|
|
root_va = &global_pu->pu_pn_root->pn_va;
|
2014-08-24 11:51:35 +02:00
|
|
|
root_node->fn_ino_nr = root_va->va_fileid;
|
|
|
|
root_node->fn_mode = root_va->va_mode;
|
|
|
|
root_node->fn_size = root_va->va_size;
|
|
|
|
root_node->fn_uid = root_va->va_uid;
|
|
|
|
root_node->fn_gid = root_va->va_gid;
|
|
|
|
root_node->fn_dev = NO_DEV;
|
|
|
|
|
|
|
|
*res_flags = RES_NOFLAGS;
|
|
|
|
|
|
|
|
mounted = TRUE;
|
2011-11-14 12:53:05 +01:00
|
|
|
|
2011-11-29 16:02:37 +01:00
|
|
|
return(OK);
|
2011-11-14 12:53:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
2014-08-24 11:51:35 +02:00
|
|
|
* fs_mountpt *
|
2011-11-14 12:53:05 +01:00
|
|
|
*===========================================================================*/
|
2014-08-24 11:51:35 +02:00
|
|
|
int fs_mountpt(ino_t ino_nr)
|
2011-11-14 12:53:05 +01:00
|
|
|
{
|
|
|
|
/* This function looks up the mount point, it checks the condition whether
|
|
|
|
* the partition can be mounted on the pnode or not.
|
|
|
|
*/
|
|
|
|
int r = OK;
|
|
|
|
struct puffs_node *pn;
|
2014-04-29 15:35:42 +02:00
|
|
|
mode_t bits;
|
2011-11-14 12:53:05 +01:00
|
|
|
|
2014-08-24 11:51:35 +02:00
|
|
|
if ((pn = puffs_pn_nodewalk(global_pu, 0, &ino_nr)) == NULL)
|
2011-11-14 12:53:05 +01:00
|
|
|
return(EINVAL);
|
|
|
|
|
|
|
|
if (pn->pn_mountpoint) r = EBUSY;
|
|
|
|
|
|
|
|
/* It may not be special. */
|
|
|
|
bits = pn->pn_va.va_mode & I_TYPE;
|
|
|
|
if(bits == I_BLOCK_SPECIAL || bits == I_CHAR_SPECIAL) r = ENOTDIR;
|
|
|
|
|
|
|
|
if (r == OK)
|
|
|
|
pn->pn_mountpoint = TRUE;
|
|
|
|
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* fs_unmount *
|
|
|
|
*===========================================================================*/
|
2014-08-24 11:51:35 +02:00
|
|
|
void fs_unmount(void)
|
2011-11-14 12:53:05 +01:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
2014-08-24 11:51:35 +02:00
|
|
|
/* Always force unmounting, as VFS will not tolerate failure. */
|
|
|
|
error = global_pu->pu_ops.puffs_fs_unmount(global_pu, MNT_FORCE);
|
2011-11-14 12:53:05 +01:00
|
|
|
if (error) {
|
|
|
|
lpuffs_debug("user handler failed to unmount filesystem!\
|
|
|
|
Force unmount!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
fs_sync();
|
|
|
|
|
|
|
|
/* Finish off the unmount. */
|
|
|
|
PU_SETSTATE(global_pu, PUFFS_STATE_UNMOUNTED);
|
2014-08-24 11:51:35 +02:00
|
|
|
mounted = FALSE;
|
2011-11-14 12:53:05 +01:00
|
|
|
global_pu->pu_pn_root->pn_count--;
|
|
|
|
}
|