Solved

OPENING A HARD DISK FILE ON MAC OS X USING C/C++

Posted on 2004-10-27
237 Views
Last Modified: 2013-12-26
hi experts
  I have tried to read the hard disk on mac os x But failed. I have use the fopen(), fread(),fwrite() to read the hard disk. I m able to read any .txt and .doc file on mac  using these functions. Becasue hard disk is also represented as file /dev/rdisk0 but i unable to even open this file using fopen().
device permissions on this file are
crw-r----- root   operator     /dev/rdisk0

plz help me why this file is not opened.
best regards
0
Question by:ManojKrChauhan
    3 Comments
     
    LVL 23

    Accepted Solution

    by:
    The 'r' in /dev/rdisk0 stands for 'raw'.   You cannot open it as a regular file.
    You must mount the raw image first.  And you cannot mount the raw disk
    image of any currently mounted volume - especially the root or boot volume.
    For more information on how to read and write raw volumes, examine the
    Darwin source code for diskutil and hdiutil.

    But I am really at a loss to understand why you wish to open a raw disk
    device using fopen().  This task is in the realm of people writing operating
    systems and disk repair/recovery utilities.  These require an extensive
    knowledge of devices, drivers, disk partitioning mechanisms, and file system
    formats --- considerably more knowledge than you have exhibited in your
    question.
    0
     

    Expert Comment

    by:manojchauhan
    hi experts
    plz tell me where i can find the Darwin source code for diskutil and hdiutil as u said this will help me
    thanx
    0
     

    Expert Comment

    by:manojchauhan
    I have two hard disks attached with my system
    /dev/disk0
    #: type name size identifier
    0: FDisk_partition_scheme *18.6 GB disk0
    1: DOS_FAT_32 NO NAME 9.8 GB disk0s1
    /dev/disk1
    #: type name size identifier
    0: Apple_partition_scheme *55.9 GB disk1
    1: Apple_partition_map 31.5 KB disk1s1
    2: Apple_Driver43 28.0 KB disk1s2
    3: Apple_Driver43 28.0 KB disk1s3
    4: Apple_Driver_ATA 28.0 KB disk1s4
    5: Apple_Driver_ATA 28.0 KB disk1s5
    6: Apple_FWDriver 256.0 KB disk1s6
    7: Apple_Driver_IOKit 256.0 KB disk1s7
    8: Apple_Patches 256.0 KB disk1s8
    9: Apple_HFS Macintosh HD 55.9 GB disk1s9

    and the file permissions of these device files are
    brw-r----- 1 root operator 14, 0 28 Oct 11:41 /dev/disk0

    brw-r----- 1 root operator 14, 1 28 Oct 11:41 /dev/disk1

    I have tried to change the permissions through root but message is
    chmod o+r /dev/disk0
    chmod: /dev/disk0: Operation not permitted

    Is there any need to change the file permissions for reading hard disk.
    plz tell how i have to proceed and give solution to the problem described.
    thanx
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Prepare to Pass the CompTIA A+ 900 Series Exam

    CompTIA aims to adapt its A+ Certification to reflect the most current knowledge and skills needed by today's IT professionals--and this year's 2016 exam is harder than ever. This certification is one of the most highly-respected and sought after in IT.

    Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
    If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now