Getting a block from a block device?
Dan Luedtke
maildanrl at googlemail.com
Tue Nov 8 09:02:26 EST 2011
Thanks for all the answers!
> You need to look at other block-based file systems in the kernel sources in fs dir for examples and understand how they do it.
I looked at fs/minix/* fs/fat/* and peeked into fs/ext2/, but got more
confused so I decided to ask for a starting point.
> Also i think if you are interested in reading the first sector
> then you can probably check the block/genhd.c file
> get the disk (i.e struct genhd) then the partition (struct hdpart)
> you will be able to get the first sector.
Thanks, a well documented source file. However, shouldn't I get the
right partition (I called it block device in previously sent mails,
thought of e.g. /dev/sda2 as a device not a partition) from VFS when a
user requestes mounting it?
> That's an old assignment from my uni.
Wow, exactly what I needed! Thanks for this starting point.
> I would redirect you to learn about struct gendisk and struct bio.
Noted, I will take a look after studying the vvfs-files from Stephens link.
> Can you tell what are you trying to achieve?
I'd like to implement a filesystem as kernel modul (like fat, ext2,
...). The filesystem is a very simple one, based on chained blocks
(similar to linked lists in c). I "invented" it when I tried to write
a bootloader that does not require a second stage to read an kernel
image. (This is all more or less a "because we can"-project, no
commercial background, just learning).
Once again, thank you guys!
Greetings,
Dan
--
Dan Luedtke
http://www.danrl.de
More information about the Kernelnewbies
mailing list