Date: Mon, 29 Jul 2013 12:19:30 +0100 From: Frank Leonhardt <frank2@fjl.co.uk> To: freebsd-questions@freebsd.org Subject: Re: Kernel Panic - Unix socket communication in kernel module Message-ID: <51F64FC2.8080506@fjl.co.uk> 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 29/07/2013 08:31, 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? > > I shall resist the obvious "why" question. I'm assuming you're talking about a fifo here (aka named pipe, and occasionally called UNIX socket) rather than the BSD network socket interface. IIRC since 4.3BSD fifos have been implemented using sockets internally anyway. Where to put it? I tend to go for /tmp but somewhere in /var might make more sense for something that's always supposed to be there. I don't know how to tell when the FS is ready but it will be when init runs, so you might like to try the sysctl variables. Knowing that init is always PID 1, the value of kern.lastpid should give a hint. There may be an official way of doing this properly. You could always load the module from rc.local instead. Regards, Frank. P.S. You do know that an fd only relates to the kernel thread it's currently running in?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51F64FC2.8080506>