[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: basic system call question
On Sun, 13 May 2001, Erik Mouw wrote:
: On Sat, May 12, 2001 at 10:07:11PM -0400, Michael B. Rash wrote:
: > I implemented a basic system call "test" in kernel 2.2.18 that just
: > returns a*b for two integers a and b, and then compiled a user land
: > program to call "test" with arguments of 5 and 6. Upon executing the
: > program "systest" the number 30 is returned. Fine, so the system is
: > working. Now upon executing "strace ./systest" the following appeared the
: > output:
: >
: > getrlimit(0x5, 0x6, 0x4010d098, 0x4000ae60, 0xbffffae4) = 30
: > fstat64(0x1, 0xbffff2e0) = -1 ENOSYS (Function not implemented)
: >
: > Why is getrlimit being called, and why is fstat returning ENOSYS?
:
: I think that getrlimit() isn't called at all, but that strace doesn't
: know about your test syscall and interprets it in an incorrect way.
:
: fstat64() returns ENOSYS because it doesn't exist in linux-2.2; large
: file support is one of the new features in linux-2.4.
:
: > Also,
: > it does not appear that my system call "test" is not being called anywhere
: > (except that getrlimit is returning the correct value of 30). Why?
:
: It is. I compiled your example code (gcc -O2 -g -o systest systest.c)
: and looked at the output with "objdump -D -S":
:
: 804842a: bb 05 00 00 00 mov $0x5,%ebx
: 804842f: b9 06 00 00 00 mov $0x6,%ecx
: 8048434: b8 2a 00 00 00 mov $0x2a,%eax
I understand up to here (thanks for the reply).
: 8048439: cd 80 int $0x80
:
: eax contains the syscall number (42 in my case), ebx contains 5, ecx 6,
: and the syscall is int 0x80.
Why is the syscall "int 0x80"? Is this where the system is actually
executed with the arguments previously listed? It is not the return
value, and the system call number is already 42.
--Mike
Michael B. Rash
http://www.cipherdyne.com
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.kernelnewbies.org/