Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Jul 1997 18:19:49 -0500 (CDT)
From:      jpt@msc.edu (Joseph Thomas)
To:        freebsd-hackers@FreeBSD.ORG
Subject:   Cloned devices???
Message-ID:  <199707212319.SAA06830@uh.msc.edu>

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


	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.



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