1. hard drive access


Has anyone written a Euphoria include for accessing harddrives at sector level by specifying the LBA?

Because i have maybe a dozen files of 15Gbytes or more, and if i would gets() them in and then write them back out with the records aligned on sector boundries, i could then access each record in the file as datafile[sectornumber].

If anyone has tried this, and found it's better to use seek() in (whatever)byte increments, chime in too.

useless

new topic     » topic index » view message » categorize

2. Re: hard drive access

eukat said...


Has anyone written a Euphoria include for accessing harddrives at sector level by specifying the LBA?

Because i have maybe a dozen files of 15Gbytes or more, and if i would gets() them in and then write them back out with the records aligned on sector boundries, i could then access each record in the file as datafile[sectornumber].

If anyone has tried this, and found it's better to use seek() in (whatever)byte increments, chime in too.

I don't think one would need a special include to do this.

To move to a particular LBA address, just use seek() in 512 byte increments. I think the formula looks like

seek_position = (LBA_address + 1) * 512

On nix, one opens the file "/dev/sda" or etc using the normal open() routine. On Windoze, the file to open is different, but pretty much everything else is the same. (You need root/admin privs to be able to do so, obviously.) It's all straightforward if you know what you are doing. (Though I've only tried this on Linux/GNU....)

added: articles which have the file name to open on windoze

http://www.codeguru.com/cpp/w-p/system/misc/article.php/c5765/ReadingWriting-Disk-Sectors-Absolute-Disk-ReadWrite.htm

http://stackoverflow.com/questions/2108313/how-to-access-specific-raw-data-on-disk-from-java

new topic     » goto parent     » topic index » view message » categorize

3. Re: hard drive access

Another way to do this maybe...
Is there a way to force the allocation of a new file to be at a specified disk location (up front)
and ensure the file is contiguous? Then absolute disk read/write would not be necessary,
normal access using blocks as records would suffice.
And set the attributes like system and readonly to prevent relocating by defragging?

Cheers,
Alan

new topic     » goto parent     » topic index » view message » categorize

4. Re: hard drive access

Sorry, I hit post a bit early;)
Why not use your disk partitioner to create the partition which you use for exclusively for your direct access?
The partitioner will specify the cyl/head/sector during its allocation.
Just skip the first few bytes that's used for the FAT etc.

new topic     » goto parent     » topic index » view message » categorize

5. Re: hard drive access

fizzpopsoft said...

Another way to do this maybe...
Is there a way to force the allocation of a new file to be at a specified disk location (up front)
and ensure the file is contiguous? Then absolute disk read/write would not be necessary,
normal access using blocks as records would suffice.
And set the attributes like system and readonly to prevent relocating by defragging?

Cheers,
Alan

In a word, no. It depends on the operating system kernel and the file system being used, but in general one shouldn't trust that a file will be contiguous with a particular disk sector.

fizzpopsoft said...

Sorry, I hit post a bit early;)
Why not use your disk partitioner to create the partition which you use for exclusively for your direct access?
The partitioner will specify the cyl/head/sector during its allocation.
Just skip the first few bytes that's used for the FAT etc.

It depends on what one is trying to do. But this is a sound idea - IIRC Oracle uses this approach for its database (it manages the database directly on top of disk sectors, bypassing any use of a filesystem). If it's a brand new and empty partition, there's even no need to worry about the FAT.

This approach still requires some form of absolute disk access.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu