RE: Unknown sys_open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
> 
> 

Some suggestions:
1) Use something like filp_open() instead of sys_open().  With
filp_open() you won't have to do all that set_fs() stuff.
2) Hard-coded "/dev/hda2" is icky.
3) Does this have to be in the kernel?  Most people prefer to do this
kind of thing from user-space.

Avishay


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux