From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 12 01:50:48 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0392B16A4CE for ; Mon, 12 Jul 2004 01:50:48 +0000 (GMT) Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5CE8E43D5C for ; Mon, 12 Jul 2004 01:50:47 +0000 (GMT) (envelope-from dev@opensound.com) Received: from [192.1.2.22] (c-24-127-17-145.we.client2.attbi.com[24.127.17.145]) by comcast.net (sccrmhc11) with ESMTP id <20040712015041011009g27me> (Authid: opensound); Mon, 12 Jul 2004 01:50:46 +0000 Message-ID: <40F1EE71.6000704@opensound.com> Date: Sun, 11 Jul 2004 18:50:41 -0700 From: 4Front Technologies User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040616 X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-hackers@FreeBSD.ORG Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Mon, 12 Jul 2004 12:13:02 +0000 Subject: FreeBSD open() questions X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2004 01:50:48 -0000 Hi, We are trying to implement multi-open() in our OSS drivers for FreeBSD. The idea is that all apps keep opening /dev/dsp and internally OSS finds the next available device (/dev/dspNN+1) and returns that device's minor number back to the open routine. What happens is that every read/write/close/ioctl call now uses the new minor number. This works in Solaris and Linux. In Solaris the open routine has an extra parameter that permits giving a new device number that will be used in subsequent read/write/etc calls. Changing this field doesn't affect the way how open works. In Linux struct file has a private field that the driver can use as it likes. We simply store the major/minor number in this field. In the read/write/ioctl/etc routines we read the device number from this field instead of using inode->dev. BSD doesn't have such mechanisms. The dev_t parameter is a "global" one and the same structure is shared by all applications having the same device file opened. If you change anything in this structure then it will affect the other applications that had opened the same file. Every time one application tries to open /dev/dsp the changes will affect also the applications that are already running (they will jump to use the new device). I've taken a look at dev_clone and EVENT_HANDLER stuff in FreeBSD's pcm drivers but essentially this works by creating a new device and adding it via devfs_create if you access /dev/dsp. But in our case we have already added all the devices so using dev_clone doesn't work (or atleast I've not been able to get it to do what we want) We already have all the devices configured during our Module Load. So all we really want to do is if you open /dev/dsp, OSS's device manager will look for a free device and return that device's minor number and from now on all read/write/ioctl/close routines will use that device number. Does anybody have any suggestions on how to get such features working in both FreeBSD 4x and 5x? Should we be looking at /dev/tty (because you can keep opening /dev/tty and it kind of behaves the same way OSS's open works in Solaris or Linux. BTW, we also want to work with the BSD audio guys to implement the upcoming OSS V4.0 mixer extensions that will allow you to add mixer extensions to devices that aren't your standard AC97 or ISA devices. So if anyone wants to extend FreeBSD's OSS api, by all means contact us and we'll work with you to implement this. best regards Dev Mazumdar PS: Please respond directly to me as I'm not subscribed to the freebsd-hackers list. ----------------------------------------------------------- 4Front Technologies 4035 Lafayette Place, Unit F, Culver City, CA 90232, USA. Tel: (310) 202 8530 URL: www.opensound.com Fax: (310) 202 0496 Email: info@opensound.com -----------------------------------------------------------