Driver development question

Chris Harrer cjharrer at comcast.net
Wed Jul 29 18:02:31 UTC 2009


>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



More information about the freebsd-drivers mailing list