Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Mar 2001 10:56:56 -0600
From:      Mike Meyer <mwm@mired.org>
To:        "Kernel Newbie" <kernel_newbie@hotmail.com>
Cc:        questions@freebsd.org
Subject:   Re: writing to a file from kernel mode
Message-ID:  <15036.53720.771043.278418@guru.mired.org>
In-Reply-To: <83340799@toto.iv>

next in thread | previous in thread | raw e-mail | index | archive | help
Kernel Newbie <kernel_newbie@hotmail.com> types:
> 1. I need to write to a file from within a kernel mode. is that possible ? 
> if yes, how do I do it ?

I don't know if it's possible, but it's certainly the wrong solution
to this problem. In generaly, you don't write files from the kernel -
you provide an api so applications can get the information, and then
the application writes the informtion. That way configuration choices
- like where to put the file - can be made in userland. Bill Moran
already suggested syslog, which is a typical solution when you need to
push information from the kernel.

> 2. Basically, what I need to do is to maintain a seperate counts of IP 
> packets received from seperate IP addresses. and I need to view the 
> statistics from the user mode. Any suggestions on how to go about it ??

If you've got syslog enabled on a current version of freebsd, it's
already configured to log messages from the kernel ipfw facility to
/var/log/security. Those messages include both pretty much everything
you'd want to know about the packets. If you aren't using ipfw, then
the command

	ipfw add allow log ip from any to any

will start logging every packet. If you are already using ipfw, then
you just need to add the logging to your current rules.  You'll want
to check your current kernel config to make sure it's not throwing out
some messages.

You can then analyze the files to your hearts content.

If you really want to maintain the counts in the kernel, then add a
sysctl to let you get the ip address and counts from the kernel.

	<mike
--
Mike Meyer <mwm@mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15036.53720.771043.278418>