[RFC,1/2] tty: fix /dev/tty{1,63} minor number

Submitted by Dmitry Safonov on April 27, 2016, 5:10 p.m.

Details

Message ID 1461777054-6898-2-git-send-email-dsafonov@virtuozzo.com
State Accepted
Series "tty small fixes"
Commit e9f9f29f92b25845af6ac4ee6f7568a47f891f50
Headers show

Commit Message

Dmitry Safonov April 27, 2016, 5:10 p.m.
Seems like, device with TTY_MAJOR major and minor MIN_NR_CONSOLES
is pointing to /dev/tty1 (first vitual console) and MAX_NR_CONSOLES
is /dev/tty63.

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
---
 criu/tty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/tty.c b/criu/tty.c
index 68d7ba3d133b..7c634e19ebc0 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -261,7 +261,7 @@  struct tty_driver *get_tty_driver(dev_t rdev, dev_t dev)
 			return &ctty_driver;
 		break;
 	case TTY_MAJOR:
-		if (minor > MIN_NR_CONSOLES && minor < MAX_NR_CONSOLES)
+		if (minor >= MIN_NR_CONSOLES && minor <= MAX_NR_CONSOLES)
 			/*
 			 * Minors [MIN_NR_CONSOLES; MAX_NR_CONSOLES] stand
 			 * for consoles (virtual terminals, VT in terms

Comments

Cyrill Gorcunov April 27, 2016, 5:25 p.m.
On Wed, Apr 27, 2016 at 08:10:53PM +0300, Dmitry Safonov wrote:
> Seems like, device with TTY_MAJOR major and minor MIN_NR_CONSOLES
> is pointing to /dev/tty1 (first vitual console) and MAX_NR_CONSOLES
> is /dev/tty63.
> 
> Cc: Cyrill Gorcunov <gorcunov@openvz.org>
> Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
> ---
>  criu/tty.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/criu/tty.c b/criu/tty.c
> index 68d7ba3d133b..7c634e19ebc0 100644
> --- a/criu/tty.c
> +++ b/criu/tty.c
> @@ -261,7 +261,7 @@ struct tty_driver *get_tty_driver(dev_t rdev, dev_t dev)
>  			return &ctty_driver;
>  		break;
>  	case TTY_MAJOR:
> -		if (minor > MIN_NR_CONSOLES && minor < MAX_NR_CONSOLES)
> +		if (minor >= MIN_NR_CONSOLES && minor <= MAX_NR_CONSOLES)
>  			/*
>  			 * Minors [MIN_NR_CONSOLES; MAX_NR_CONSOLES] stand
>  			 * for consoles (virtual terminals, VT in terms

Wait! IIRC MIN_NR_CONSOLES stands for 0 so it is pointing to /dev/tty
and should be treated as current tty.

[cyrill@uranus ~] stat /dev/tty
  File: ‘/dev/tty’
Device: 6h/6dInode: 1035        Links: 1     Device type: 5,0
Dmitry Safonov April 27, 2016, 5:28 p.m.
On 04/27/2016 08:25 PM, Cyrill Gorcunov wrote:
> On Wed, Apr 27, 2016 at 08:10:53PM +0300, Dmitry Safonov wrote:
>> Seems like, device with TTY_MAJOR major and minor MIN_NR_CONSOLES
>> is pointing to /dev/tty1 (first vitual console) and MAX_NR_CONSOLES
>> is /dev/tty63.
>>
>> Cc: Cyrill Gorcunov <gorcunov@openvz.org>
>> Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
>> ---
>>   criu/tty.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/criu/tty.c b/criu/tty.c
>> index 68d7ba3d133b..7c634e19ebc0 100644
>> --- a/criu/tty.c
>> +++ b/criu/tty.c
>> @@ -261,7 +261,7 @@ struct tty_driver *get_tty_driver(dev_t rdev, dev_t dev)
>>   			return &ctty_driver;
>>   		break;
>>   	case TTY_MAJOR:
>> -		if (minor > MIN_NR_CONSOLES && minor < MAX_NR_CONSOLES)
>> +		if (minor >= MIN_NR_CONSOLES && minor <= MAX_NR_CONSOLES)
>>   			/*
>>   			 * Minors [MIN_NR_CONSOLES; MAX_NR_CONSOLES] stand
>>   			 * for consoles (virtual terminals, VT in terms
> Wait! IIRC MIN_NR_CONSOLES stands for 0 so it is pointing to /dev/tty
> and should be treated as current tty.
>
> [cyrill@uranus ~] stat /dev/tty
>    File: ‘/dev/tty’
> Device: 6h/6dInode: 1035        Links: 1     Device type: 5,0

Hmm, could you tell the kernel version on which MIN_NR_CONSOLES
is zero? On current master it's:
> [linux]$ git grep MIN_NR_CONSOLES
> include/uapi/linux/vt.h:#define MIN_NR_CONSOLES 1       /* must be at 
> least 1 */
> [linux]$ 
What I overlooked?
Cyrill Gorcunov April 27, 2016, 5:46 p.m.
On Wed, Apr 27, 2016 at 08:28:07PM +0300, Dmitry Safonov wrote:
> On 04/27/2016 08:25 PM, Cyrill Gorcunov wrote:
> >On Wed, Apr 27, 2016 at 08:10:53PM +0300, Dmitry Safonov wrote:
> >>Seems like, device with TTY_MAJOR major and minor MIN_NR_CONSOLES
> >>is pointing to /dev/tty1 (first vitual console) and MAX_NR_CONSOLES
> >>is /dev/tty63.
> >>
> >>Cc: Cyrill Gorcunov <gorcunov@openvz.org>
> >>Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
> >>---
> >>  criu/tty.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >>diff --git a/criu/tty.c b/criu/tty.c
> >>index 68d7ba3d133b..7c634e19ebc0 100644
> >>--- a/criu/tty.c
> >>+++ b/criu/tty.c
> >>@@ -261,7 +261,7 @@ struct tty_driver *get_tty_driver(dev_t rdev, dev_t dev)
> >>  			return &ctty_driver;
> >>  		break;
> >>  	case TTY_MAJOR:
> >>-		if (minor > MIN_NR_CONSOLES && minor < MAX_NR_CONSOLES)
> >>+		if (minor >= MIN_NR_CONSOLES && minor <= MAX_NR_CONSOLES)
> >>  			/*
> >>  			 * Minors [MIN_NR_CONSOLES; MAX_NR_CONSOLES] stand
> >>  			 * for consoles (virtual terminals, VT in terms
> >Wait! IIRC MIN_NR_CONSOLES stands for 0 so it is pointing to /dev/tty
> >and should be treated as current tty.
> >
> >[cyrill@uranus ~] stat /dev/tty
> >   File: ‘/dev/tty’
> >Device: 6h/6dInode: 1035        Links: 1     Device type: 5,0
> 
> Hmm, could you tell the kernel version on which MIN_NR_CONSOLES
> is zero? On current master it's:
> >[linux]$ git grep MIN_NR_CONSOLES
> >include/uapi/linux/vt.h:#define MIN_NR_CONSOLES 1       /* must be at
> >least 1 */
> >[linux]$
> What I overlooked?

You missed "iirc" ;) So you're right.
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Dmitry Safonov April 27, 2016, 5:48 p.m.
On 04/27/2016 08:46 PM, Cyrill Gorcunov wrote:
> You missed "iirc" ;) So you're right.
> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>

Thanks, Cyrill :)