<div> </div>
<div>if you wanna open a block device specificallyy </div>
<div>you can look into fs/block_dev.c </div>
<div> </div>
<div>struct block_device *open_bdev_exclusive(const char *path, fmode_t mode, void *holder)</div>
<div> </div>
<div>Also i think if you are interested in reading the first sector </div>
<div>then you can probably check the block/genhd.c file </div>
<div>get the disk (i.e struct genhd) then the partition (struct hdpart) </div>
<div>you will be able to get the first sector. </div>
<div> </div>
<div>Thanks </div>
<div> </div>
<div class="gmail_quote">On Tue, Nov 8, 2011 at 5:29 PM, rohan puri <span dir="ltr"><<a href="mailto:rohan.puri15@gmail.com">rohan.puri15@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div class="HOEnZb">
<div class="h5"><br><br>
<div class="gmail_quote">On Tue, Nov 8, 2011 at 5:26 PM, Dan Luedtke <span dir="ltr"><<a href="mailto:maildanrl@googlemail.com" target="_blank">maildanrl@googlemail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Hallo,<br><br>On Tue, Nov 8, 2011 at 12:27 PM, Stephen Gream <<a href="mailto:poisonthemon@gmail.com" target="_blank">poisonthemon@gmail.com</a>> wrote:<br>
> Once you have the device registered (on /sys or /dev), register a read<br>> callback on the file and use copy_to_user to output the data<br><br>I read that article you referred to, but I don't think it addresses my<br>
problem, as I may have been more clear on what I want to achieve<br>before. Sorry for that!<br>I want to eventually implement a file system, and therefore I am<br>studying the kernel sources to get an idea about all that.<br>
<br>Here is my general understanding on how thinks may work :)<br><br>virtual file system (VFS) <-[1]-> my file system implementation<br><-[2]-> a block device<br><br>As I understood, all these subsystems are running in kernel mode.<br>
<br>For [1] I read vfs.txt and learned about the VFS-API<br>For [2] I have no idea where I can find the API documentation, however<br>there were some hints on the book "Linux Driver Development" from<br>O'Reilly in chapter "block devices". Nothing really helpful, as they<br>
were talking about registering new block devices. I want to use<br>already present devices where I expect my filesystem to be present on.<br>To check that, I have to read the first 512 bytes.<br><br>The userspace implementation I was talking about previously is<br>
something like a mkfs.myfilesystem, that's why i referred to fopen()<br>there.<br><br>Thank you!<br><br>Greetings,<br>
<div>
<div></div>
<div><br>Dan<br>--<br>Dan Luedtke<br><a href="http://www.danrl.de/" target="_blank">http://www.danrl.de</a><br><br>_______________________________________________<br>Kernelnewbies mailing list<br><a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br></div></div></blockquote></div></div></div>Dan,<br><br>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.<br>
<br>Regards,<span class="HOEnZb"><font color="#888888"><br>Rohan Puri<br></font></span><br>_______________________________________________<br>Kernelnewbies mailing list<br><a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br><br></blockquote></div><br>