kernels/linux-2.4.0/fs/minix/inode.c
/*
 * Check the root directory of the filesystem to make sure
 * it really _is_ a Minix filesystem, and to check the size
 * of the directory entry.
 */
Check the root directory of the filesystem to make sure
it really _is_ a Minix filesystem, and to check the size
of the directory entry.
Check the root directory of the filesystem to make sure it really _is_ a Minix filesystem and to check the size of the directory entry .
static const char * minix_checkroot(struct super_block *s, struct inode *dir)
{
	struct buffer_head *bh;
	struct minix_dir_entry *de;
	const char * errmsg;
	int dirsize;
	if (!S_ISDIR(dir->i_mode))
		return "root directory is not a directory";
	bh = minix_bread(dir, 0, 0);
	if (!bh)
		return "unable to read root directory";
	de = (struct minix_dir_entry *) bh->b_data;
	errmsg = "bad root directory '.' entry";
	dirsize = BLOCK_SIZE;
	if (de->inode == MINIX_ROOT_INO && strcmp(de->name, ".") == 0) {
		errmsg = "bad root directory '..' entry";
		dirsize = 8;
	}
	while ((dirsize <<= 1) < BLOCK_SIZE) {
		de = (struct minix_dir_entry *) (bh->b_data + dirsize);
		if (de->inode != MINIX_ROOT_INO)
			continue;
		if (strcmp(de->name, ".."))
			continue;
		s->u.minix_sb.s_dirsize = dirsize;
		s->u.minix_sb.s_namelen = dirsize - 2;
		errmsg = NULL;
		break;
	}
	brelse(bh);
	return errmsg;
}
static const char * minix_checkroot ( struct super_block * s , struct inode * dir ) { struct buffer_head * bh ; struct minix_dir_entry * de ; const char * errmsg ; int dirsize ; if ( ! S_ISDIR ( dir -> i_mode ) ) return " " ; bh = minix_bread ( dir , 0 , 0 ) ; if ( ! bh ) return " " ; de = ( struct minix_dir_entry * ) bh -> b_data ; errmsg = " " ; dirsize = BLOCK_SIZE ; if ( de -> inode == MINIX_ROOT_INO && strcmp ( de -> name , " " ) == 0 ) { errmsg = " " ; dirsize = 8 ; } while ( ( dirsize <<= 1 ) < BLOCK_SIZE ) { de = ( struct minix_dir_entry * ) ( bh -> b_data + dirsize ) ; if ( de -> inode != MINIX_ROOT_INO ) continue ; if ( strcmp ( de -> name , " " ) ) continue ; s -> u . minix_sb . s_dirsize = dirsize ; s -> u . minix_sb . s_namelen = dirsize - 2 ; errmsg = NULL ; break ; } brelse ( bh ) ; return errmsg ; }
Check the root directory of the filesystem to make sure
 it really _is_ a Minix filesystem, and to check the size
 of the directory entry.
Check the root directory of the filesystem to make sure it really _is_ a Minix filesystem and to check the size of the directory entry .