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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:02:22+00:00 2026-06-09T12:02:22+00:00

I have a kernel module named mymodule and in it I have : static

  • 0

I have a kernel module named mymodule and in it I have :

static struct file_operations my_mod_fops = {
        .owner = THIS_MODULE
        .write = my_write,
        .open = my_open,
        .unlocked_ioctl = my_ioctl,
        .read = my_read,

};

all the function mapped in the previous struct were tested and they are OK.
I want to declare globally (and staticly if available) a char kernel_array[128] and I want to write a userspace application that can do this:

int main(){

char* ptr_to_kernel_arr = get_kernel_array_address();

for (int i=0 ; i<128;++i)
    *(ptr_to_kernel_arr+i) = i;

return 0;
}

my difficulties are:

  1. how do I get the address of kernel_array[128] such that I can assign values from a user space application?

  2. how does the kernel knows to which module from its lsmod list holds the kernel_array

  3. how mmap relates all this scenario?

I read chapter 15 and much more material but couldn’t figure out how to do it.
all the examples I found online declare a file and share it with the kernel and user space.

  • 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-09T12:02:23+00:00Added an answer on June 9, 2026 at 12:02 pm

    You need to implement the mmap function and point to it from file_operations.

    This will allow the user space to open your device, call mmap with the file descriptor, and get the address.

    Note that mmap works at page resolution. So you can’t map 128 bytes, but only multiples of 4K. You could map the 4K page(s) which contain the static buffer, but then the user process will be able to corrupt memory it shouldn’t touch, which is highly discouraged.

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

Sidebar

Related Questions

I have this in a kernel module: /*global scope declared*/ static int array[10]={1,2,3,4,5,6,7,8,9,10}; and
I have developed a kernel module (Android) which provides me: PCM 16-bit 48000 Hz
I am writing a kernel module in which i have 3 source files and
Does someone have the source for Android loadable kernel module for libnfc? If not,
I have a kernel module in which I deal with USB devices. It happens
I have a Linux kernel module M1 which exports a symbol S1 . When
I have a problem with use count of kernel module being developed.I'd like to
On an x86 system, I have a Linux kernel module (watcher module) that gets
Basically, I want to write a kernel module that adds a possible filter to
I have a kernel module that allocates a large buffer of memory, this buffer

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.