8000 minix/minix/servers/vfs/mount.c at R3.3.0 · cppfool/minix · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
641 lines (539 loc) · 18.2 KB

mount.c

File metadata and controls

641 lines (539 loc) · 18.2 KB
/* Verify we succesfully unmounted all file systems */
for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; vmp++) {
if (vmp->m_dev != NO_DEV) {
panic("vmp still mounted: %s %d %llx\n", vmp->m_label,
vmp->m_fs_e, vmp->m_dev);
}
}
}
/*===========================================================================*
* name_to_dev *
*===========================================================================*/
static dev_t name_to_dev(int allow_mountpt, char path[PATH_MAX])
{
/* Convert the block special file in 'user_fullpath' to a device number.
* If the given path is not a block special file, but 'allow_mountpt' is set
* and the path is the root node of a mounted file system, return that device
* number. In all other cases, return NO_DEV and an error code in 'err_code'.
*/
dev_t dev;
struct vnode *vp;
struct vmnt *vmp;
struct lookup resolve;
lookup_init(&resolve, path, PATH_NOFLAGS, &vmp, &vp);
resolve.l_vmnt_lock = VMNT_READ;
resolve.l_vnode_lock = VNODE_READ;
/* Request lookup */
if ((vp = eat_path(&resolve, fp)) == NULL) return(NO_DEV);
if (S_ISBLK(vp->v_mode)) {
dev = vp->v_sdev;
} else if (allow_mountpt && vp->v_vmnt->m_root_node == vp) {
dev = vp->v_dev;
} else {
err_code = ENOTBLK;
dev = NO_DEV;
}
unlock_vnode(vp);
unlock_vmnt(vmp);
put_vnode(vp);
return(dev);
}
/*===========================================================================*
* is_nonedev *
*===========================================================================*/
int is_nonedev(dev_t dev)
{
/* Return whether the given device is a "none" pseudo device.
*/
return (major(dev) == NONE_MAJOR &&
minor(dev) > 0 && minor(dev) <= NR_NONEDEVS);
}
/*===========================================================================*
* find_free_nonedev *
*===========================================================================*/
static dev_t find_free_nonedev(void)
{
/* Find a free "none" pseudo device. Do not allocate it yet.
*/
int i;
for (i = 0; i < NR_NONEDEVS; i++)
if (!GET_BIT(nonedev, i))
return makedev(NONE_MAJOR, i + 1);
err_code = EMFILE;
return NO_DEV;
}
0