PDA

View Full Version : Minix and system calls!!!help!



squeezah
04-01-2008, 09:07 AM
Need some help with minix!!! To put it simple,what i want is,when i execute a system call, me or the OS,to also print a random message followed be the system call's name i just used.
Any help would be appreciated.

matsp
04-01-2008, 09:08 AM
You will have to add code in the system call function itself to produce this information. This is implemented in most Unix varieties for the strace command.

--
Mats

squeezah
04-01-2008, 09:20 AM
i need to print the msg with the name of system call ,whatever system call i use.when i typing ls for example with what order this call execute?
if i want to print just something when a call is executing i can put a printf in exec right?but what about the name of the call?

brewbuck
04-01-2008, 09:35 AM
Need some help with minix!!! To put it simple,what i want is,when i execute a system call, me or the OS,to also print a random message followed be the system call's name i just used.
Any help would be appreciated.

Capturing a process's system calls is usually done with ptrace(). I have no idea if Minix has it, but I assume it does.

squeezah
04-01-2008, 10:44 AM
strace doesnt work in minix...:(

brewbuck
04-01-2008, 12:06 PM
strace doesnt work in minix...:(

strace works by using ptrace(). Do you at least have ptrace() on Minix? If not, you'll have to hack the standard library to hook the syscall entry points, which will be a pain.

squeezah
04-01-2008, 12:50 PM
no other way to 'capture' the system call's name??

brewbuck
04-01-2008, 01:06 PM
no other way to 'capture' the system call's name??

No. I keep suggesting ptrace() and you keep ignoring it for some reason.

squeezah
04-01-2008, 02:15 PM
am not ignoring it:) how can i use it?

brewbuck
04-01-2008, 02:38 PM
am not ignoring it:) how can i use it?

Surely Minix has a manual? It would be far more informative than my random guesses. Googling for "minix ptrace" might be useful.

CornedBee
04-01-2008, 02:45 PM
It is, I just did. Not quite as helpful as you'd think, though.

squeezah
04-01-2008, 02:58 PM
i use man ptrace and says
Note: This manual page has no relation to Minix. Someone who
knows
ptrace() has to check, or rewrite, this page. :P

brewbuck
04-01-2008, 02:58 PM
It is, I just did. Not quite as helpful as you'd think, though.

Well, Minix is getting old in the tooth. If there's no good manual out there anymore, then the OP will have to resort to random hacking.

Most UNIX-like operating systems provide equivalent functionality through ptrace(), but the details are all slightly different.

CornedBee
04-01-2008, 03:01 PM
You could also look at the source of ptrace. I think it's the kernel function do_trace, here:
https://gforge.cs.vu.nl/plugins/scmsvn/viewcvs.php/trunk/src/kernel/system/do_trace.c?rev=2734&root=minix&view=markup

squeezah
04-01-2008, 03:05 PM
can i ask something ?maybe is wrong or stupid:P a call is executing through exec right?which is the function that reads from shell and l8r other fuction/call call exec??

CornedBee
04-01-2008, 04:32 PM
Once more so that we understand what you mean, please.

squeezah
04-02-2008, 09:02 AM
i just want to find out where i can put a printf to print the system call name that i just used.When i execute ls before see ls results i want to print am gonna execute :ls.what function starts when i type ls?

CornedBee
04-02-2008, 11:01 AM
Are you confusing system calls with core utilities?

squeezah
04-02-2008, 11:03 AM
maybe :) i just want to know what happens when i press ls

CornedBee
04-02-2008, 11:06 AM
Type
which ls
and it will tell you exactly which executable will be called.

Then look at the source for it.

squeezah
04-02-2008, 11:47 AM
CornedBee one last thing:)
how can i print the executable's name every time something is being executed?

CornedBee
04-02-2008, 11:49 AM
I fail to see how that would be useful, but I suppose you'd have to look into the CRT implementation of the exec* family, track it down to the lowest common function and modify that to do what you want.

squeezah
04-02-2008, 04:46 PM
is there any possibility to know exactly what function i have to modify?

dwks
04-02-2008, 05:40 PM
how can i print the executable's name every time something is being executed?
You don't mean something like this, by any chance?

#include <stdio.h>

int main(int argc, char *argv[]) {
printf("&#37;s\n", argv[0]);
return 0;
}
Never mind, I obviously didn't read the thread properly.

Maybe this will be useful: http://www.raspberryginger.com/jbailey/minix/html/commands_2ash_2exec_8c-source.html

brewbuck
04-02-2008, 07:19 PM
is there any possibility to know exactly what function i have to modify?

Could we please know exactly what you're trying to do, just to make sure we're talking about something that makes sense? I mean your ULTIMATE goal. Are you trying to monitor everything every process ever does?