Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Raw disk access

Reply
Thread Tools

Raw disk access

 
 
Daniel Rudy
Guest
Posts: n/a
 
      03-23-2007
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
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      03-23-2007
Daniel Rudy wrote:
> 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.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
christian.bau
Guest
Posts: n/a
 
      03-23-2007
On Mar 23, 9:34 am, Daniel Rudy <(E-Mail Removed)> wrote:
> 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.

 
Reply With Quote
 
Daniel Rudy
Guest
Posts: n/a
 
      03-23-2007
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
 
Reply With Quote
 
daya
Guest
Posts: n/a
 
      03-23-2007

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


 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      03-23-2007
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.
--
Flash Gordon
 
Reply With Quote
 
Daniel Rudy
Guest
Posts: n/a
 
      03-24-2007
At about the time of 3/23/2007 1:08 PM, Flash Gordon stated the following:
> 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.
>


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.

>> 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.
>


It would have to be binary mode.

>> 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.


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
 
Reply With Quote
 
Flash Gordon
Guest
Posts: n/a
 
      03-24-2007
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:


<snip>

>> 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.


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.
--
Flash Gordon
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RAW vs JPEGs - Does RAW show more detail? Tim Digital Photography 117 04-17-2007 03:02 PM
RAW Viewer for wide range of RAW formats greymfm Digital Photography 0 06-14-2006 09:12 PM
[Maxxum 7D] Dimage RAW Viewer v. Adobe Raw Plugin Alan Browne Digital Photography 3 03-12-2005 04:17 AM
Adobe PS RAW convertor vs Nikon RAW convertor Vlad Gunko Digital Photography 8 01-25-2005 07:43 PM
How raw is RAW format? Editor www.nutritionsoftware.org Digital Photography 4 12-22-2003 07:33 PM



Advertisments