From owner-freebsd-questions@FreeBSD.ORG Fri Aug 23 18:55:26 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D2D626B9; Fri, 23 Aug 2013 18:55:26 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A93D62BD7; Fri, 23 Aug 2013 18:55:25 +0000 (UTC) Received: from jhbbsd.localnet (unknown [38.105.238.108]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id D447FB999; Fri, 23 Aug 2013 14:55:24 -0400 (EDT) From: John Baldwin To: freebsd-drivers@freebsd.org Subject: Re: Kernel Panic - Unix socket communication in kernel module Date: Fri, 23 Aug 2013 14:48:54 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p28; KDE/4.5.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201308231448.54236.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 23 Aug 2013 14:55:25 -0400 (EDT) Cc: freebsd-fs@freebsd.org, abgupta@microsoft.com, varanasi sainath , freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Aug 2013 18:55:26 -0000 On Monday, July 29, 2013 3:31:49 am varanasi sainath wrote: > Hello, > > I am writing a kernel module in which I am trying to connect to a UNIX > socket > (UNIX domain sockets use the file system as their address name space). > Kernel module (loadable) acts as a client and User mode program acts as > server, > I have loaded the module using kldload and communication between > user and kernel module works fine, > when I try to load the kernel module from loader.conf - > auto load the kernel module at boot up leads to kernel panic > as the file system is not ready and kern_connect fails. > > How to notify kernel module that File system is ready? > (any specific event flags) > > Is there any specific location for Unix domain socket files? > (currently created it under /root/soc/socket ) > > Using "MODULE_DEPEND" Can I make the module dependent of file system? You can register a hook for the 'mountroot' EVENTHANDLER event which will fire after / is mounted. (You could compare rootvnode against NULL during module startup to determine if you should defer your work to the EVENTHANDLER vs doing it right away.) If you need to wait for all local filesystems to be mounted, then you will need to have some userland utility poke your module via a sysctl/ioctl/etc. after the filesystems are mounted (you could use a custom rc.d script for this). -- John Baldwin