Per-open file private data for the cdevs
John Baldwin
jhb at freebsd.org
Mon May 5 13:56:17 UTC 2008
On Monday 05 May 2008 03:49:24 am Ed Schouten wrote:
> * Kostik Belousov <kostikbel at gmail.com> wrote:
> > Since the review for the clone-at-open patch (fdclone) posted some time
> > ago mostly says that it would be better to implement per-file private
> > data instead, I produced the patch along this line,
>
> I also thought about this. The new TTY layer I'm developing needs the
> following patch to implement /dev/ptmx and /dev/ptyXX compatibility:
>
> --- sys/fs/devfs/devfs_vnops.c
> +++ sys/fs/devfs/devfs_vnops.c
> @@ -800,9 +800,8 @@
> if(fp == NULL)
> return (error);
> #endif
> - KASSERT(fp->f_ops == &badfileops,
> - ("Could not vnode bypass device on fdops %p", fp->f_ops));
> - finit(fp, fp->f_flag, DTYPE_VNODE, dev, &devfs_ops_f);
> + if (fp->f_ops == &badfileops)
> + finit(fp, fp->f_flag, DTYPE_VNODE, dev, &devfs_ops_f);
> return (error);
> }
>
> This way drivers can just implement d_fdopen() and call finit() there.
> It's probably not as nice as having the per-fdesc stuff inside devfs
> itself, but I'm not sure the amount of drivers that needs this makes it
> worth adding it to devfs itself.
Many drivers currently do devfs cloning soley to get per-file data. Other
OS's (such as WinXP and Linux) already provide facilities for drivers to set
per-file data as well. This is definitely very useful.
--
John Baldwin
More information about the freebsd-arch
mailing list