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
Who is Participating?
brettmjohnsonConnect With a Mentor Commented:
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
hi experts
plz tell me where i can find the Darwin source code for diskutil and hdiutil as u said this will help me
I have two hard disks attached with my system
#: type name size identifier
0: FDisk_partition_scheme *18.6 GB disk0
1: DOS_FAT_32 NO NAME 9.8 GB disk0s1
#: 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.
All Courses

From novice to tech pro — start learning today.