Waqar
Waqar

Reputation: 105

disk sector reading in objective c

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.

Upvotes: 0

Views: 415

Answers (1)

rob mayoff
rob mayoff

Reputation: 385650

If open returns -1, then you need to check errno to see why it failed. The most likely reason is that you are not running your program as root or as a user in group operator.

Also, you are missing the second (oflag) parameter to the open function.

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.

Upvotes: 1

Related Questions