Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Nov 2007 18:29:52 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        freebsd-arch@freebsd.org
Subject:   Re: fdclone KPI
Message-ID:  <20071107162951.GA37471@deviant.kiev.zoral.com.ua>
In-Reply-To: <20071031150620.GT37471@deviant.kiev.zoral.com.ua>
References:  <20071031150620.GT37471@deviant.kiev.zoral.com.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--GUfsrdPq8omuo5Le
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Oct 31, 2007 at 05:06:20PM +0200, Kostik Belousov wrote:
> Dear arch@ readers,
> with the important help from Peter Holm I have implemented the KPI that
> provides the ability for the driver to implement cloning on the open(2).
> This is another (IMHO, more UNIXy) way to provide per-fd private data
> for the driver. It seems that at least /dev/apm, /dev/drm and /dev/sg
> could immediately benefit from the fdclone() KPI.
>=20
> The patch is at
> http://people.freebsd.org/~kib/misc/fdclone.9.patch
As Oleksandr Tymoshenko pointed out, the patch was not really available
at this address. Fixed, sorry.

> Sample dumb driver that uses the KPI is at
> http://people.freebsd.org/~kib/fclone
>=20
> The driver that uses the fdclone() shall provide cdevsw for master device,
> and cdevsw for clones. Master shall have d_fdopen() method that could call
> int fdclone(struct cdevsw *_csw, struct file *_fp, int _fmode,
>     struct cdev **_clone, void *si_drv1, struct thread *td);
> to replace the reference in the _fp with newly created cdev.
>=20
> After successfull fdclone() call, all further calls on the _fp
> are dispatched to the clone _csw instead of master one. si_drv1 of the
> new cdev is set to respective argument, allowing the clone to find the
> master.
>=20
> The cloned cdev is not accessible for lookup through the devfs, and is
> destroyed automatically on the final close of the last filedescriptor that
> references the vnode.
>=20
> Please, review. Your feedback is welcome !



--GUfsrdPq8omuo5Le
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (FreeBSD)

iD8DBQFHMef/C3+MBN1Mb4gRAn8KAJ4x3J+nj7bdvdRbwZOOjHaGnWXaQgCcDogL
5F8lAqBVDBo4JplfHq3t7PY=
=SOI0
-----END PGP SIGNATURE-----

--GUfsrdPq8omuo5Le--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071107162951.GA37471>