Date: Wed, 29 Jul 2009 14:02:30 -0400 From: "Chris Harrer" <cjharrer@comcast.net> To: "'John Baldwin'" <jhb@freebsd.org> Cc: freebsd-drivers@freebsd.org Subject: RE: Driver development question Message-ID: <000d01ca1076$bdf58510$39e08f30$@net> In-Reply-To: <200907291356.51702.jhb@freebsd.org> References: <002801ca06f0$b1d42af0$157c80d0$@net> <20090725035643.GT49724@elvis.mu.org> <000c01ca1071$54991d70$fdcb5850$@net> <200907291356.51702.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
>The problem is that kernel threads do not have a valid file descriptor table, >hence fd_cdir is NULL. You could work around this if you create a dedicated >kproc and set fd_cdir to rootvnode (but vref() rootvnode when you do this). >You should also set fd_rdir and fd_jdir to rootvnode as well (also doing >appropriate vref() of rootvnode for each reference). Something like this: > > struct filedesc *fdp; > > fdp = curthread->td_proc->p_fd; > FILEDESC_XLOCK(fdp); > fd->fd_rdir = rootvnode; > vref(rootvnode); > fd->fd_jdir = rootvnode; > vref(rootvnode); > fd->fd_cdir = rootvnode; > vref(rootvnode); > FILEDESC_XUNLOCK(fdp); > >You should not do this from a callout routine or interrupt handler however. >You could do this via a TASK to a private taskqueue with a dedicated kernel >process however. (i.e. queue a task that does the above during after >creating the taskqueue and then queue a task to create the file later). > >-- >John Baldwin John, Thanks so much for the help and quick response, I will try this now. Cheers, Chris
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000d01ca1076$bdf58510$39e08f30$>