Solved

ioctl

Posted on 2004-03-27
3
339 Views
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");
       }
       break;
    }
    case LWFW_DEACTIVATE: {
       active ^= active;
       printk("LWFW: Deactivated.\n");
       break;
    }
    case LWFW_GET_STATS: {
       ret = copy_stats((struct lwfw_stats *)arg);
       break;
    }
    case LWFW_DENY_IF: {
       ret = set_if_rule((char *)arg);
       break;
    }
    case LWFW_DENY_IP: {
       ret = set_ip_rule((unsigned int)arg);
       break;
    }
    case LWFW_DENY_PORT: {
       ret = set_port_rule((unsigned short)arg);
       break;
    }
    default:
      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

suman...
0
Comment
Question by:namus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
scn earned 50 total points
ID: 10702145
Driver operations are accessed from user applications through an inode entry in the filesystem  (e.g. /dev/mydriver).
Refer to the section "Major and minor numbers" in Rubini's book at http://www.xml.com/ldd/chapter/book/ch03.html.
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question