Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Jun 2002 17:44:51 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        "Vladimir B. Grebenschikov" <vova@sw.ru>
Cc:        Poul-Henning Kamp <phk@critter.freebsd.dk>, Maksim Yevmenkin <m_evmenkin@yahoo.com>, "current@freebsd.org" <current@freebsd.org>
Subject:   Re: Device cloning
Message-ID:  <3D054803.F3A0D76E@mindspring.com>
References:  <29346.1023743719@critter.freebsd.dk> <1023748326.595.69.camel@vbook.express.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
"Vladimir B. Grebenschikov" wrote:
> As far as I understand _key_ word is "open", each new instance appears
> on open(), but fork() and dup() only do regular work. dup'ed or fork'ed
> descriptors will be same from driver's point of view, but each new
> open() will create new instance.

No.

The problem is that if you open the same thing N times, you will
get N references to the single vnode of the thing.

For devices, it's possible to kludge this, so that the device
gives you a different vnode for each instance; however, the
close is not sufficiently tracked unless you also give back
a different minor number for each open instance.  The problem
is that there is no per reference instance information that
is stored with the vnode and given to the device, as a context,
with each operation, other tha the device context itself.  So
the only way to do this is a different minor number, so that
the device is capable of maintaining its own per open instance
information.

It's also really questionable what the correct course of action
for the fork/dup/dup2 code is.  Consider the case of a program
that intentionally forks, so that one process can read from the
/etc/tty and write to the device, while the other can do the
opposite (this is how the original "cu" program worked).  On
top of this, add descriptor passing.

This breaks down to: are you creating a new open instance, or
are you manipulating a reference to an existing open instance?

Pushing this information over the "struct fileops" barrier is
not a very easy thing to do.  It would require reorganization
of a lot of code.

While this code is in *dire* need of reorganization, when you
are done, if you can't answer the question about whether you
are doing a "dup" or passing a reference to a single instance
when you pass an FD between processes... well... you're in a
bit of a jam.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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