Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6542115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:11:11+00:00 2026-05-25T11:11:11+00:00

How do you read hard disk sectors in C++ with gcc/linux? Is there a

  • 0

How do you read hard disk sectors in C++ with gcc/linux? Is there a standard library that I can use or must something be downloaded? In Windows I can use CreateFile(…) to access raw disk sectors, but I do not know how to do in in Linux.

I am using GCC on Ubuntu LTS 10.4. Thank you for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:11:12+00:00Added an answer on May 25, 2026 at 11:11 am

    The hard disk is just another file (not a “regular file” but a “device file”, but still, a file). Open it the normal way…

    int fdes = open("/dev/sda1", O_RDONLY);
    if (fdes < 0)
        err(1, "/dev/sda1");
    ... do more ...
    

    You will get permission errors unless you have the right permissions. Note that "/dev/sda1" is just an example, it is the first partition on disk sda, the exact path will depend on your system. You can list mount points with the mount command, and you can access entire disks (instead of just partitions) using /dev/sda, /dev/sdb, etc.

    You could also open it as a C++ fstream or C FILE, but I do not recommend this. You will have a better time finding example code and getting help on forums if you use open instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since Greasemonkey can't read/write files from a local hard disk, I've heard people suggesting
I want to read an image(JPEG) file from hard disk to memory. How can
I want to read a file from hard disk in size up to ~4-5GB.
I have a faulty hard drive that works intermittently. After cold booting, I can
I have a python program that does something like this: Read a row from
I'm writing an application that on some stage performs low-level disk operations in Linux
Well, greasemonkey is simply great but it cant read/write files from hard disk for
Hard-to-read-line @daily export sunshine=~/logs/Sunshine-`date '+\%F'` && export sunshineUrl=http://www.sunshine.net/main/search_results.asp?currency_id=1&min_price=&max_price=50000&country_id=241&region_id=&Submit=Search && mkdir -p $sunshine && cd
I find NSLog() statements really hard to read because of the verbose date. Is
Does anyone know when calling 'seek' and 'read' , how is the hard-drive physicly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.