On Fri, 15 Jul 2005, Hillel wrote: > I am building a kernel module (char device) that should get runtime > parameters from a user mode process. > Among the info items that should flow to the module are strings and > arrays. To my understanding I can use any of the following methods to > achieve this: ioctl, sysfs, procfs, device read and write and system calls. > > Is there a preferred method? maybe a different one?
different people seem to have philosophical issues regarding which option to use. if you're writing a FOSS project - start with the easiest thing so you can work on the rest of the driver faster, and after you see the cons and pros of your method, you could switch to another. your choice is also dependent on portability - do you want this for the 2.6 kernel and up, or also for older kernels? if for also older (2.4 or older) - rule out sysfs. you should also figure out how stable you want this interface. for example, in the procfs and device read/write interfaces, the user reads writes config data using the 'write' system call. it could be that you'll get this data in several chunks, and you'll need to accumulate it. since _normally_ a write from user space of 4KB of data (one page on IA32) will go in a single operation, you could write a first version of the interface to assume you get everything in a single write, or fail the operation. afterwards, you could re-write the interface to be able to receive data in several chunks. this is why people used to refer to ioctl - you can copy the entire user buffer in a single copy_from_user operation - even if it is very large. the lazy method, then, would be to go for ioctl first. one last thing - if you only need to give this data when the module loads - you could use module parameters for that - encode your data in a string, and pass it as one module parameter. i'm not sure how much data may be in a module parameter, thought. check it out before you try to go for this. and ofcourse, never add new system calls if you're not going to try to add your code into the mainline kernel - and even if you are - don't ;) -- guy "For world domination - press 1, or dial 0, and please hold, for the creator." -- nob o. dy ================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]