From owner-freebsd-hackers Mon Jul 21 16:20:06 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id QAA19285 for hackers-outgoing; Mon, 21 Jul 1997 16:20:06 -0700 (PDT) Received: from noc.msc.edu (noc.msc.edu [137.66.12.254]) by hub.freebsd.org (8.8.5/8.8.5) with SMTP id QAA19241 for ; Mon, 21 Jul 1997 16:19:58 -0700 (PDT) Received: from uh.msc.edu by noc.msc.edu (5.65/MSC/v3.0.1(920324)) id AA15043; Mon, 21 Jul 97 18:19:49 -0500 From: jpt@msc.edu (Joseph Thomas) Received: (jpt@localhost) by uh.msc.edu (8.7.1/8.6.6) id SAA06830 for freebsd-hackers@FreeBSD.ORG; Mon, 21 Jul 1997 18:19:50 -0500 (CDT) Message-Id: <199707212319.SAA06830@uh.msc.edu> Subject: Cloned devices??? To: freebsd-hackers@FreeBSD.ORG Date: Mon, 21 Jul 1997 18:19:49 -0500 (CDT) X-Mailer: ELM [version 2.4 PL25] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk I'm looking for a way to do what the 'clone' device in SunOS/streams allows the driver to do. Any pointers/ideas? (Okay - let's see if I can explain this and make it understandable.) Basically, I have an application which would like to have several unique opens to a device without the application having to poll minor numbers. With the clone device, an open call to a known major/minor will cause the xxx_open() routine to find an unused minor device and return makedev(major,unique minor). A couple of advantages of this include a) user always opens one device, b) you don't clutter up your /dev directory with every possible major/minor pair. Example: /dev has node clone, major M, minor 0. application does: for ( i = 0; i < 3; i++ ) fd[i] = open ( "/dev/clone", O_RDWR ); where fd[0] would actually point to a device with major M, minor 1, fd[1] would point to major M, minor 2, and fd[2] would point to major M, minor 3. what I'd like to avoid is: /dev/clone00 major M, minor 0 /dev/clone01 major M, minor 1 /dev/clone02 major M, minor 2 /dev/clone03 major M, minor 3 . . . /dev/cloneNN major M, minor NN and application: for ( i = 0; i < 3; i++ ) for ( j = 0; j < NN; j++ ) { sprintf ( name, "/dev/clone%2d", j ); if ( ( fd[i] = open ( name, O_RDWR ) ) > 0 ) break; } Does this make sense? -- Joseph Thomas E/Mail: jpt@msc.edu Minnesota Supercomputer Center, Inc. jpt@magic.net 1200 Washington Ave So. Tel: +1 612 337 3558 Minneapolis, MN 55415-1227 FAX: +1 612 337 3400 An elephant is a mouse with an operating system.