Re: problem with syscall macro
From: Jan-Benedict Glaw
Date: Wed Jan 12 2005 - 09:58:37 EST
On Wed, 2005-01-12 14:40:47 +0000, sounak chakraborty <sounakrin@xxxxxxxxxxx>
wrote in message <20050112144047.51119.qmail@xxxxxxxxxxxxxxxxxxxxxxx>:
> 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@xxxxxxxxxx . +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:
signature.asc
Description: Digital signature