phunix/minix/fs/isofs/mount.c
David van Moolenbroek c2f99d7c3a isofs: rename source directory to "isofs"
Change-Id: Ibe630f720b4399e7ebbbd850650036fbaa9cec7b
2014-09-18 13:00:57 +00:00

67 lines
1.4 KiB
C

#include "inc.h"
#include <minix/vfsif.h>
int fs_mount(dev_t dev, unsigned int __unused flags,
struct fsdriver_node *root_node, unsigned int *res_flags)
{
int r;
fs_dev = dev;
/* Open the device the file system lives on in read only mode */
if (bdev_open(fs_dev, BDEV_R_BIT) != OK)
return EINVAL;
/* Read the superblock */
r = read_vds(&v_pri, fs_dev);
if (r != OK) {
bdev_close(fs_dev);
return r;
}
/* Return some root inode properties */
root_node->fn_ino_nr = v_pri.inode_root->i_stat.st_ino;
root_node->fn_mode = v_pri.inode_root->i_stat.st_mode;
root_node->fn_size = v_pri.inode_root->i_stat.st_size;
root_node->fn_uid = SYS_UID; /* Always root */
root_node->fn_gid = SYS_GID; /* operator */
root_node->fn_dev = NO_DEV;
*res_flags = RES_NOFLAGS;
return r;
}
int fs_mountpt(ino_t ino_nr)
{
/*
* This function looks up the mount point, it checks the condition
* whether the partition can be mounted on the inode or not.
*/
struct inode *rip;
if ((rip = find_inode(ino_nr)) == NULL)
return EINVAL;
if (rip->i_mountpoint)
return EBUSY;
/* The inode must be a directory. */
if ((rip->i_stat.st_mode & I_TYPE) != I_DIRECTORY)
return ENOTDIR;
rip->i_mountpoint = TRUE;
return OK;
}
void fs_unmount(void)
{
release_vol_pri_desc(&v_pri); /* Release the super block */
bdev_close(fs_dev);
if (check_inodes() == FALSE)
printf("ISOFS: unmounting with in-use inodes!\n");
}