예제 #1
0
/**
 * Based on fs/ext3/super.c:1630. Can't use bread, however. 
 */
extern int ljx_ext3_fill_super(
		struct xen_vbd *vbd,
		struct ext3_super_block *sb, 
		int silent
) {
	struct ljx_ext3_superblock *lsb;
	struct ljx_ext3_superblock **pp_lsb; 
	struct label *label;
	unsigned int blocksize, db_count, i, block, groups_left;

	lsb = kzalloc(sizeof(struct ljx_ext3_superblock), GFP_KERNEL);
	if (! lsb)
		return -ENOMEM;
	pp_lsb = &vbd->superblock;
	*pp_lsb = lsb;

	/* compute blocksize
	minsize = bdev_logical_block_size(vbd->bdev);
	size = EXT3_MIN_BLOCK_SIZE;
	if (size < minsize)
		size = minsize;
	*/
	blocksize = vbd->bdev->bd_block_size;

	lsb->inodes_count      =  le32_to_cpu(sb->s_inodes_count);
	lsb->blocks_count      =  le32_to_cpu(sb->s_blocks_count);
	lsb->inode_size        =  le32_to_cpu(sb->s_inode_size);
	lsb->first_data_block  =  le32_to_cpu(sb->s_first_data_block);
	lsb->log_block_size    =  le32_to_cpu(sb->s_log_block_size);
	lsb->log_frag_size     =  le32_to_cpu(sb->s_log_frag_size);
	lsb->blocks_per_group  =  le32_to_cpu(sb->s_blocks_per_group);
	lsb->frags_per_group   =  le32_to_cpu(sb->s_frags_per_group);
	lsb->inodes_per_group  =  le32_to_cpu(sb->s_inodes_per_group);
	lsb->first_inode       =  le32_to_cpu(sb->s_first_ino);
	lsb->journal_inum      =  le32_to_cpu(sb->s_journal_inum);
	lsb->inodes_per_block  =  blocksize / le32_to_cpu(sb->s_inode_size);
	lsb->desc_per_block    =  blocksize / sizeof(struct ext3_group_desc);
	lsb->groups_count      =  ((le32_to_cpu(sb->s_blocks_count) -
			       le32_to_cpu(sb->s_first_data_block) - 1)
				       / lsb->blocks_per_group) + 1;
	lsb->first_meta_bg     =  le32_to_cpu(sb->s_first_meta_bg);
	lsb->feature_incompat  =  le32_to_cpu(sb->s_feature_incompat);
	lsb->feature_ro_compat  =  le32_to_cpu(sb->s_feature_ro_compat);
	lsb->block_size		=  EXT3_MIN_BLOCK_SIZE << lsb->log_block_size;

	db_count = DIV_ROUND_UP(lsb->groups_count, lsb->desc_per_block);
	lsb->group_desc = kzalloc(db_count * sizeof(struct ljx_ext3_group_desc *),
			GFP_KERNEL);
	if (lsb->group_desc == NULL)
		return -ENOMEM;
	lsb->group_desc = kzalloc(db_count * sizeof(*lsb->group_desc), GFP_KERNEL);
	groups_left = lsb->groups_count;
	for (i = 0; i < db_count; i++) {
		block = descriptor_loc(lsb, i);
		lsb->group_desc[i].init = false;
		lsb->group_desc[i].location = block;
		JPRINTK("group desc at %u", block);
		label = insert_label(
				&vbd->label_list, 
				block, 
				8,
				GROUP_DESC
		);
		label->processor = &process_group_desc;
	}
	JPRINTK("Total number of groups: %u", lsb->groups_count);
	print_label_list(&vbd->label_list);

	return 0;
}
예제 #2
0
파일: simple.c 프로젝트: jeppeter/elilo
/*
 * interactively select a kernel image and options.
 * The kernel can be an actual filename or a label in the config file
 * Return:
 * 	-1: if unsucessful
 * 	 0: otherwise
 */
static INTN
select_kernel(CHAR16 *buffer, INTN size)
{
#define CHAR_CTRL_C	L'\003' /* Unicode CTRL-C */
#define CHAR_CTRL_D	L'\004' /* Unicode CTRL-D */
#define CHAR_CTRL_U	L'\025' /* Unicode CTRL-U */
//#define CHAR_TAB	L'\t'
	SIMPLE_INPUT_INTERFACE *ip = systab->ConIn;
	EFI_INPUT_KEY key;
	EFI_STATUS status;
	INTN pos = 0, ret;
	INT8 first_time = 1;

	/* 
	 * let's give some help first
	 */
	print_help(0);

	print_infos(0);

reprint:
	buffer[pos] = CHAR_NULL;

	Print(L"\nELILO boot: %s", buffer);
	/*
	 * autoboot with default choice after timeout expires
	 */
	if (first_time && (ret=wait_timeout(elilo_opt.timeout)) != 1) {
		return ret == -1 ? -1: 0;
	}
	first_time = 0;

	for (;;) {
		while ((status = uefi_call_wrapper(ip->ReadKeyStroke, 2, ip, &key))
				 == EFI_NOT_READY);
		if (EFI_ERROR(status)) {
			ERR_PRT((L"select_kernel readkey: %r", status));
			return -1;
		} 
		switch (key.UnicodeChar) {
			case CHAR_TAB:
				Print(L"\n");
				if (pos == 0) {
					print_label_list();
					Print(L"(or a kernel file name: [[dev_name:/]path/]kernel_image cmdline options)\n");
				} else {
					buffer[pos] = CHAR_NULL;
					display_label_info(buffer);
				}
				goto reprint;
			case L'%':
				if (pos>0) goto normal_char;
				Print(L"\n");
				print_vars();
				goto reprint;
			case L'?':
				if (pos>0) goto normal_char;
				Print(L"\n");
				print_help(1);
				goto reprint;
			case L'&':
				if (pos>0) goto normal_char;
				Print(L"\n");
				print_infos(1);
				goto reprint;
			case L'=':
				if (pos>0) goto normal_char;
				Print(L"\n");
				print_devices();
				goto reprint;
			case CHAR_BACKSPACE:
				if (pos == 0) break;
				pos--;
				Print(L"\b \b");
				break;
			case CHAR_CTRL_U: /* clear line */
				while (pos) {
					Print(L"\b \b");
					pos--;
				}
				break;
			case CHAR_CTRL_C: /* kill line */
				pos = 0;
				goto reprint;
			case CHAR_LINEFEED:
			case CHAR_CARRIAGE_RETURN:
				buffer[pos]   = CHAR_NULL;
				Print(L"\n");
				return 0;
			default:
normal_char:
				if (key.UnicodeChar == CHAR_CTRL_D || key.ScanCode == 0x17 ) {
					Print(L"\nGiving up then...\n");
					return  -1;
				}
				if (key.UnicodeChar == CHAR_NULL) break;

				if (pos > size-1) break;

				buffer[pos++] = key.UnicodeChar;

				/* Write the character out */
				Print(L"%c", key.UnicodeChar);
		}
	}
	return 0;
}