In my pure C++ native process (that I run from the terminal with adb) I'm trying to read a block directly from the SD Card in Android 2.3 SGS2. My code is running with root permissions so it shouldn't matter.
I know that the SD Card memory mapped to /sys/block/mmcblk1
so I open it:
int fd = open("/sys/block/mmcblk1", O_RDONLY);
which succeeds. Now, when I'm trying to read from it:
bytes_read = read(fd, buffer, 4096);
I get an error: "Is a directory"
Well, I know that this is a directory but it's still supposed to work, maybe with some other flags in the open?
How can I do this?
Haha!
My mistake was indeed that I tried to read from a directory /sys/block/mmcblk1
.
But I should have try to read from /dev/block/mmcblk1
!
Which works perfectly.