[Ilugc] Kernel struct info

  • From: raja.mallik@xxxxxxxxxxx (Raja Mallik)
  • Date: Wed Jan 12 15:41:26 2005



Kernel module maintains a structure that can be operate by READ/WRITE
operations by user application.

For eg : SETTINGS[5] = {10, 11,12,13,14,}
         

User will defined IOCTLs for this map is defined as:

For write to device: ( Pass an index number and value to write)

1) IOCTL_SET1_MSG
2) IOCTL_SET2_MSG
3) IOCTL_SET3_MSG
4) IOCTL_SET4_MSG
5) IOCTL_SET5_MSG

And for reading from device: ( Pass an index number and get the value
set for the device)

1) IOCTL_GET1_MSG
2) IOCTL_GET2_MSG
3) IOCTL_GET3_MSG
4) IOCTL_GET4_MSG
5) IOCTL_GET5_MSG

I have defined 

static int Settings[5]={10, 12, 13, 14, 15}

When I call this in device_ioctl() in kernel module , I define all IOCTL
defined above in a switch(cmd_num) 

what I want to do is for 

case IOCTL_SET1_MSG:
     
        { 

          Here I want to set the global settings as defined above:
Settings[5] array.

}

I have IOCTL defined as:

#defined IOCTL_SET1_MSG --IOR( _IOR(DEVICE_MAJOR_NUM, 0, char *) 


When the user application calls with IOCTL_SET1_MSG, its passes a number
0 to the node, kernel should set 1st value of Settings[5]={10. 11, 12,
13, 14} i.e 10, and 11 for 1 and so on..

I am little stuck here.. 

Thanks
Raja



Other related posts: