I am using this method to access drive and reading sector.
int fd = open("/dev/rdisk1s1");
nbytes_got = pread(fd, buf, nbytes, off);
but FD returns -1 means it failed. i need to read disks and their sectors but i am unable to do this in mac OS X. Please help me. Thanks in advance.
If
openreturns-1, then you need to checkerrnoto see why it failed. The most likely reason is that you are not running your program asrootor as a user in groupoperator.Also, you are missing the second (
oflag) parameter to theopenfunction.That is pretty basic knowledge. Reading disk sectors directly is generally a pretty advanced topic. You probably shouldn’t be doing this at your level of knowledge.