+ -
当前位置:首页 → 问答吧 → 请教一个错误。

请教一个错误。

时间:2006-07-07

来源:互联网

file_storage.c 一个关于设备端驱动的代码

其中filp_open的时候出错,提示unable to open file

该file创建过程如下:
[root@Bill ~]vi /root/back_file
[root@Bill ~]dd bs=1M count=8 if=/dev/zero of=/root/back_file
[root@Bill ~]fdisk -S 8 -H 16 -C 128 /root/disk
Above is from llinux-usb.org/gadget/file_storage.html
then
[root@Bill ~]chmod 777 /root/back_file

请问这个错误是怎么回事呢。

相关代码如下
/*ro=0,filename=/root/back_file*/
static int open_backing_file(.............)
{
.......
.......
/* R/W if we can, R/O if we must */
ro = curlun->ro;
if (!ro) { /*ro=0*/
    filp = filp_open(filename, O_RDWR | O_LARGEFILE, 0);
    if (-EROFS == PTR_ERR(filp))
        ro = 1;
}
if (ro)
    filp = filp_open(filename, O_RDONLY | O_LARGEFILE, 0);
if (IS_ERR(filp)) {
    LINFO(curlun, "unable to open backing file: %s\n", filename);/***/
return PTR_ERR(filp);
}
本人目前想把板子上的FLASH模拟成U盘,在主机上可以识别,可是g_file_storage驱动总是弄不好,作成模块时候insert error 编译进内核又出这样的错误。有没有谁以前做过这样的工作的??
我用的是linux 2.6.11的内核,emdoor pxa27x的扳子。      

作者: andyzn   发布时间: 2006-07-07

热门下载

更多