b1d068470b
isofs now uses an in-memory directory listing built on-the-fly instead of parsing the ISO 9660 data structures over and over for almost every request. This yields huge performance improvements. The directory listing is allocated dynamically, but Minix servers aren't normally supposed to do that because critical servers would crash if the system runs out of memory. isofs is quite frugal, won't allocate memory after having the whole directory tree cached and is not that critical (its most important job is to serve as a root file system during installation). The benefits and elegance of this scheme far outweights this small problem in practice. Change-Id: I13d070388c07d274cbee0645cbc50295c447c5b6
67 lines
1.4 KiB
C
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 = get_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)
|
|
puts("ISOFS: unmounting with in-use inodes!\n");
|
|
}
|