From owner-freebsd-drivers@FreeBSD.ORG Wed Jul 29 18:02:31 2009 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2CCC01065675 for ; Wed, 29 Jul 2009 18:02:31 +0000 (UTC) (envelope-from cjharrer@comcast.net) Received: from QMTA08.westchester.pa.mail.comcast.net (qmta08.westchester.pa.mail.comcast.net [76.96.62.80]) by mx1.freebsd.org (Postfix) with ESMTP id CE69F8FC17 for ; Wed, 29 Jul 2009 18:02:30 +0000 (UTC) (envelope-from cjharrer@comcast.net) Received: from OMTA20.westchester.pa.mail.comcast.net ([76.96.62.71]) by QMTA08.westchester.pa.mail.comcast.net with comcast id MnCq1c0051YDfWL58u2XYK; Wed, 29 Jul 2009 18:02:31 +0000 Received: from record ([69.253.164.177]) by OMTA20.westchester.pa.mail.comcast.net with comcast id Mu4P1c00B3py3KZ3gu4PGZ; Wed, 29 Jul 2009 18:04:24 +0000 From: "Chris Harrer" To: "'John Baldwin'" References: <002801ca06f0$b1d42af0$157c80d0$@net> <20090725035643.GT49724@elvis.mu.org> <000c01ca1071$54991d70$fdcb5850$@net> <200907291356.51702.jhb@freebsd.org> In-Reply-To: <200907291356.51702.jhb@freebsd.org> Date: Wed, 29 Jul 2009 14:02:30 -0400 Message-ID: <000d01ca1076$bdf58510$39e08f30$@net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-index: AcoQdfiCG9t44+1bSKSxSEicpj0saQAAHWVQ Content-Language: en-us Cc: freebsd-drivers@freebsd.org Subject: RE: Driver development question X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jul 2009 18:02:31 -0000 >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