* problem with syscall macro
@ 2005-01-12 14:40 sounak chakraborty
2005-01-12 14:57 ` Jan-Benedict Glaw
2005-01-12 15:04 ` linux-os
0 siblings, 2 replies; 3+ messages in thread
From: sounak chakraborty @ 2005-01-12 14:40 UTC (permalink / raw)
To: linux-kernel
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
________________________________________________________________________
Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: problem with syscall macro
2005-01-12 14:40 problem with syscall macro sounak chakraborty
@ 2005-01-12 14:57 ` Jan-Benedict Glaw
2005-01-12 15:04 ` linux-os
1 sibling, 0 replies; 3+ messages in thread
From: Jan-Benedict Glaw @ 2005-01-12 14:57 UTC (permalink / raw)
To: linux-kernel; +Cc: sounak chakraborty
[-- Attachment #1: Type: text/plain, Size: 1874 bytes --]
On Wed, 2005-01-12 14:40:47 +0000, sounak chakraborty <sounakrin@yahoo.co.in>
wrote in message <20050112144047.51119.qmail@web53305.mail.yahoo.com>:
> 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
That's an easy task.
> i am using syslog with syscall3 but when i am using
Why do you want to use syslog with syscall3? syslogd and klogs will
prepare /var/log/messages for you, so you just need to read() it and
write() it to a different file.
> 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
No need for that. You shouldn't fiddle directly with your operating
system's syscall interface. You should use libc's wrappers instead,
which will also correctly set errno and all the like.
> do i have to do it for open system call also
> i am little bit confuse with the kernel-user mode
> switching concept too
Actually, you don't need to know anything about Linux' internals, Linux'
syscall interface etc. You only need to know about the
POSIX/SuSv3/whatever interface the libc presents to userspace. If you
directly use system calls, you'll loose portability and need to fight
against stupid problems like this one.
> could you please help me out
The bottom line is that this isn't a kernel-related question, so you'd
probably ask on a C beginner's mailing list...
See:
man 2 open
man 2 close
man 2 read
man 2 write
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O
fuer einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O
ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA));
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: problem with syscall macro
2005-01-12 14:40 problem with syscall macro sounak chakraborty
2005-01-12 14:57 ` Jan-Benedict Glaw
@ 2005-01-12 15:04 ` linux-os
1 sibling, 0 replies; 3+ messages in thread
From: linux-os @ 2005-01-12 15:04 UTC (permalink / raw)
To: sounak chakraborty; +Cc: linux-kernel
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-01-12 15:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-12 14:40 problem with syscall macro sounak chakraborty
2005-01-12 14:57 ` Jan-Benedict Glaw
2005-01-12 15:04 ` linux-os
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®