From owner-freebsd-questions Sat Mar 24 8:57: 4 2001 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-65-26-235-186.mmcable.com [65.26.235.186]) by hub.freebsd.org (Postfix) with SMTP id 203D537B71D for ; Sat, 24 Mar 2001 08:56:58 -0800 (PST) (envelope-from mwm@mired.org) Received: (qmail 39761 invoked by uid 100); 24 Mar 2001 16:56:57 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15036.53720.771043.278418@guru.mired.org> Date: Sat, 24 Mar 2001 10:56:56 -0600 To: "Kernel Newbie" Cc: questions@freebsd.org Subject: Re: writing to a file from kernel mode In-Reply-To: <83340799@toto.iv> X-Mailer: VM 6.89 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Kernel Newbie 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. 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