Solved

What is the best way to program for direct disk access?

Posted on 2007-12-02
3
897 Views
Last Modified: 2008-02-18
I am experimenting with some database technology and would like to write a protoype system that can access a disk drive directly. Note that I do not want to use a filesystem managed by the OS. I will manage the access to each sector on the drive. I would like to build this prototype in a high-level language and thus would like the simplest way to access a specific sector on a drive. What is the best way to accomplish this? Is one drive interface technology easier to do this than another? (EIDE, SCSI, SATA, etc.) Will the new drive already have the current bad blocks mapped out or will I need to take care of this myself? I would prefer to use Windows XP but would consider Linux if it is easier to accomplish this.
0
Comment
Question by:Philsh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 43

Accepted Solution

by:
ravenpl earned 250 total points
ID: 20391907
Linux is very easy. You just opening file like
/dev/sdb # for whole second sata/scsi drive
or
/dev/sdb2 # for second partition

Then You operate just like on regular file (eg. pread() pwrite())
No filesystem overhead - just direct raw device access(via driver of course).
0
 
LVL 25

Assisted Solution

by:kode99
kode99 earned 250 total points
ID: 20394176
Its not that hard in windows either.  Pretty similar to linux,  open the device/partition with a CreateFile then access  and then use ReadFile or WriteFile to do the work.

MS article which just mentions roughly how to do it,

http://support.microsoft.com/kb/q100027/

Here's an example in C,  the example covers win98 which is different from xp/2000

http://www.codeguru.com/cpp/w-p/system/misc/article.php/c5765/

If you are so inclinded here is a Delphi wrapper for direct access.  Includes source and is free to use.

http://www.e-f-w.com/content.php?cid=rda

Since you are not trying to work with a filesystem it is fairly straight forward as you do not need to worry about the data structures that a given filesystem uses.  

You will need to keep track of bad sectors though.  So you will probably want to create your own virtual layer between the application and the raw read/writes that will take care of avoiding bad spots. Possibly also do some level of write verification too.

It does not make a difference what type of drive you access.

0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Your hard drive is full! Do you know what is filling it up? A small free (trial period) utility will solve the problem.  It is SpaceMonger.  It can show you visually the content of your hard drive as blocks with different color and sizes depending…
Solid State (Hard) Drives aka SSD began to evolve in the computer industry recently. As the name suggests, there are no moving parts in the drives. The drive uses microchip memory store the data, as opposed to the spinning disks of a traditional HDD…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question