views:

207

answers:

2

Hello,

I've implemented a character device and I'd like to ask If this is correct:

  1. In a Userspace I've a struct with 2 pointers.

  2. I write this struct into my device.

  3. In my write function in char device I copy_from_user this structure into kmalloced space.

  4. After this I'm in KS and got 2 pointers to US so I want to copy_from_user each. Am I allowed to do so right after first copy_from_user by using this copied addresses? They point to a data in US application which called write function not to the write function argument char *buf.

+1  A: 

Seems like it should work.

I'd probably be inclined to put this sort of thing into an ioctl instead of write, depending on whether the operation is similar to what other devices do when written to. But that's just style; it's functionally the same.

Eric Seppanen
A: 

I agree with first answer, IOCTL seems like a more conventional way of handling this.

Your approach should work, feel free to post code samples if you have further questions.

Sam Post