Per-open file private data for the cdevs

Ed Schouten ed at 80386.nl
Mon May 5 07:49:25 UTC 2008


* 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.

-- 
 Ed Schouten <ed at 80386.nl>
 WWW: http://80386.nl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20080505/e4857e27/attachment.pgp


More information about the freebsd-arch mailing list