Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Aug 2013 14:48:54 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-drivers@freebsd.org
Cc:        freebsd-fs@freebsd.org, abgupta@microsoft.com, varanasi sainath <varanasisai@gmail.com>, freebsd-questions@freebsd.org
Subject:   Re: Kernel Panic - Unix socket communication in kernel module
Message-ID:  <201308231448.54236.jhb@freebsd.org>
In-Reply-To: <CAL_6YgT75YO-yL1s3yq1GyHWxV_TbXaj2OqEddzG-km9sLj8xg@mail.gmail.com>
References:  <CAL_6YgT75YO-yL1s3yq1GyHWxV_TbXaj2OqEddzG-km9sLj8xg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



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