Beispiel #1
0
int minix_bmap(struct inode * inode,int block)
{
	int i;

	if (block<0) {
		printk("minix_bmap: block<0");
		return 0;
	}
	if (block >= 7+512+512*512) {
		printk("minix_bmap: block>big");
		return 0;
	}
	if (block < 7)
		return inode_bmap(inode,block);
	block -= 7;
	if (block < 512) {
		i = inode_bmap(inode,7);
		if (!i)
			return 0;
		return block_bmap(bread(inode->i_dev,i,BLOCK_SIZE),block);
	}
	block -= 512;
	i = inode_bmap(inode,8);
	if (!i)
		return 0;
	i = block_bmap(bread(inode->i_dev,i,BLOCK_SIZE),block>>9);
	if (!i)
		return 0;
	return block_bmap(bread(inode->i_dev,i,BLOCK_SIZE),block & 511);
}
Beispiel #2
0
int sysv_bmap(struct inode * inode,int block_nr)
{
    unsigned int block = block_nr;
    struct super_block * sb = inode->i_sb;
    int convert;
    int i;
    struct buffer_head * bh;

    if (block < 10)
        return inode_bmap(sb,inode,block);
    block -= 10;
    convert = sb->sv_convert;
    if (block < IND_PER_BLOCK) {
        i = inode_bmap(sb,inode,10);
        if (!i)
            return 0;
        bh = bread(inode->i_dev,i,BLOCK_SIZE);
        return block_bmap(sb,bh,block,convert);
    }
    block -= IND_PER_BLOCK;
    if (block < IND_PER_BLOCK*IND_PER_BLOCK) {
        i = inode_bmap(sb,inode,11);
        if (!i)
            return 0;
        bh = bread(inode->i_dev,i,BLOCK_SIZE);
        i = block_bmap(sb,bh,block/IND_PER_BLOCK,convert);
        if (!i)
            return 0;
        bh = bread(inode->i_dev,i,BLOCK_SIZE);
        return block_bmap(sb,bh,block%IND_PER_BLOCK,convert);
    }
    block -= IND_PER_BLOCK*IND_PER_BLOCK;
    if (block < IND_PER_BLOCK*IND_PER_BLOCK*IND_PER_BLOCK) {
        i = inode_bmap(sb,inode,12);
        if (!i)
            return 0;
        bh = bread(inode->i_dev,i,BLOCK_SIZE);
        i = block_bmap(sb,bh,block/(IND_PER_BLOCK*IND_PER_BLOCK),convert);
        if (!i)
            return 0;
        bh = bread(inode->i_dev,i,BLOCK_SIZE);
        i = block_bmap(sb,bh,(block/IND_PER_BLOCK)%IND_PER_BLOCK,convert);
        if (!i)
            return 0;
        bh = bread(inode->i_dev,i,BLOCK_SIZE);
        return block_bmap(sb,bh,block%IND_PER_BLOCK,convert);
    }
    if ((int)block<0) {
        printk("sysv_bmap: block<0");
        return 0;
    }
    printk("sysv_bmap: block>big");
    return 0;
}