kernels/linux-2.4.0/fs/minix/inode.c
/*
 * The minix V2 function to read an inode.
 */
The minix V2 function to read an inode.
The minix V2 function to read an inode .
static void V2_minix_read_inode(struct inode * inode)
{
	struct buffer_head * bh;
	struct minix2_inode * raw_inode;
	int block, ino;
	ino = inode->i_ino;
	inode->i_mode = 0;
	if (!ino || ino > inode->i_sb->u.minix_sb.s_ninodes) {
		printk("Bad inode number on dev %s"
		       ": %d is out of range\n",
			kdevname(inode->i_dev), ino);
		return;
	}
	block = 2 + inode->i_sb->u.minix_sb.s_imap_blocks +
		    inode->i_sb->u.minix_sb.s_zmap_blocks +
		    (ino-1)/MINIX2_INODES_PER_BLOCK;
	if (!(bh=bread(inode->i_dev,block, BLOCK_SIZE))) {
		printk("Major problem: unable to read inode from dev "
		       "%s\n", kdevname(inode->i_dev));
		return;
	}
	raw_inode = ((struct minix2_inode *) bh->b_data) +
		    (ino-1)%MINIX2_INODES_PER_BLOCK;
	inode->i_mode = raw_inode->i_mode;
	inode->i_uid = (uid_t)raw_inode->i_uid;
	inode->i_gid = (gid_t)raw_inode->i_gid;
	inode->i_nlink = raw_inode->i_nlinks;
	inode->i_size = raw_inode->i_size;
	inode->i_mtime = raw_inode->i_mtime;
	inode->i_atime = raw_inode->i_atime;
	inode->i_ctime = raw_inode->i_ctime;
	inode->i_blocks = inode->i_blksize = 0;
	for (block = 0; block < 10; block++)
		inode->u.minix_i.u.i2_data[block] = raw_inode->i_zone[block];
	if (S_ISREG(inode->i_mode)) {
		inode->i_op = &minix_file_inode_operations;
		inode->i_fop = &minix_file_operations;
		inode->i_mapping->a_ops = &minix_aops;
	} else if (S_ISDIR(inode->i_mode)) {
		inode->i_op = &minix_dir_inode_operations;
		inode->i_fop = &minix_dir_operations;
	} else if (S_ISLNK(inode->i_mode)) {
		inode->i_op = &page_symlink_inode_operations;
		inode->i_mapping->a_ops = &minix_aops;
	} else
		init_special_inode(inode, inode->i_mode, raw_inode->i_zone[0]);
	brelse(bh);
}
static void V2_minix_read_inode ( struct inode * inode ) { struct buffer_head * bh ; struct minix2_inode * raw_inode ; int block , ino ; ino = inode -> i_ino ; inode -> i_mode = 0 ; if ( ! ino || ino > inode -> i_sb -> u . minix_sb . s_ninodes ) { printk ( " " " \n " , kdevname ( inode -> i_dev ) , ino ) ; return ; } block = 2 + inode -> i_sb -> u . minix_sb . s_imap_blocks + inode -> i_sb -> u . minix_sb . s_zmap_blocks + ( ino - 1 ) / MINIX2_INODES_PER_BLOCK ; if ( ! ( bh = bread ( inode -> i_dev , block , BLOCK_SIZE ) ) ) { printk ( " " " \n " , kdevname ( inode -> i_dev ) ) ; return ; } raw_inode = ( ( struct minix2_inode * ) bh -> b_data ) + ( ino - 1 ) % MINIX2_INODES_PER_BLOCK ; inode -> i_mode = raw_inode -> i_mode ; inode -> i_uid = ( uid_t ) raw_inode -> i_uid ; inode -> i_gid = ( gid_t ) raw_inode -> i_gid ; inode -> i_nlink = raw_inode -> i_nlinks ; inode -> i_size = raw_inode -> i_size ; inode -> i_mtime = raw_inode -> i_mtime ; inode -> i_atime = raw_inode -> i_atime ; inode -> i_ctime = raw_inode -> i_ctime ; inode -> i_blocks = inode -> i_blksize = 0 ; for ( block = 0 ; block < 10 ; block ++ ) inode -> u . minix_i . u . i2_data [ block ] = raw_inode -> i_zone [ block ] ; if ( S_ISREG ( inode -> i_mode ) ) { inode -> i_op = & minix_file_inode_operations ; inode -> i_fop = & minix_file_operations ; inode -> i_mapping -> a_ops = & minix_aops ; } else if ( S_ISDIR ( inode -> i_mode ) ) { inode -> i_op = & minix_dir_inode_operations ; inode -> i_fop = & minix_dir_operations ; } else if ( S_ISLNK ( inode -> i_mode ) ) { inode -> i_op = & page_symlink_inode_operations ; inode -> i_mapping -> a_ops = & minix_aops ; } else init_special_inode ( inode , inode -> i_mode , raw_inode -> i_zone [ 0 ] ) ; brelse ( bh ) ; }
The minix V2 function to read an inode.
The minix V2 function to read an inode .