[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `disk` level IO: how it works?
From: |
Robert Millan |
Subject: |
Re: `disk` level IO: how it works? |
Date: |
Tue, 22 Jan 2008 21:00:29 +0100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
On Tue, Jan 22, 2008 at 08:01:56AM +0000, Oleg Strikov wrote:
> Good day!
> I'm trying to look into grub low-level disk IO.
> I've started exploration with my own low-level FS block reader, but it
> works too strange:
>
> /* I know that such code is incorrect due to low-level FS operations but i'm
> trying to understand some principals of low level IO :) */
>
> file = grub_file_open (FILE);
> fs_data = (struct grub_ext2_data *) file->data;
> disk = fs_data->disk;
>
> fsize = grub_file_size(file);
> block_num = (fsize >> LOG2_BLOCK_SIZE (fs_data));
> if (((grub_off_t) block_num << LOG2_BLOCK_SIZE (fs_data)) != fsize)
> block_num++;
>
> log2_blksz = LOG2_EXT2_BLOCK_SIZE (fs_data);
>
> blocks = grub_malloc (sizeof (int) * block_num);
>
> fshelp_node = &fs_data->diropen;
>
> for (i = 0; i < block_num; i++)
> {
> blocks[i] = grub_ext2_read_block_wrapper (fshelp_node, i);
> }
>
> grub_disk_read(fs_data->disk,
> \
> grub_le_to_cpu32 (blocks[i]) << log2_blksz, \
> 0,
> \
> sizeof (struct my_entry),
> \
> (char *) entry);
>
> grub_ext2_read_block_wrapper its my exported wrapper from ext2.c that calls
> original grub_ext2_read_block with the same parameters.
I find this very confusing. Could you rephrase your question to make it more
specific? Like, what are you trying to do or which function you don't
understand.
> Problem: I have extended partition with two logical (hd0,5) & (hd0,6)
> If I place FILE on (hd0,5) (at the begining of my physical disk) - all is OK
> If I place FILE on (hd0,6) i get `out of partition` at grub_disk_read.
Did you check if debug options give you anything useful? Try "set debug=disk",
and maybe also "set debug=fs".
What's the size of your disk, and your partitions?
> P.S. I'm right that `disk` represents one partition (logical or primary),
> not a group?
I think grub_disk_t can either be a partition or a disk.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)