Date: Mon, 5 May 2008 09:30:17 -0400 From: John Baldwin <jhb@freebsd.org> To: freebsd-arch@freebsd.org Cc: Kostik Belousov <kostikbel@gmail.com>, Ed Schouten <ed@80386.nl>, arch@freebsd.org Subject: Re: Per-open file private data for the cdevs Message-ID: <200805050930.18114.jhb@freebsd.org> In-Reply-To: <20080505074924.GF1181@hoeg.nl> References: <20080504171002.GN18958@deviant.kiev.zoral.com.ua> <20080505074924.GF1181@hoeg.nl>
next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 05 May 2008 03:49:24 am Ed Schouten wrote:
> * Kostik Belousov <kostikbel@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805050930.18114.jhb>
