Fedora Linux Support Community & Resources Center
  #1  
Old 11th October 2011, 02:57 PM
Mascara Negra Offline
Registered User
 
Join Date: Oct 2009
Age: 28
Posts: 49
windows_7chrome
Exclamation How compile modules in linux ?

I'm new to linux world, I need to do these steps :

1)
compile this module (hello.c):

Code:
    #include <linux/module.h>
    #include <linux/kernel.h>
    #include <linux/proc_fs.h>
    
    struct proc_dir_entry *file;
    
    ssize_t proc_read(char *buffer, char **buffer_location,
    		  off_t offset, int buffer_length, int *eof, void *data) {
      int len = 0; 
    
      if (offset > 0) {
        *eof = 1;
        return len;
      }
    
      len = sprintf(buffer, "Hello, World!\n");
      return len;
    }
    
    
    int init_module(void) {
      int rv = 0;
      file = create_proc_entry("hello", 0644, NULL);
      file->read_proc = proc_read;
      file->mode = S_IFREG | S_IRUGO;
      file->uid = 0;
      file->gid = 0;
      file->size = 37;
    
      if (file == NULL) {
        rv = -ENOMEM;
        remove_proc_entry("hello", NULL);
        printk("Problem with the module!\n");
      } else {
        printk("Module loaded!\n");
      }
    
      return rv;
    }
    
    void cleanup_module(void) {
      remove_proc_entry("hello", NULL);
      printk("Module unloaded!\n");
    }
    
    MODULE_LICENSE("GPL");
2)
This module should create a file /proc/hello (where I found this file ?) when readed, this file should present the follow message: 'Hello World!'.

3)
Change the module above to show the PID instead the 'Hello World!'message.
Compile and see its working.

I'm folling this [tutorial][1], but nothing so far.

Any tip, any help will be very appreciated.


[1]: http://www.cyberciti.biz/tips/compil...el-module.html
Reply With Quote
Reply

Tags
kernel, linux, modules

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fedora 7 kernel /modules compile error fizy Installation, Upgrades and Live Media 3 16th August 2007 04:31 AM
Too many modules - Compile fresh kernel? skudder Installation, Upgrades and Live Media 3 28th April 2006 04:57 AM
trying to compile vmware modules bytesniper Fedora Core 5 - Dev 3 12th March 2006 09:28 PM
Compile Kernel Modules AMD 64 pghislain Using Fedora 1 9th September 2005 07:21 PM


Current GMT-time: 07:33 (Wednesday, 17-09-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat