Hello Gurus:
I have a compact flash with 2 partitions /dev/hda1 and /dev/hda2.
I tried to open("/dev/hda2", O_RDWR, 0644); which is from user space. It is
fine to write/read. However, after I moved to kernel module, I always got return
0 for read/write. My source code is below. Could you help me figure out the
problem? Thanks.
struct
file*
filp;
int data[1024], bytes;
filp = filp_open("/dev/hda2",
O_RDONLY, S_IRWXU);
if (IS_ERR(filp))
{
printk("Unable to open stats
file to write\n");
} else
{
bytes =
filp->f_op->read(filp, (char*)data, 1024*sizeof(int),
&filp->f_pos);
fput(filp);
filp_close(filp,
NULL);
printk("filp->f_pos:%d,
bytes:%d, data:%d %d %d
%d\n",
filp->f_pos, bytes, data[0], data[127], data[511],
data[1023]);
}