Intercepting system calls

Intercepting system calls

Post by Clinton Pierc » Sat, 11 May 1996 04:00:00



I'm looking to buy a clue.  What I want to do is have a _single_ program
run and get "custom" results back from a system call.  For example, if I
wanted to intercept time(2) so that a program calling time(2) gets something
else back...how?

I understand that I can re-compile libc and probably get something like this
to happen...  The kernel seems to actually get the time from
the system harware clock in kernel/time.c near:

asmlinkage int sys_time(long * tloc)
{
        int i, error;

        i = CURRENT_TIME;
        if (tloc) {
                error = verify_area(VERIFY_WRITE, tloc, 4);
                if (error)
                        return error;
                put_fs_long(i,(unsigned long *)tloc);
        }
        return i;

Quote:}

Obiously, this is the guts of time(2) in the kernel.  What I don't understand
is how you get from an application to here.  In the application, of course,
you just do this:
        long now;
        time(&now);
This has to link (at link time) to something, but I can't seem to find a
"time" function in the libc sources...what did I miss?

--
----------------------------------------------------------------------o------
    Clinton A. Pierce       |    "If you rush a Miracle Man     |  \ / \ /

 DCI, Inc. on loan to Ford. | --Miracle Max, The Princess Bride |  / \ / \
------------------------------------------------------------------Freemason--
Geek Code: GCM/GCSd-(++)s+:+a-C++UA++++$UIS+++$UL+++P++++L++E---W++N++w---O
(Revised!)  t++(+++)5+X+R-tv-b+++DI++++G++e+>++h----r+++y+++(--)>y*

 
 
 

1. Intercepting system calls

Hello all...

What is the best way to intercept system calls for a single process?
For example, say a process calls gethostbyname(), and I want to intercept
this and return different information than gethostbyname() would normally
return, how do I do this?

Please reply via email rather than here, if possible.

Thanks in advance
Chris Seatory
System Administrator

2. mount command under UNIX

3. tty7 and tty8 hang while logging in

4. intercepting system calls

5. Problems with 2.4.5ac1[78]

6. Intercepting System Calls

7. Can't see my Linux Box on the Network.

8. Intercepting system calls

9. How to intercept selected system calls

10. How to intercept UNIX system calls ?

11. intercepting the read system call

12. intercept/log SunOS system calls?