We help IT Professionals succeed at work.


namus asked
Medium Priority
Last Modified: 2010-04-21
im opening a device file frm my kernel module,thers no particular existent device as such for this file ,& i need to communicate with the module from user space, one of the functions regestered for that device is like this,

 * File operations functions for control device

static int lwfw_ioctl(struct inode *inode, struct file *file,
                  unsigned int cmd, unsigned long arg)
   int ret = 0;
   switch (cmd) {
    case LWFW_GET_VERS:
      return LWFW_VERS;
    case LWFW_ACTIVATE: {
       active = 1;
       printk("LWFW: Activated.\n");
       if (!deny_if && !deny_ip && !deny_port) {
        printk("LWFW: No deny options set.\n");
       active ^= active;
       printk("LWFW: Deactivated.\n");
    case LWFW_GET_STATS: {
       ret = copy_stats((struct lwfw_stats *)arg);
    case LWFW_DENY_IF: {
       ret = set_if_rule((char *)arg);
    case LWFW_DENY_IP: {
       ret = set_ip_rule((unsigned int)arg);
    case LWFW_DENY_PORT: {
       ret = set_port_rule((unsigned short)arg);
      ret = -EBADRQC;
   return ret;


i need to communicate with the kernel module frm my GUI code in the user space.
Its like if i want to activate the module i need to enter the case LWFW_ACTIVATE. & so on...
How to do it...

the other functions are :

/* Called whenever open() is called on the device file */
static int lwfw_open(struct inode *inode, struct file *file){ ... }

/* Called whenever close() is called on the device file */
static int lwfw_release(struct inode *inode, struct file *file){ ... }

i dont understand the 'inode' & 'file' parameters, how to get their values for the device file.
any kinda help is appreciated... thx

Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.