close device if mount fails after device opened.

This commit is contained in:
Ben Gras 2007-09-26 15:06:41 +00:00
parent b74b3315a3
commit b6e07e1835

View File

@ -91,15 +91,21 @@ PUBLIC int fs_readsuper_s()
/* Is it recognized as a Minix filesystem? */
if (r != OK) {
sp->s_dev = NO_DEV;
dev_close(driver_e, fs_dev);
return(r);
}
/* Get the root inode of the mounted file system. */
if ( (root_ip = get_inode(fs_dev, ROOT_INODE)) == NIL_INODE)
if ( (root_ip = get_inode(fs_dev, ROOT_INODE)) == NIL_INODE) {
sp->s_dev = NO_DEV;
dev_close(driver_e, fs_dev);
return err_code;
}
if (root_ip != NIL_INODE && root_ip->i_mode == 0) {
put_inode(root_ip);
sp->s_dev = NO_DEV;
dev_close(driver_e, fs_dev);
return EINVAL;
}