[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: basic system call question



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
 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.


Erik

PS: Instead of *replying* to an existing thread, you'd better *start* a
    new thread ("compose" instead of "reply"). If I killed the "kernel
    to user transactions" thread I wouldn't have seen your message at all.
    Same goes for the guy who started that thread: don't reply to the
    "about kiobuf" thread if you want to start a new thread.

-- 
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2783635  Fax: +31-15-2781843  Email: J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/
-
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/