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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:31:00+00:00 2026-05-20T10:31:00+00:00

Hey, I’m trying to play around a with sysfs a little bit, to get

  • 0

Hey,
I’m trying to play around a with sysfs a little bit, to get some data from user space into my kernel module.
Here is the code:

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/elf.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/kobject.h>
#include <linux/sysfs.h>

#define PRINT(x) printk(KERN_INFO x "\n")
#define ERROR(fmt,arg...) printk(KERN_ALERT "Error - " fmt,##arg)



ssize_t mystore (struct kobject *obj,
                    struct attribute *attr, const char *buff, size_t count)
{
 /* doing a little bit */
        return count;
}


ssize_t myshow (struct kobject *obj, struct attribute *attr, char *buff)
{
    return 0;
}

char file_name[] = "myfile";
static struct attribute myattribute = {
    .name = file_name,
    .mode = S_IRUSR | S_IWUSR
};
static struct sysfs_ops mysysfs_ops = {
    .show = myshow,
    .store = mystore
};
static struct kobj_type mykobj_type = {
    .sysfs_ops = &mysysfs_ops,
};
static struct kobject mykobject = {
    .name = "mykobject",
    .ktype = &mykobj_type
};

static int __init start(void)
{
    int tmp;

    PRINT("Initializing module\n");

    if (kobject_init_and_add(&mykobject, &mykobj_type, NULL, "mykobj") != 0) {
        ERROR ("Digsig key failed to register properly\n");
        return -1;
    }
    if ((tmp = sysfs_create_file(&mykobject, &myattribute)) != 0) {
        ERROR ("Create file failed\n");
        return -1;
    }
    PRINT("INIT CORRECT");
    return 0;
}

static void __exit close(void)
{
    PRINT("Deinitializing module\n");
    sysfs_remove_file(&mykobject, &myattribute);
    kobject_del(&mykobject);
}

module_init(start);
module_exit(close);

When I compile my module, all works fine, but when I try to run it I get a
insmod: error inserting ‘mytester.ko’: -1 Unknown symbol in module

Using dmesg I get more details:

[18335.892462] mytester: Unknown symbol sysfs_remove_file (err 0)
[18335.892462] mytester: Unknown symbol sysfs_create_file (err 0)
[18335.892646] mytester: Unknown symbol kobject_init_and_add (err 0)

And that’s the point. I don’t understand this message, because both kobject.h and sysfs.h are included. So I can’t really understand what is happening here. Even if I comment out my whole function mystore to a simple return (as shown) the error is the same. So the error is not elsewhere….

  • 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-20T10:31:00+00:00Added an answer on May 20, 2026 at 10:31 am

    The sysfs_remove_file and other functions in your example are exported GPL only, and can only be accessed from a module marked with MODULE_LICENSE("GPL");. See the Linux Kernel FAQ for some more on this. If your module is for in-house use, or you plan to distribute as open source, this shouldn’t be a problem. Otherwise, you may need to reconsider how you interface to the kernel.

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

Sidebar

Related Questions

Hey i have been looking around and i cant find a way to get
Hey I'm building an app that will allow a user to log into a
Hey I need a little help with unsigned char bit access. I need to
Hey trying to get a validation check working on a boolean field called 'activated'.
Hey, I'm currently trying to extract information from a 3d array, where each entry
Hey having some trouble trying to maintain transparency on a png when i create
Hey, I'm trying to get the source code of an app similar to the
Hey everyone i did some research online but i couldn't get a solution, hopefully
Hey I just started dabbling with android programming, and from my short period of
Hey folks I am trying to implement a search functionality in a website using

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.