public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC] char/tty_io: fix legacy pty name when more than 256 pty devices are requested
@ 2009-09-08 17:49 Mauro Carvalho Chehab
  2009-09-08 17:59 ` Alan Cox
  2009-09-08 22:48 ` [PATCH " H. Peter Anvin
  0 siblings, 2 replies; 26+ messages in thread
From: Mauro Carvalho Chehab @ 2009-09-08 17:49 UTC (permalink / raw)
  To: LKML; +Cc: Kay Sievers, Andrew Morton, Alan Cox, Greg Kroah-Hartman

There are some use cases where more than 256 pty device pairs are needed.
   
With kernel 2.6, the number of minors is not 256 anymore. So, it is
possible to have more than 256 pty devices, either by specifying the number
of tty devices at CONFIG_LEGACY_PTY_COUNT or by using tty.legacy_count parameter
at boot time.

However, the pty_line_name() only provides device names for the first
256 tty/pty devices.

As this function is used to generate the sysfs class name, any number of
pty devices above 256 will fail to properly register them at sysfs.

This is a bug, since there's no limits for the maximum number of legacy
pty devices at Kconfig or at pty.legacy_count.

It is important to preserve the old nomenclature for tty/pty devices for the
first 256 devices, to avoid breakage on existing applications and with udev.

So, in order to allow more pty devices, the nomenclature were extended for
the devices with minor 256 or above. For those, the nomenclature will be:
	ttyf0000-ttfpffff	(pty slave)
	ptyf0000-ttyfffff	(pty master)

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index a3afa0c..fdea89b 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1110,9 +1110,15 @@ static void pty_line_name(struct tty_driver *driver, int index, char *p)
 {
 	int i = index + driver->name_base;
 	/* ->name is initialized to "ttyp", but "tty" is expected */
-	sprintf(p, "%s%c%x",
-		driver->subtype == PTY_TYPE_SLAVE ? "tty" : driver->name,
-		ptychar[i >> 4 & 0xf], i & 0xf);
+	if (i < 256) {
+		sprintf(p, "%s%c%x",
+				driver->subtype == PTY_TYPE_SLAVE ? "tty" : driver->name,
+				ptychar[i >> 4 & 0xf], i & 0xf);
+	} else {	/* Up to 4096 */
+		sprintf(p, "%sf%04x",
+				driver->subtype == PTY_TYPE_SLAVE ? "tty" : driver->name,
+				i - 256);
+	}
 }
 
 /**





Cheers,
Mauro

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2009-09-11  8:42 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-08 17:49 [PATCH RFC] char/tty_io: fix legacy pty name when more than 256 pty devices are requested Mauro Carvalho Chehab
2009-09-08 17:59 ` Alan Cox
2009-09-08 18:56   ` Mauro Carvalho Chehab
2009-09-08 18:59   ` [PATCH v2 " Mauro Carvalho Chehab
2009-09-08 22:48 ` [PATCH " H. Peter Anvin
2009-09-08 23:33   ` Mauro Carvalho Chehab
2009-09-09  0:26     ` H. Peter Anvin
2009-09-09  2:54       ` Mauro Carvalho Chehab
2009-09-09  4:46         ` H. Peter Anvin
2009-09-10  4:05           ` [PATCH] " Mauro Carvalho Chehab
2009-09-10  6:21             ` H. Peter Anvin
2009-09-10 12:33               ` Mauro Carvalho Chehab
2009-09-10 14:07                 ` Alan Cox
2009-09-10 15:57                   ` H. Peter Anvin
2009-09-10 16:08                   ` H. Peter Anvin
2009-09-10 19:12                     ` Mauro Carvalho Chehab
2009-09-10 19:17                       ` H. Peter Anvin
2009-09-10 20:05                         ` Mauro Carvalho Chehab
2009-09-10 20:35                           ` H. Peter Anvin
2009-09-10 23:23                       ` Alan Cox
2009-09-10 23:25                         ` H. Peter Anvin
2009-09-11  8:43                     ` Alan Cox
2009-09-10  4:13           ` [PATCH RFC] " Mauro Carvalho Chehab
2009-09-10  5:33             ` H. Peter Anvin
2009-09-10 12:18               ` Mauro Carvalho Chehab
2009-09-10 10:19             ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox