Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

printk() and printf() question

449 views
Skip to first unread message

K P

unread,
Aug 19, 2002, 4:26:02 AM8/19/02
to
Hello all,
after almost succeeding in adding hte news syscall,I'm no wwtrying to
check if it works.
did compile fromhome dir where the test program is with the following
line:
gcc -pedantic -nostdinc -I../../linux-2.4.18-3/include/linux/
-I../../linux-2.4.18-3/include -Iusr/include try.c -o try
while the try.c looks as folowing:

#include<../../..nsyscall.h>
#include <include.stdio.h> or #include<stdio.h> or many options...
int main()
{
int retval,i=5;
char * msg="ttt";
retval=nsyscall(i,msg);
printf("%d",retval);
return(1);
}
nsyscall is properly added and compiled into kernel syscall,using the
_syscall2 macro as well
however when trying to compile it says that it can't find some file
which stdio.h is supposed to use....
what do i do? the above file is found in numerous locations,do i need
to include everything the stdio.h uses-or is it supposed to find it by
himself?

another question:
I tried to use printk(),instead of the printf(),but it DOESN'T
actually print something to the stdout.... any explanation for this?

thanks a lot to all in advance

Kasper Dupont

unread,
Aug 19, 2002, 5:15:24 AM8/19/02
to
K P wrote:
>
> another question:
> I tried to use printk(),instead of the printf(),but it DOESN'T
> actually print something to the stdout.... any explanation for this?

Yes, printk doesn't print to stdout it prints to the kernel log.
http://www.daimi.au.dk/~kasperd/comp.os.linux.development.faq.html
question #4.

--
Kasper Dupont -- der bruger for meget tid på usenet.
For sending spam use mailto:aaa...@daimi.au.dk
or mailto:mcxumhv...@skrammel.yaboo.dk

Neil Horman

unread,
Aug 18, 2002, 7:09:21 PM8/18/02
to
You can force printk to print messages to the console through the use of two
variables. The first is passed into printk itself. If you look at some example
usage of printk you will see the printed strings precedd by one of several
#defines, KERN_EMERG through KERN_DEBUG, all defined in kernel.h. Secondly, in
/proc/sys/kernel/printk, you will see a series of numbers. I can't oof the top
of my head recall what they all mean exactly, but I do know that the first
number defines the console log level. That first number reflects the #define
value in kernel.h below which printk get displayed on the console as well as in
the log. For instance if it is set to 1, only messages which are KERN_ALERT and
KERN_EMERG will be displayed. You can adjust this value to reflect how much
console printing you would like.
Neil

K P

unread,
Aug 19, 2002, 1:47:49 PM8/19/02
to
Hello,
thanks for the reply.
however,although I include the required kernel.h in the file which
uses the printk(),I get the following error: "undefined refernce to
printk()"

So tried to stick with the printf(),and I find that when I compile a
call to printf() with the regular gcc try.c it compiles and
works,however,when I compile a slighlty different file,which uses my
new syscall-with the long "gcc -pedantic -I../../linux/include
-I../../linux/include |..etc.line from my previous message-which I
need to properly include various system, files(I think)....-it can't
correctly find a file which a certain file included by stdio.h
includes...

I've tried "gcc -E try.c |less",and I see that the steps that both the
compilations take are similar-both seems to find the above
file(stdarg.h),but inthe 2nd case I still get an error msg,and the
compilation fails.
Can you think of a solution for this,please??? I've spent a week
adding the systam call,and now can't even check that it works....Got
to submit the thing tomorow,as well....


Thanks in advance,
Katy

Kasper Dupont <kas...@daimi.au.dk> wrote in message news:<3D60B72C...@daimi.au.dk>...

0 new messages