how do i read a block

Shampavman shampavman.cg at gmail.com
Wed May 15 09:43:31 EDT 2013


Sorry imeant 3blocks 

Sankar P <sankar.curiosity at gmail.com> wrote:

>On Mon, May 13, 2013 at 1:35 PM, shampavman <shampavman.cg at gmail.com> wrote:
>> Hi all,
>>
>> Supposing i create a file of size 10K, it will occupy 2 blocks (4K each).
>> Now if i want to read only 1 block from it how can i do it?
>>
>
>It will require 3 blocks.
>
>
>> read(fd, buf, 4096) ;
>> would this mean i would read the first block and all its contents?
>>
>
>It may be read even further (readahead)
>
>If you are in kernel mode, and if you want to implement your own
>filesystem and want to read a single block, you can use the sb_bread
>function.
>
>
>--
>Sankar P
>http://psankar.blogspot.com


More information about the Kernelnewbies mailing list