lkml.org 
[lkml]   [1998]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: read on /dev/hd? ?
Date
From

>
>
> Vladimir Dergachev wrote:
> > If I make a read on /dev/hd? as a file (after doing lseek)
> > would the data I read put in the buffer and later reused
> > if filesystem tried to access the disk ?
>
> Do you mean "will be reads go through the buffer cache"? The answer is yes.

The question is this : suppose that /dev/hda4 has an ext2 partition on it.
Suppose also that a file in this partition has blocks 1,2,1024. Suppose
also that a program read /dev/hda4 directly (as a file (and it doesn't mmap))
so that blocks 1 2 and 1024 were read. Now if I were to read the same file
but using the files inode (i.e. thru the ext2 partition) would the VFS
recognize that I am going for the same blocks ? (I think that the answer
to this is yes though I am not sure). The other part of the question is that
if the file was executable and I tried to execute it (or mmap) will the same
happen ? Apparently there is big difference to the kernel whether the
file is mmaped or just read.. So far I couldn't make my test program
load /dev/hda4 in such a way so that the blocks get reused when the files
are read thru ext2.. But it could be well that I got the block numbers
wrong.. (Btw can anybody tell me if I talk about block 731 should I lseek
to 512*731 or 1024*731 ? I think I heard somewhere that SCSI uses 512byte
blocks but I actually have IDE drives so I don't know)


>
> > Is it dangerous to read a mounted device ? (only read)
>
> Depends on how you define "dangerous". You can't hurt the filesystem by
> just reading. However if the filesystem is active, the application doing
> the reads might get nasty surprises as things change under it. For
> best safety, remount the filesystem read-only also.
>

Thanks..

> -Mitch
>

Vladimir Dergachev

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html

\
 
 \ /
  Last update: 2005-03-22 13:44    [W:0.026 / U:0.792 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site