LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-29-2004, 03:59 PM   #1
leosgb
Member
 
Registered: Nov 2004
Location: Brazil
Distribution: Gentoo
Posts: 363

Rep: Reputation: 31
Exclamation Sample module coding: Linux Device Drivers


I am trying to build a simple module at home from the info i am gathering reading LDD2. I am currently trying to add a simple identification line from page 21 just to get some process related information (PID and process name). The code is as follows:
#define MODULE

#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/sched.h>

MODULE_LICENSE("GPL");

int init_module (void)
{
printk("<1>This is test module\n");
printk("Process is %s (ID is %i)\n",current->comm, current->pid);
return 0;
}

void cleanup_module(void)
{
printk("<1> Goodbye World\n");
}
I get an error on the header file linux/sched.h
[prog@ademonozu cap1]$ gcc -I/lib/modules/2.4.22-1.2115.nptl/build/include -c p15.c
In file included from /lib/modules/2.4.22-1.2115.nptl/build/include/linux/sched.h:15,
from p15.c:6:
/lib/modules/2.4.22-1.2115.nptl/build/include/linux/timex.h:173: error: field `time' has incomplete type
In file included from /lib/modules/2.4.22-1.2115.nptl/build/include/linux/sched.h:23,
from p15.c:6:
/lib/modules/2.4.22-1.2115.nptl/build/include/asm/mmu.h:13: error: field `sem' has incomplete type
/lib/modules/2.4.22-1.2115.nptl/build/include/asm/mmu.h:15: error: field `user_cs' has incomplete type
In file included from /lib/modules/2.4.22-1.2115.nptl/build/include/linux/sched.h:31,
from p15.c:6:
/lib/modules/2.4.22-1.2115.nptl/build/include/linux/pid.h:18: error: field `task_list' has incomplete type
/lib/modules/2.4.22-1.2115.nptl/build/include/linux/pid.h:19: error: field `hash_chain' has incomplete type
/lib/modules/2.4.22-1.2115.nptl/build/include/linux/pid.h:24: error: field `pid_chain' has incomplete type
/lib/modules/2.4.22-1.2115.nptl/build/include/linux/pid.h:36: error: syntax error before '(' token
/lib/modules/2.4.22-1.2115.nptl/build/include/linux/pid.h:38: error: syntax error before '(' token
/lib/modules/2.4.22-1.2115.nptl/build/include/linux/pid.h:43: error: syntax error before '(' token
/lib/modules/2.4.22-1.2115.nptl/build/include/linux/pid.h:49: error: syntax error before '(' token
/lib/modules/2.4.22-1.2115.nptl/build/include/linux/pid.h:52: error: syntax error before '(' token
p15.c: In function `init_module':
p15.c:13: error: `current' undeclared (first use in this function)
p15.c:13: error: (Each undeclared identifier is reported only once
p15.c:13: error: for each function it appears in.)

Can anyone help?
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ or pure C for Linux kernel module, Linux device driver development. What to use? Igor007 Programming 91 07-19-2014 11:55 AM
Linux Device Drivers, Third Edition --- scull module??? Igor007 Programming 2 09-09-2005 05:05 PM
Emacs module for better perl coding rose_bud4201 Linux - Software 3 04-27-2005 02:39 PM
linux device drivers alaios Programming 1 05-24-2003 08:23 PM
got a sample device driver??? aditya Linux - General 1 02-21-2003 12:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration