Page 1 of 1
Cant read a file from initrd
Posted: Thu Jan 01, 2009 9:20 am
by goku
I am using JamesM tutorial and facing some problem loading initial ramdisk image.
The initrd is loaded by grub as a module and it is loading alright and i am able to read a directory from it as well but i am unable to read two text file which have been added to initrd. Using the tutorial source code i can read the directory and the two files from the same initrd image. So i guess the problem lies in the kernel code. Cant really figure out whats the cause of the problem as i am using the same source code. I have attached the source code.
Using gcc, nasm, bochs on Ubuntu 8.10.
Please help out guys.
Thanks.
Re: Cant read a file from initrd
Posted: Sun Jan 04, 2009 1:36 pm
by goku
Ok i have narrowed down the problem. I have both the kernel i compiled and JamesM kernel on the same floppy both reading a common initrd image file. Initial ramdisk contains a root director with 3 child, first /dev (which is marked as a directory), and 2 text files. After grub loads the initrd.img as a module i checked the initrd_header from the location returned in multiboot header.
Here is the multiboot header :
Code: Select all
struct multiboot
{
u32int flags;
u32int mem_lower;
u32int mem_upper;
u32int boot_device;
u32int cmdline;
u32int mods_count;
u32int mods_addr;
u32int num;
u32int size;
u32int addr;
u32int shndx;
u32int mmap_length;
u32int mmap_addr;
u32int drives_length;
u32int drives_addr;
u32int config_table;
u32int boot_loader_name;
u32int apm_table;
u32int vbe_control_info;
u32int vbe_mode_info;
u32int vbe_mode;
u32int vbe_interface_seg;
u32int vbe_interface_off;
u32int vbe_interface_len;
} __attribute__((packed));
Used the following code to display the number of files in the initrd.img file header
Code: Select all
u32int initrd_location = *((u32int*)mboot_ptr->mods_addr);
u32int initrd_end = *(u32int*)(mboot_ptr->mods_addr+4);
initrd_header_t *initrd_header;
initrd_header = (initrd_header_t *)initrd_location;
monitor_write("\ninitrd_header->nfiles = ");
monitor_write_dec(initrd_header->nfiles);
Leaving rest of the code aside, the above should display the same output irrespective of the kernel which i am booting since it is essentially reading from the same image file. But booting James kernel it gives the output 2 (which is the correct number of files) and when i try to boot it gives 0. Cant really figure out why??????
Please help me out.
Thanks.
Re: Cant read a file from initrd
Posted: Tue Jan 06, 2009 12:40 pm
by goku
Well thanks for the encouragement i am still working on it.
Cheers