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 4616052
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:55:38+00:00 2026-05-22T01:55:38+00:00

I am writing a module for the Linux kernel, and I want to create

  • 0

I am writing a module for the Linux kernel, and I want to create some device nodes in the init() function:

int init_module(void)
{
    Major = register_chrdev(0, DEVICE_NAME, &fops);

    // Now I want to create device nodes
    // with the returned major number
}

I also want the kernel to assign a minor number for my first node, and then I will assign the other nodes’ minor numbers by myself.

How can I do this in the code? I don’t want to create devices from the shell using mknod().

  • 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-05-22T01:55:39+00:00Added an answer on May 22, 2026 at 1:55 am

    To have more control over the device numbers and the device creation, you could do the following steps (instead of register_chrdev()):

    1. Call alloc_chrdev_region() to get a major number and a range of minor numbers to work with.
    2. Create a device class for your devices with class_create().
    3. For each device, call cdev_init() and cdev_add() to add the character device to the system.
    4. For each device, call device_create(). As a result, among other things, Udev will create device nodes for your devices. There isn’t any need for mknod() or the like. device_create() also allows you to control the names of the devices.

    There are probably many examples of this on the Internet, and one of them is here.

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

Sidebar

Related Questions

I am writing a python module which checks several media and document formats whether
I'm writing a module that acts on another module. The other module's submit form
When writing a Perl module, is it a good practice to use croak/die inside
I'm writing a Drupal module and have run into what should be a trivial
I am writing a program in Haskell here it is the code module Main
I'm using cpanm to install Perl modules, but I can't install Thread::Pool for some
I have a build script where i create a text report file and output
I have a module with four node types declared. My problem is, hook_load, hook_view
So I have a CSV that contains a filename and a file's contents. The
Is there an officially updated recommendation indicating which versions of Python should be supported

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.