0
votes

I've just implemented a "pseudo" device driver and want to test it. What can I do as a test is just:

echo "something"> /dev/mydev
cat /dev/mydev

My driver supports more advanced functionality and I implemented a test program to test these functionaries. However I'm not able to run it on UML (Error: Floating point exception). I believe there is a "special" way of compiling user programs for UML?

Could you please give a starting point for this? How should I compile the test program?

p.s. Testing program is very simple and above error is not caused by the bug in the program. p.p.s. For compiling the module I had ready Makefile, so it was easy :)

Thanks in advance.

EDIT: Both host and UML kernels are of same version 2.6.35

EDIT: I believe I need to show kernel source directory, plus some compiler options, also something like ARCH=um?

EDIT: Currently I'm compiling without any options. gcc test.c. Even the "Hello world" program is not working on the UML. Maybe i've to change something on UML compilation?

2
Retagged uml->user-mode-linux, the tag uml is for the Unified Modelling Language.Kos
What makes you think the problem is with the method of compilation for User-Mode Linux rather than simply a bug in your code?Jonathan Leffler
The code is very simple. It's just open, write/read, close. And it's working in my host OS. (on different file)oop123123
It would be easier to help you if you put your code here.jmpcm

2 Answers

1
votes

The solution for the problem is found (thanks to my classmates and professor):

the glibc versions of the compile environment should match with UML. So compiling --static option solves the problem.

-1
votes

If you want to read/write from/to your device, you have to implement, and then use on your program, at least the system calls open(), read(), write() and close(), like any other device on you Linux. For the example you gave, your program would be something like this (syntax might contain some errors):

char* string = "something";
char* result = (char*)malloc(sizeof(char) * strlen(string) + 1);

int fd = open("/dev/mydev", O_RDWR);

write(fd, "something", strlen(string));

read(fd, result, strlen(string));
printf("result = %s\n", result);

close(fd);