1. hard drive access
- Posted by useless_ Nov 18, 2013
- 1758 views
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
2. Re: hard drive access
- Posted by jimcbrown (admin) Nov 19, 2013
- 1819 views
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://stackoverflow.com/questions/2108313/how-to-access-specific-raw-data-on-disk-from-java
3. Re: hard drive access
- Posted by fizzpopsoft Nov 21, 2013
- 1475 views
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
4. Re: hard drive access
- Posted by fizzpopsoft Nov 21, 2013
- 1536 views
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.
5. Re: hard drive access
- Posted by jimcbrown (admin) Nov 21, 2013
- 1501 views
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.
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.