0

On Mac OSX Mojave 10.14.6, the following simple code does not work anymore :

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>

int main(int argc, char** argv)
{
        int fd = open ("/dev/rdisk0", O_RDONLY);
        if (fd == -1)
        {
                fprintf(stdout, "open(%s) error = %s\n", "/dev/rdisk0", strerror(errno));
                fflush(stdout);
                return 1;
        }

        return 0;
}

It gives :

open(/dev/rdisk0) error = Operation not permitted

This happens even when running the executable using sudo.

This code used to work under 10.13 and earlier versions.

Thinking this might be due to SIP, I gave the Terminal and the executable Full Disk Access but it didn't help.

Is there another way to get around this issue? How do I open /dev/rdisk0 now ?

Thanks in advance

  • Did you actually try disabling SIP? Programs that require full disk access to (such as gdisk) require SIP to be disabled to access the boot disk. – lx07 Oct 10 at 18:47
  • @lx07 So there is no way other than disabling SIP ? Maybe some special OSX API that may replace open() / read() / write() and close() functions ? I really want to keep disabling SIP as a last resort ... – MiD Oct 10 at 18:53
  • @MiD There are no "special OS X APIs" for that. Could you say a bit about why you want to access the boot disk in that manner? - I.e. what's the purpose for this? - It might be achievable some other way without disabling SIP. – jksoegaard Oct 10 at 20:25

You must log in to answer this question.

Browse other questions tagged .