Nieuws:

Welkom, Gast. Alsjeblieft inloggen of registreren.
Heb je de activerings-mail niet ontvangen?

Auteur Topic: Problemen bij het compileren van kernel module  (gelezen 555 keer)

pieterb

  • Gast
Problemen bij het compileren van kernel module
« Gepost op: 2007/02/01, 13:00:08 »
Ik ben bezig met een kernel module. Maar bij het allereerste compileren gaat het al fout.
Mijn code:
#define __KERNEL__
#define MODULE

#include
#include
int init_module(void)
{
  /* do something to initialize the module */
  return 0; /* on error, return -EERR */
}
void cleanup_module(void)
{
  /* cleanup after the module */
}
De uitvoer:
pieter@pieter.void:~/prog/module$ gcc drop.c -c -I /usr/src/linux-headers-2.6.17-10/include/
In file included from /usr/src/linux-headers-2.6.17-10/include/asm/thread_info.h:16,
                 from /usr/src/linux-headers-2.6.17-10/include/linux/thread_info.h:21,
                 from /usr/src/linux-headers-2.6.17-10/include/linux/preempt.h:9,
                 from /usr/src/linux-headers-2.6.17-10/include/linux/spinlock.h:49,
                 from /usr/src/linux-headers-2.6.17-10/include/linux/capability.h:45,
                 from /usr/src/linux-headers-2.6.17-10/include/linux/sched.h:44,
                 from /usr/src/linux-headers-2.6.17-10/include/linux/module.h:9,
                 from drop.c:4:
/usr/src/linux-headers-2.6.17-10/include/asm/processor.h:76: error: ‘CONFIG_X86_L1_CACHE_SHIFT’ undeclared here (not in a function)
/usr/src/linux-headers-2.6.17-10/include/asm/processor.h:76: error: requested alignment is not a constant
In file included from /usr/src/linux-headers-2.6.17-10/include/linux/sched.h:49,
                 from /usr/src/linux-headers-2.6.17-10/include/linux/module.h:9,
                 from drop.c:4:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:33:3: error: #error You lose.
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:210:31: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:254:46: error: division by zero in #if
In file included from /usr/src/linux-headers-2.6.17-10/include/linux/sched.h:49,
                 from /usr/src/linux-headers-2.6.17-10/include/linux/module.h:9,
                 from drop.c:4:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h: In function ‘jiffies_to_msecs’:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:259: error: ‘CONFIG_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:259: error: (Each undeclared identifier is reported only once
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:259: error: for each function it appears in.)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:265:46: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h: In function ‘jiffies_to_usecs’:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:270: error: ‘CONFIG_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:278:46: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h: In function ‘msecs_to_jiffies’:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:283: error: ‘CONFIG_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:291:46: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h: In function ‘usecs_to_jiffies’:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:296: error: ‘CONFIG_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h: In function ‘timespec_to_jiffies’:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:315: error: ‘CONFIG_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:321: error: ‘SHIFT_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h: In function ‘jiffies_to_timespec’:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:334: error: ‘CONFIG_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h: In function ‘timeval_to_jiffies’:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:356: error: ‘CONFIG_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:360: error: ‘SHIFT_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h: In function ‘jiffies_to_timeval’:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:372: error: ‘CONFIG_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:385:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h: In function ‘jiffies_to_clock_t’:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:386: error: ‘CONFIG_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h: In function ‘clock_t_to_jiffies’:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:397: error: ‘CONFIG_HZ’ undeclared (first use in this function)
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:416:6: error: division by zero in #if
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h: In function ‘jiffies_64_to_clock_t’:
/usr/src/linux-headers-2.6.17-10/include/linux/jiffies.h:417: error: ‘CONFIG_HZ’ undeclared (first use in this function)
In file included from /usr/src/linux-headers-2.6.17-10/include/linux/rwsem.h:26,
                 from /usr/src/linux-headers-2.6.17-10/include/asm/semaphore.h:42,
                 from /usr/src/linux-headers-2.6.17-10/include/linux/sched.h:57,
                 from /usr/src/linux-headers-2.6.17-10/include/linux/module.h:9,
                 from drop.c:4:
/usr/src/linux-headers-2.6.17-10/include/asm/rwsem.h: In function ‘__down_read’:
/usr/src/linux-headers-2.6.17-10/include/asm/rwsem.h:105: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/usr/src/linux-headers-2.6.17-10/include/asm/rwsem.h: In function ‘__down_write’:
/usr/src/linux-headers-2.6.17-10/include/asm/rwsem.h:157: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/usr/src/linux-headers-2.6.17-10/include/asm/rwsem.h: In function ‘__up_read’:
/usr/src/linux-headers-2.6.17-10/include/asm/rwsem.h:194: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/usr/src/linux-headers-2.6.17-10/include/asm/rwsem.h: In function ‘__up_write’:
/usr/src/linux-headers-2.6.17-10/include/asm/rwsem.h:220: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/usr/src/linux-headers-2.6.17-10/include/asm/rwsem.h: In function ‘__downgrade_write’:
/usr/src/linux-headers-2.6.17-10/include/asm/rwsem.h:245: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
In file included from /usr/src/linux-headers-2.6.17-10/include/linux/sched.h:57,
                 from /usr/src/linux-headers-2.6.17-10/include/linux/module.h:9,
                 from drop.c:4:
/usr/src/linux-headers-2.6.17-10/include/asm/semaphore.h: In function ‘down’:
/usr/src/linux-headers-2.6.17-10/include/asm/semaphore.h:105: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/usr/src/linux-headers-2.6.17-10/include/asm/semaphore.h: In function ‘down_interruptible’:
/usr/src/linux-headers-2.6.17-10/include/asm/semaphore.h:130: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/usr/src/linux-headers-2.6.17-10/include/asm/semaphore.h: In function ‘down_trylock’:
/usr/src/linux-headers-2.6.17-10/include/asm/semaphore.h:155: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
/usr/src/linux-headers-2.6.17-10/include/asm/semaphore.h: In function ‘up’:
/usr/src/linux-headers-2.6.17-10/include/asm/semaphore.h:179: error: expected ‘:’ or ‘)’ before ‘KBUILD_BASENAME’
In file included from /usr/src/linux-headers-2.6.17-10/include/linux/module.h:22,
                 from drop.c:4:
/usr/src/linux-headers-2.6.17-10/include/asm/module.h:60:2: error: #error unknown processor family
pieter@pieter.void:~/prog/module$
Weet iemand wat ik fout doe????

Alvast bedankt!

Pieter

blubber

  • Gast
Problemen bij het compileren van kernel module
« Reactie #1 Gepost op: 2007/02/01, 17:11:04 »
Blijkbaar missen er nog wat simlinks enzo.
http://perspex.com/hacks/linux/distros/mandrake/9.0/driver-barfs.html
Ik weet niet of linux-headers-2.6.17-10 te dpkg-reconfiguren is, maar je zou het kunnen proberen.

pieterb

  • Gast
Problemen bij het compileren van kernel module
« Reactie #2 Gepost op: 2007/02/02, 10:18:52 »
linux-headers kun je niet reconfiguren, volgens mij.

Maar ik heb eindelijk het probleem opgelost.

De source moet je niet zelf compileren, maar een Makefile maken die redirect naar de kernel modules directory:

obj-m += micro_firewall.o

all:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

clean:
        make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Maar toch hartstikke bedankt voor je antwoord! Op het engelse ubuntu forum heeft men niet eens 1 antwoord kunnen bedenken.

Groet, Pieter