LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-12-2006, 12:32 AM   #1
tgo
Member
 
Registered: Dec 2004
Posts: 125

Rep: Reputation: 15
kernel module problem


after trying to compile a pretty stanard lkm I wrote I got this error ( among many others from included files )

Code:
In file included from /lib/modules/2.6.17.2/build/include/linux/rwsem.h:27,
                 from /lib/modules/2.6.17.2/build/include/asm/semaphore.h:42,
                 from /lib/modules/2.6.17.2/build/include/linux/sched.h:20,
                 from /lib/modules/2.6.17.2/build/include/linux/module.h:10,
                 from ftpsniff.c:3:
/lib/modules/2.6.17.2/build/include/asm/rwsem.h: In function '__down_read':
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:105: error: expected ':' or ')' before 'KBUILD_BASENAME'
/lib/modules/2.6.17.2/build/include/asm/rwsem.h: In function '__down_write':
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:157: error: expected ':' or ')' before 'KBUILD_BASENAME'
/lib/modules/2.6.17.2/build/include/asm/rwsem.h: In function '__up_read':
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:194: error: expected ':' or ')' before 'KBUILD_BASENAME'
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:188: warning: unused variable 'tmp'
/lib/modules/2.6.17.2/build/include/asm/rwsem.h: In function '__up_write':
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:220: error: expected ':' or ')' before 'KBUILD_BASENAME'
/lib/modules/2.6.17.2/build/include/asm/rwsem.h: In function '__downgrade_write':
/lib/modules/2.6.17.2/build/include/asm/rwsem.h:245: error: expected ':' or ')' before 'KBUILD_BASENAME'
I googled the first line about __down_read and it seems many other projects had this problem in their bug reports and other people asking about it but no one had a solution. It seems to only hapeen in 2.6.15 > kernels and I am running 2.6.17.2.

Has anyone seen this error or is there some config option i missed that would cause this?

thanks
 
Old 12-12-2006, 05:34 PM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
/lib/modules/2.6.17.2/build/include/asm/rwsem.h
... have you tried looking in that header, lines 105, 157, etc, and seeing if there is a missing ":" or ")" that should be there?

You'll find googling "rwsem.h:105: error: expected ':' or ')'" more productive... lots of folk with your kernel are experiencing difficulty with this header.
 
Old 12-23-2006, 03:05 PM   #3
pcastone
LQ Newbie
 
Registered: Dec 2006
Posts: 1

Rep: Reputation: 0
Here is a fix

The root cause of this problem is somewhere around 2.6.15 the inline function LOCK_SECTION_NAME was defined as
#define LOCK_SECTION_NAME ".text.lock." __stringify(KBUILD_BASENAME)
In latter release of the the 2.6.xx kernel it's define as
#define LOCK_SECTION_NAME".text.lock."KBUILD_BASENAME
without the __stringify macro.

The fix is to use KBASE_STR macro at then Makefile level.

add these lines to your Makefile or Makefile.am

KMOD = <Module Name> # Name of module
KBASE= <Module Base> # Name of Base

CFLAGS+= -D"KBUILD_STR(s)=\#s"
CFLAGS+= -D"KBUILD_BASENAME=KBUILD_STR(${KBASE})"
CFLAGS+= -D"KBUILD_MODNAME=KBUILD_STR(${MOD})"

Last thing make sure that you build str uses ${CFLAGS}
IE: cc ${CFLAGS} <...>
 
Old 12-23-2006, 04:13 PM   #4
tgo
Member
 
Registered: Dec 2004
Posts: 125

Original Poster
Rep: Reputation: 15
yes sorry for not replying to this post after getting it figured. Changing my makefile similar to how you mentioned it fixed it. thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Problem installing module in Fedora Core 2 (2.6 kernel vs 2.4 problem?) Arodef Linux - Kernel 3 11-30-2007 02:55 PM
Kernel 2.6.13 and module problem jeffpr Fedora 3 10-07-2005 05:22 PM
problem in kernel module cranium2004 Programming 1 04-14-2005 03:10 AM
Kernel 2.4.23 module problem powadha Linux - Software 2 12-09-2003 06:28 AM
kernel module ignorant newbie looking for any one with kernel module knowledge cpoet Slackware 4 11-24-2003 09:37 PM

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

All times are GMT -5. The time now is 08:29 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