AnsweredAssumed Answered

Can't open "/dev/block/mmcblk0" in kernel

Question asked by Qingyuan Lam on Apr 10, 2014
Latest reply on Apr 15, 2014 by PeterChan

I  use below codes to open "/dev/block/mmcblk0" in android kernel:

static const char *filename = "/dev/block/mmcblk0";
static const int  offset = 26623 * 512;

static int emmc_read(void)
{
mm_segment_t fs;
struct file *fp = NULL;
loff_t pos = 0;
u8 header[512], *data=NULL, *udata=NULL, *vp;
int len, outlen=0, n, i, ret = -1;
char *p;

printk("loading  file: %s\n", filename);

fs = get_fs();
set_fs(KERNEL_DS);

fp = filp_open(filename, O_RDONLY, 0);
if (IS_ERR(fp)) {
  fp = NULL;
  ERR("Could not open  file\n");
  goto err2;
}

....

}

but it failed,it shows below error:

loading file: /dev/block/mmcblk0

Could not open file

 

 

Can you tell me how to open "/dev/block/mmcblk0"  in android kernel ?

 

Thanks.

Outcomes