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 6946109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:31:21+00:00 2026-05-27T13:31:21+00:00

In the code given below: #include <stdio.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> #include

  • 0

In the code given below:

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/disk.h>

int main(int argc, char **argv)
{
    int fd = open("/dev/disk0", O_RDONLY, 0);

    ...
}

fd has -1 for physical hard drives but it works fine for a USB/flash drive. Why is this happening?

  • 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-27T13:31:22+00:00Added an answer on May 27, 2026 at 1:31 pm

    This is almost certainly a permissions issue. Giving ordinary users any access to raw disks is a security hole (the user could circumvent all file permissions and read anything they want on the disk), so no OS gives raw disk access to normal users.

    In the example below, disk0 is my internal hard drive and disk3 is a USB flash drive. In OS X, even “administrators” aren’t part of the operator group that would allow raw disk access to fixed hard drives.


    pip$ ls -ltr /dev/disk*
    brw-r----- 1 root operator 14, 3 Dec 12 10:14 /dev/disk0s3
    brw-r----- 1 root operator 14, 2 Dec 12 10:14 /dev/disk0s2
    brw-r----- 1 root operator 14, 1 Dec 12 10:14 /dev/disk0s1
    brw-r----- 1 root operator 14, 0 Dec 12 10:14 /dev/disk0
    br--r----- 1 root operator 14, 4 Dec 14 15:15 /dev/disk1
    brw-r----- 1 root operator 14, 7 Dec 14 15:15 /dev/disk2s2
    br--r----- 1 root operator 14, 6 Dec 14 15:15 /dev/disk2s1
    brw-r----- 1 root operator 14, 5 Dec 14 15:15 /dev/disk2
    brw-r----- 1 pip operator 14, 9 Dec 14 15:18 /dev/disk3s1
    brw-r----- 1 pip operator 14, 8 Dec 14 15:18 /dev/disk3

    If your app really needs raw disk access you’ll either need to run it as root with sudo, add yourself to the operator group, or use the OS X APIs for privilege escalation.

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

Sidebar

Related Questions

Below is my code (test.c): #include <stdio.h> #include <string.h> int main(int argc, char **argv)
While debugging some code I got something like below: #include<stdio.h> int main() { FILE
I wrote the below code which replaces '|' characters from the string. #include <stdio.h>
Hello friends i am running code given below which contains the setLogTimeEntery function and
Technology Used:- Asp.Net 2.0 Code:- See Below Description:- hello code given below is working
I tried the following code in LINQPad and got the results given below: List<string>
Given the below setup and code snippets, what reasons can you come up with
Given the code below, how would you create/implement SR.h so that it produces the
Given the code below ... Net::HTTP.start('localhost', 4000) do |http| # # usual stuff omitted
Given the code below, how do I compare a List of objects's values with

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.