Open file from particular position?
I was asking yourself, if you had a specifically huge documents, claiming 64 MEGABYTES, is it feasible to identify the physical disk drive area of the documents, and afterwards read bytes from a certain countered right into the documents?
Allow is claim I'm interested in 100 bytes with a countered of 60 megabytes from the beginning of the documents. I do not desire the inadequacies of the thousands of disk seeks it would certainly require to obtain from the start of the documents throughout of the documents if I made use of some application degree seek() function.
Exists a remedy?
Many thanks a lot!
Rereading, it feels like possibly I really did not address the underlying inquiry:
Using "seek" at the application (actually, bit) degree does not always set you back any kind of "seeks" on disk - all it does is upgrade the countered number related to the documents take care of.
As soon as you ask the bit to read or write it will certainly convert that countered right into a disk countered, which might entail analysis obstructs to figure that out, yet has an ideal instance price of one look for - similar to your straight accessibility would certainly.
It is definitely feasible to do that: that is specifically what the documents system vehicle driver does, nevertheless, so it has to be feasible for somebody else. All you require is accessibility to the raw disk.
If the documents system remains in energetic usage you have some technological obstacles that make it tougher to do - due to the fact that the web content on disk is transforming in such a way that you can not fairly see - yet it is still feasible.
You can additionally ask the bit straight ; the xfs_bmap device does that, and also at the very least some documents systems implement the very same user interface so you can straight ask.
Computing the area will certainly take the very same variety of looks for that the bit would certainly take, however, so you are not likely to in fact conserve anything doing this.
I do not assume so.
If you open the documents, you'll either go to the start (for read/write) or completion (for append). Also in "update mode" you will not merely land in some defined area in the center of the documents.
I assume the most effective you can do is what you currently thwarted to: If you can compute the countered from the beginning you can look for to that area straight and also read the information. I do not assume this would certainly entail any kind of too much read procedures in - in between. You next read after opening up the documents needs to go to the computed countered.
You appear to have a false impression regarding just how
seek() acts. It does situate the area where the information at this countered is saved as successfully as feasible, without reviewing the interfering bytes. There will certainly be a couple of looks for (most likely not hundreds), to go across the block index.
What you can not do is conserve the traversal of the block index from one-time when the documents is opened up to the next. The OS would certainly need to bear in mind that the documents hasn't been changed or transferred given that the last time it was openeed, which would certainly call for remembering a great deal of information for a really tiny possible gain.
Keep in mind that the materials of a documents are not in successive disk placements, as a whole. Files often tend to be fragmented. Filesystems generally attempt to lower fragmentation, yet this can not be assured as a whole.