View Full Version : READING OF HARD DISK ON MAC OS
Oct 27, 2004, 08:27 AM
I am able to read any text or doc file in any file or buffer. But my ultimate purpose is to read the hard disk. I think which is also a file in mac like linux. which is in /dev/rdisk0. But I am not able to read this file using fopen() ,fread(), fwrite() functions. If anyone who know how to read hard disk on mac or linux plz help me.
my device permissions are
crw-r----- 1 root operator 14, 0 27 Oct 09:36 /dev/rdisk0
and i m working on administrator. Plz help me through valuable solutions.
Waiting for reply
Oct 27, 2004, 08:52 AM
Try putting the command "sudo" (super user do) in fornt of the command (Without inverted commas). It has caught me out once or twice but remember that, by default, root is not enabled on the mac, though you may have admin rights with your normal log on. I haven't tried it with your commands so I apologise if it doesn't work.
Oct 27, 2004, 09:40 AM
That's right, administrator is not root.
Oct 28, 2004, 11:44 AM
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
Whether the functions i have used for reading hard disk is right or wrong through c++ on mac os.
Whether to read hard disk i have to change the permissions or not?.
If yes how i have to change the permissions.
plz tell how i have to proceed and give solution to the problem described.
Oct 29, 2004, 01:39 PM
First you need to change permissions with a valid mount point or filepath NOT a device name, usually /Volumes/HardDisk or something like ~/Public/Shared, etc...
Second, your C++ program is going to execute as the user logged in (unless you are trying some fancy suexec() commands) so make sure that user (ie you) has permissions to rw.
Third, to issue the chmod command on files/paths that root owns, you will need to prefix sudo to the command. You can't change permissions on files you don't have access to. sudo will allow you to execute a chmod command without having to login as root.
Finally, don't go nuts change everything. Change just what you need to. ie only the files or directories you are going to need to "touch" with your program.
I recommend you find some tutorials (google) on *NIX file permissions so you understand what exactly you are doing.
Oct 29, 2004, 02:19 PM
You may also want to post questions like this over at the BSD forums.
Converting from BSD might be a lot easier than trying to translate from LINUX.