Raw disk access

D

Daniel Rudy

How does one access the raw disk?

I have a USB thumb drive that will have many megabytes of data on it.
What I want to do is access the device raw and do reading from/writing
to the usb device itself. No partitions, no mounting, just raw disk
access to data in predefined structures that is on the device. I have
looked at Advanced Unix Programming (ISBN 0-13-141154-3) by Marc J.
Rochkind and it does mention a few things about it, but I want to know
more. Any documentation/references online that someone is willing to share?

I am running FreeBSD 6.x.

--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
 
I

Ian Collins

Daniel said:
How does one access the raw disk?

I have a USB thumb drive that will have many megabytes of data on it.
What I want to do is access the device raw and do reading from/writing
to the usb device itself. No partitions, no mounting, just raw disk
access to data in predefined structures that is on the device. I have
looked at Advanced Unix Programming (ISBN 0-13-141154-3) by Marc J.
Rochkind and it does mention a few things about it, but I want to know
more. Any documentation/references online that someone is willing to share?

I am running FreeBSD 6.x.
Either a BSD group or comp.unix.programmer would be a better place to ask.
 
C

christian.bau

How does one access the raw disk?

I have a USB thumb drive that will have many megabytes of data on it.
What I want to do is access the device raw and do reading from/writing
to the usb device itself. No partitions, no mounting, just raw disk
access to data in predefined structures that is on the device. I have
looked at Advanced Unix Programming (ISBN 0-13-141154-3) by Marc J.
Rochkind and it does mention a few things about it, but I want to know
more. Any documentation/references online that someone is willing to share?

Do a search for USB and "mass storage" devices.

The things that you are looking for might not even exist. USB
implements an interface. There is no knowing what is on the device
itself.
 
D

Daniel Rudy

At about the time of 3/23/2007 2:34 AM, Daniel Rudy stated the following:
How does one access the raw disk?

I have a USB thumb drive that will have many megabytes of data on it.
What I want to do is access the device raw and do reading from/writing
to the usb device itself. No partitions, no mounting, just raw disk
access to data in predefined structures that is on the device. I have
looked at Advanced Unix Programming (ISBN 0-13-141154-3) by Marc J.
Rochkind and it does mention a few things about it, but I want to know
more. Any documentation/references online that someone is willing to share?

I am running FreeBSD 6.x.

Opps....

Wrong group. That's what happens when you post at 2AM.


--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
 
D

daya

To access the USB drive in raw mode in Linux...do not mount the drive.
Just search the device file in the folder /dev
It will probably be /dev/sda or /dev/sdc.

Since all the devices are treated as files in linux.you can use the
file in raw mode
in C/C++ program

eg

FILE* fp=fopen("/dev/sda","r");

etc.
For writing you may probably need to run the program as root.

daya
 
F

Flash Gordon

daya wrote, On 23/03/07 16:54:
To access the USB drive in raw mode in Linux...do not mount the drive.
Just search the device file in the folder /dev
It will probably be /dev/sda or /dev/sdc.

Since all the devices are treated as files in linux.you can use the
file in raw mode
in C/C++ program

I think you mean binary mode, C does not have a raw mode.
eg

FILE* fp=fopen("/dev/sda","r");

That would open it in text mode which is not what you want (although it
does not make much difference on Linux). You should use "rb" for binary.
etc.
For writing you may probably need to run the program as root.

All this would be best discussed on a Linux or Unix programming group
where the specifics of the system are topical. They are not topical here.
 
D

Daniel Rudy

At about the time of 3/23/2007 1:08 PM, Flash Gordon stated the following:
daya wrote, On 23/03/07 16:54:

I think you mean binary mode, C does not have a raw mode.

No, I mean raw device access mode in Unix, when the disk looks just like
a bunch of data blocks and you can view the partition table and
filesystem structures that the kernel uses to keep track of things on
the disk. In my case, it's a USB flash drive.
That would open it in text mode which is not what you want (although it
does not make much difference on Linux). You should use "rb" for binary.

It would have to be binary mode.
All this would be best discussed on a Linux or Unix programming group
where the specifics of the system are topical. They are not topical here.

Which is why I posted a follow-up message indicating that I posted to
the wrong group. The poster that you replied to snipped my post that
made a statement to that fact.


--
Daniel Rudy

Email address has been base64 encoded to reduce spam
Decode email address using b64decode or uudecode -m

Why geeks like computers: look chat date touch grep make unzip
strip view finger mount fcsk more fcsk yes spray umount sleep
 
F

Flash Gordon

Daniel Rudy wrote, On 24/03/07 08:53:
At about the time of 3/23/2007 1:08 PM, Flash Gordon stated the following:


Which is why I posted a follow-up message indicating that I posted to
the wrong group. The poster that you replied to snipped my post that
made a statement to that fact.

I either did not see or did not remember that. I'm not disputing you
posted it, just pointing out that it is not unusual for these things to
be pointed out more than once.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top