LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-06-2009, 07:43 AM   #1
Karbon
LQ Newbie
 
Registered: Jun 2008
Posts: 5

Rep: Reputation: 0
Question Best way to Access Raw sectors of a USB device


Hi All,

I am new to Linux. In my attempts to understand the ext3 and FAT filesystems, I want to write a C code to access the raw sectors to read the MBR and layout of the filesystems.

I formatted the USB with two partitions ext3 and FAT and study them.
I would need read / write access on the raw sectors of the usb drive.

I googled for the information and found
  1. Directly access the dev file in linux for the usb (say /dev/sdb) and do an open/read/write/lseek combination to read the raw sectors.
  2. Another way, would be to write a wrapper over an IOCTL and construct the scsi packets and do queries .. but read/write and dd internally do this anyway.

Am I on the right track .... ?

I want to know are there any other efficient methods or which of the above is the proper approach to access the raw sectors of the USB device?

All responses appreciated, Thanks in advance.
 
Old 02-07-2009, 04:39 PM   #2
pentode
Member
 
Registered: Dec 2005
Location: Oregon
Distribution: Debian Testing
Posts: 488

Rep: Reputation: 38
Your C program is only going to interact with the file system. It knows nothing about disk sectors, etc. The physical structure of the disk almost entirely hidden from the user (and operating system) by the disk controller. So even at the lowest level you can imagine you still have deal with the disk controller.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I extract raw sectors from a CD-ROM? pxumsgdxpcvjm Linux - General 2 12-25-2006 09:06 AM
How do I extract raw sectors from a CD-ROM? pxumsgdxpcvjm Linux - Newbie 1 12-25-2006 09:06 AM
How to access raw sectors on HDD with no file system? prasanthpooyath Programming 4 01-08-2005 10:53 AM
block device raw access rvilarl Programming 0 10-24-2004 12:53 PM
Reading raw hard disk sectors villie Programming 4 05-13-2004 12:18 AM


All times are GMT -5. The time now is 11:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration