0

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?

oop123123
  • 45
  • 2
  • 10

2 Answers2

1

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.

oop123123
  • 45
  • 2
  • 10
-1

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);
jmpcm
  • 1,814
  • 2
  • 19
  • 27
  • I've already implemented this kind of test program. But my original question is how to compile it in order to run on UML. Normal compiling with gcc -ansi test.c is not working. I believe I need to show kernel source, plus some options plus ARCH=um somewhere. – oop123123 Dec 26 '10 at 21:13
  • @user502515: despite it is not necessary, it is good in order to know exactly what you are returning from the `malloc`; this is more from the developer point of view than a problem for the compiler (for C memory is memory, I know). – jmpcm Dec 26 '10 at 22:21