Hello,
I'm trying to write a Linux device driver. I've got it to work really well, until I tried to use "memcpy". I don't even get a compiler error, when I "make" it just warns me:
WARNING: "memcpy" [/root/homedir/sv/main.ko] undefined!
OK and when I try to load via insmod, I get on the console:
insmod: error inserting './main.ko': -1 Unknown symbol in module
and on dmesg:
main: Unknown symbol memcpy (err 0)
I include the following:
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/kernel.h> /* printk() */
#include <linux/slab.h> /* kmalloc() */
#include <linux/fs.h> /* everything... */
#include <linux/errno.h> /* error codes */
#include <linux/types.h> /* size_t */
#include <linux/fcntl.h> /* O_ACCMODE */
#include <linux/cdev.h>
#include <asm/system.h> /* cli(), *_flags */
#include <asm/uaccess.h> /* copy_*_user */
The function using memcpy:
static int dc_copy_to_user(char __user *buf, size_t count, loff_t *f_pos,
struct sv_data_dev *dev)
{
char data[MAX_KEYLEN];
size_t i = 0;
/* Copy the bulk as long as there are 10 more bytes to copy */
while (i < (count + MAX_KEYLEN)) {
memcpy(data, &dev->data[*f_pos + i], MAX_KEYLEN);
ec_block(dev->key, data, MAX_KEYLEN);
if (copy_to_user(&buf[i], data, MAX_KEYLEN)) {
return -EFAULT;
}
i += MAX_KEYLEN;
}
return 0;
}
Could someone help me? I thought the thing was in linux/string.h, but I get the error just the same. I'm using kernel 2.6.37-rc1 (I'm doing in in user-mode-linux, which works only since 2.6.37-rc1). Any help is greatly appreciated.
# Context dependent makefile that can be called directly and will invoke itself
# through the kernel module building system.
KERNELDIR=/usr/src/linux
ifneq ($(KERNELRELEASE),)
EXTRA_CFLAGS+=-I $(PWD) -ARCH=um
obj-m := main.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD = $(shell pwd)
all:
$(MAKE) V=1 ARCH=um -C $(KERNELDIR) M=$(PWD) modules
clean:
rm -rf Module.symvers .*.cmd *.ko .*.o *.o *.mod.c .tmp_versions *.order
endif