示例#1
0
文件: bdev.c 项目: DeanBoro/openiBoot
block_device_t *block_device_find(block_device_t *_prev)
{
	LinkedList *ptr;
	if(_prev == NULL)
		ptr = bdev_list.next;
	else
		ptr = &_prev->list_ptr;

	if(ptr == &bdev_list)
		return NULL;

	return bdev_get(ptr);
}
示例#2
0
文件: ext4.c 项目: JansZeng/g-bios
static int ext4_check_fs_type(const char *bdev_name)
{
	struct ext4_super_block *e4_sb;
	struct bio *bio;
	char buff[EXT4_SUPER_BLK_SIZE];
	struct block_device *bdev;
	uint32_t fc, frc, fi;
	int ret;

	bdev = bdev_get(bdev_name);
	if (NULL == bdev) {
		DPRINT("bdev %s not found!\n", bdev_name);
		return -ENODEV;
	}

	bio = bio_alloc();
	if (!bio)
		return -ENOMEM;

	bio->bdev = bdev;
	bio->sect = 1024 / SECT_SIZE;
	bio->size = sizeof(buff);
	bio->data = buff;
	submit_bio(READ, bio);
	// TODO: check flags here
	bio_free(bio);

	e4_sb = (struct ext4_super_block *)buff;

	if (0xEF53 != e4_sb->s_magic) {
		DPRINT("%s is not \"ext4\" fs!\n", bdev_name);
		return -EINVAL;
	}

	fc = e4_sb->s_feature_compat;
	fi = e4_sb->s_feature_incompat;
	frc = e4_sb->s_feature_ro_compat;


	ret = ck_ext4_feature(fc, frc, fi);

#ifdef CONFIG_DEBUG
	extern void ext_sb_list(struct ext4_super_block * esb);
	if (ret == 0) {
		ext_sb_list(e4_sb);
	}
#endif

	return ret;
}