[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Unknown sys_open
On Tue, 2006-12-05 at 09:45 -0800, Junhan Zhang (junhan) wrote:
> Actually, we want to write some stats info to compactflash. The code
> is below:
>
> fs = get_fs();
> set_fs(get_ds());
> if((tfd = sys_open("/dev/hda2", O_WRONLY, S_IRWXU)) < 0) {
> printk("Unable to open stats file to write\n");
> } else {
> filp = fget(tfd);
> write_sizef = (sizeof(flash_stats_info_t)
> + (wear_planes *
> sizeof(aesop_flash_blk_t))
> + (wear_planes * sizeof(int)));
> rbytes = filp->f_op->write(filp, (char*)(wstats_mem),
> write_sizef, &filp->f_pos);
> fput(filp);
> sys_close(tfd);
> }
> set_fs(fs);
>
Hi,
I'm sorry but this code is wrong on so many levels that it's not
funny ;(
you probably need/want to use bread() and friends as API to work on
block devices inside the kernel, but even then, it feels a bit fishy.
You probably want to layer this properly .. especially when you try to
get this into the mainline kernel (that is the plan right?) I am worried
about the overall approach...
--
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/