From mboxrd@z Thu Jan 1 00:00:00 1970 From: manishrma@gmail.com (mani) Date: Tue, 8 Nov 2011 17:58:34 +0530 Subject: Getting a block from a block device? In-Reply-To: References: Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org if you wanna open a block device specificallyy you can look into fs/block_dev.c struct block_device *open_bdev_exclusive(const char *path, fmode_t mode, void *holder) 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 On Tue, Nov 8, 2011 at 5:29 PM, rohan puri wrote: > > > On Tue, Nov 8, 2011 at 5:26 PM, Dan Luedtke wrote: > >> Hallo, >> >> On Tue, Nov 8, 2011 at 12:27 PM, Stephen Gream >> wrote: >> > Once you have the device registered (on /sys or /dev), register a read >> > callback on the file and use copy_to_user to output the data >> >> I read that article you referred to, but I don't think it addresses my >> problem, as I may have been more clear on what I want to achieve >> before. Sorry for that! >> I want to eventually implement a file system, and therefore I am >> studying the kernel sources to get an idea about all that. >> >> Here is my general understanding on how thinks may work :) >> >> virtual file system (VFS) <-[1]-> my file system implementation >> <-[2]-> a block device >> >> As I understood, all these subsystems are running in kernel mode. >> >> For [1] I read vfs.txt and learned about the VFS-API >> For [2] I have no idea where I can find the API documentation, however >> there were some hints on the book "Linux Driver Development" from >> O'Reilly in chapter "block devices". Nothing really helpful, as they >> were talking about registering new block devices. I want to use >> already present devices where I expect my filesystem to be present on. >> To check that, I have to read the first 512 bytes. >> >> The userspace implementation I was talking about previously is >> something like a mkfs.myfilesystem, that's why i referred to fopen() >> there. >> >> Thank you! >> >> Greetings, >> >> Dan >> -- >> Dan Luedtke >> http://www.danrl.de >> >> _______________________________________________ >> Kernelnewbies mailing list >> Kernelnewbies at kernelnewbies.org >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >> > Dan, > > 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. > > Regards, > Rohan Puri > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111108/beed6f3f/attachment.html