Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 07 Nov 2000 18:43:09 -0800
From:      bruno schwander <bschwand@dvart.com>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: close call in a device ?
Message-ID:  <3A08BDBD.575A6AA4@dvart.com>
References:  <200011080157.RAA00555@iguana.aciri.org>

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

The reason I am doing this, is precisely because I need to virtualize accesses
from several processes to _one_  _predefined_ device. I have no control over that
device name from the client process point of view, so I can not have multiple
devices.  I pretty much need to be able to lie to the process, telling it that it
has full control of the device it wants, and actually allow other processes to
open and use the device in the same way at the same time.

Did I miss something in your suggestion ? Or were you suggesting that I can
create same name device entries, differing only by their minor number ? But then
I still hit the problem that the processes are maybe not going to open the device
in exclusive mode ?


> the reason for this is that you might have a process fork() after
> it has opened the device, and you do not want to get to the
> device all close calls from all processes generated by the original
> one, but really only the last instance.
>
> The thing is, i think your model (allocating per-user resources on
> open) is wrong. It cannot protect you from a process forking
> and then having two instances using the same device.
>

I can walk the process tree to figure whose parent process allocated the resource
and thus use the same resource for the child, so this is not a problem (I
think...). Besides, in my context, I doubt the process will fork after opening
the device.

> If you want multiple instances of the device, one option could be
> to use the minor number and really create multiple instances
> of the device, and open them in exclusive way so you know that
> there can be only one open per device (you should scan available
> devices in a similar way as the one is used for scanning pty's).
>
>         cheers
>         luigi



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




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