Re: problem with syscall macro

From: linux-os
Date: Wed Jan 12 2005 - 10:06:29 EST


On Wed, 12 Jan 2005, sounak chakraborty wrote:

i am writing a program which willcopy all the lines
from system log file /var/log/messages and put it in a
user log file
i am using syslog with syscall3 but when i am using
write system cal it is not able to write anything
do i have to add something more
i have added the syscall3 macro for write too
do i have to do it for open system call also
i am little bit confuse with the kernel-user mode
switching concept too
could you please help me out
thans
sounak


You are very confused. The "stuff" that comes from the
kernel, printk(), etc., is buffered by the kernel and
then read by user-mode code from /proc/kmsg.

But, once you read it, it's gone. Therefore there is
a procedure, int syslog(int type, char *buf, int buf_len);
that allows a user to read/manuiplate the logging
facility. `man syslog` will get you that information.
You do __not__ use _syscall3(). See the underscore in
the name? Things that begin with underscores are used by
the 'C' runtime library, not you directly.

#include <stdio.h>
#include <sys/syslog.h>
int main() {
char buf[0x2000];
syslog(3, buf, sizeof(buf));
puts(buf);
return 0;
}

Cheers,
Dick Johnson
Penguin : Linux version 2.6.10 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/