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

Re: get_user/copy_from_user



On Fri, Apr 27, 2001 at 07:11:06PM +0530, Chirag Kantharia wrote:
| I am trying to retrieve these two arguments from the ``arg'' parameter
| using:
| 
| struct xtcsound_data {
|     long location;
|     long value;
|  };
| static int xtcsound_ioctl(struct inode *inode, struct file *file,
|                                    unsigned int cmd, unsigned long arg)
| {
|   struct xtcsound_data val;
|   switch(cmd) {
|     case XTCSOUND_PCI_CONFIG_READ_REGISTER:
|       printk("before get_user_ret\n")
|       get_user_ret(val, (unsigned long *)arg, -EFAULT);
|       printk("after get_user_ret\n")
|       break;
|     case ...
|   }

Hi!

I have been able to ``solve'' the problem temporarily. From the library
function, I pass the pointer to a struct xtcsound_data, to ioctl, which
I can receive in the xtcsound_ioctl() alright, using copy_from_user.
Probably, this is the right way to do things.

I'd looked up ioctl manpage, which gave the following:

"""int ioctl(int d, int request, ...)

[The  "third"  argument  is  traditionally char *argp, and will be so
named for this discussion.]"""

I got a feeling that ioctl can be used similar to printf (va_list,
stdarg.h etc) and I can pass as many parameters to the ioctl as possible
(though I wasn;t sure how to extract those parameters from the unsigned
long arg in xtcsound_ioctl).

If there's indeed a way to extract the parameters passed to ioctl using
the unsigned long arg, please let me know. I guess, that would be bit
cleaner way to do things.

Thanks anyways,

chyrag.
-- 
Chirag Kantharia, slashetc.net/chyrag/

-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/