Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7768025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:49:01+00:00 2026-06-01T15:49:01+00:00

I am developing a kernel module that uses unlocked_ioctl. I tested it with kernel

  • 0

I am developing a kernel module that uses unlocked_ioctl. I tested it with kernel version 2.6.24-23-generic and it works perfectly. Now I tried it with kernel version 3.3.1-1-ARCH and something weird happens: the ioctl function is not executed when the request value (cmd) is 2. It returns 0, but the function is not executed. In order to check that it is not executed I did the following:

static long midriver_ioctl(struct file *file,
    unsigned int cmd, unsigned long arg) {

printk("Called with cmd = %d\n", cmd);

I wrote a test program that calls ioctl for this device from 0 to 4096, and I can see in dmesg the message “Called with cmd = n” for all those values, except of “2”, the only one that is not shown.

Any clues about what I am doing wrong?

Thank you in advance,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:49:02+00:00Added an answer on June 1, 2026 at 3:49 pm

    Take a look on this:

     546 int do_vfs_ioctl(struct file *filp, unsigned int fd, unsigned int cmd,
     547             unsigned long arg)
     548 {
     549        int error = 0;
     550        int __user *argp = (int __user *)arg;
     551        struct inode *inode = filp->f_path.dentry->d_inode;
     552
     553        switch (cmd) {
     554        case FIOCLEX:
     555                set_close_on_exec(fd, 1);
     556                break;
     557
     558        case FIONCLEX:
     559                set_close_on_exec(fd, 0);
     560                break;
     561
     562        case FIONBIO:
     563                error = ioctl_fionbio(filp, argp);
     564                break;
     565
     566        case FIOASYNC:
     567                error = ioctl_fioasync(fd, filp, argp);
     568                break;
     569
     570        case FIOQSIZE:
     571                if (S_ISDIR(inode->i_mode) || S_ISREG(inode->i_mode) ||
     572                    S_ISLNK(inode->i_mode)) {
     573                        loff_t res = inode_get_bytes(inode);
     574                        error = copy_to_user(argp, &res, sizeof(res)) ?
     575                                        -EFAULT : 0;
     576                } else
     577                        error = -ENOTTY;
     578                break;
     579
     580        case FIFREEZE:
     581                error = ioctl_fsfreeze(filp);
     582                break;
     583
     584        case FITHAW:
     585                error = ioctl_fsthaw(filp);
     586                break;
     587
     588        case FS_IOC_FIEMAP:
     589                return ioctl_fiemap(filp, arg);
     590
     591        case FIGETBSZ:
     592                return put_user(inode->i_sb->s_blocksize, argp);
     593
     594        default:
     595                if (S_ISREG(inode->i_mode))
     596                        error = file_ioctl(filp, cmd, arg);
     597                else
     598                        error = vfs_ioctl(filp, cmd, arg);
     599                break;
     600        }
     601        return error;
     602 
    

    As you can see, there is some of the switch-cases before vfs_ioctl or file_ioctl call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When developing a module (device driver, middleware, etc...) that will run in the kernel
I have a C program that I'm developing using Ubuntu 11.10 (Linux version 3.0.0-12-generic-pae
I'm developing a Linux kernel module outside of the Linux source tree (in the
I'm working on keyboard input for a very basic kernel that I'm developing and
Currently I am developing GPIO kernel module for friendlyarm Linux 2.6.32.2 (mini2440). I am
I have a kernel already designed and am now developing a bootloader. I would
I am developing application that uses shared preferences and content provider. But everytime I
I'm developing an app that download news from google reader. The app works perfect
I'm developing a kernel module which send messages to user space via netlink. To
I'm developing an operating system and rather than programming the kernel, I'm designing the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.