Re: [RFC] procd: Use /dev/console for serial console if exists
Apr 25, 2021 8:34:06 AM Gaurav Pathak : inittab.c: Use "/dev/console" character device (5,1) if it is present, before trying "/sys/class/tty/console/active" in case if console kernel command line is not provided during boot and to allow container environment to use it as login PTY console. Signed-off-by: Gaurav Pathak --- LGTM inittab.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/inittab.c b/inittab.c index 2c2270c..716bcee 100644 --- a/inittab.c +++ b/inittab.c @@ -190,7 +190,13 @@ static void askconsole(struct init_action *a) */ tty = get_cmdline_val("console", line, sizeof(line)); if (tty == NULL) { - tty = get_active_console(line, sizeof(line)); + if (dev_exist("/dev/console")) { + tty = "/dev/console"; + } + else { + tty = get_active_console(line, sizeof(line)); + } + } if (tty != NULL) { split = strchr(tty, ','); -- 2.25.1 -- ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC] procd: Use /dev/console for serial console if exists
inittab.c: Use "/dev/console" character device (5,1) if it is present, before trying "/sys/class/tty/console/active" in case if console kernel command line is not provided during boot and to allow container environment to use it as login PTY console. Signed-off-by: Gaurav Pathak --- inittab.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/inittab.c b/inittab.c index 2c2270c..716bcee 100644 --- a/inittab.c +++ b/inittab.c @@ -190,7 +190,13 @@ static void askconsole(struct init_action *a) */ tty = get_cmdline_val("console", line, sizeof(line)); if (tty == NULL) { - tty = get_active_console(line, sizeof(line)); +if (dev_exist("/dev/console")) { +tty = "/dev/console"; +} +else { +tty = get_active_console(line, sizeof(line)); +} + } if (tty != NULL) { split = strchr(tty, ','); -- 2.25.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [RFC] procd: Use /dev/console for serial console if exists
On Sat, Apr 24, 2021 at 09:05:58PM +0530, Gaurav Pathak wrote: > As Daniel mentioned, this change is for providing the capability to container > environment to be able to login using PTY. > Also, there can be a case when console option is not passed to kernel command > line, > in that case we should try and check for the presence of /dev/console > character > device (5,1) and use it if it is present before trying > "/sys/class/tty/console/active". Please send the patch again with a commit message explaining its purpose. > > On Sat, Apr 24, 2021 at 02:54:26PM +0100, Daniel Golle wrote: > > On Sat, Apr 24, 2021 at 03:39:51AM -1000, Paul Spooren wrote: > > > > > > On 4/24/21 1:01 AM, Gaurav Pathak wrote: > > > > Modified inittab.c to use "/dev/console" as preferred console if exists. > > > > > > > > Signed-off-by: Gaurav Pathak > > > > --- > > > > > > Could you please elaborate why this is useful? > > > > Container environments typically provide /dev/console PTY, hence it's > > nice to be able to login on that console. > > > > > > > > > Edited inittab.c to check and use "/dev/console" as the first > > > > console device before parsing "/sys/class/tty/console/active". > > > > inittab.c | 8 +++- > > > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/inittab.c b/inittab.c > > > > index 2c2270c..716bcee 100644 > > > > --- a/inittab.c > > > > +++ b/inittab.c > > > > @@ -190,7 +190,13 @@ static void askconsole(struct init_action *a) > > > > */ > > > > tty = get_cmdline_val("console", line, sizeof(line)); > > > > if (tty == NULL) { > > > > - tty = get_active_console(line, sizeof(line)); > > > > +if (dev_exist("/dev/console")) { > > > > +tty = "/dev/console"; > > > > +} > > > > +else { > > > > +tty = get_active_console(line, sizeof(line)); > > > > +} > > > > + > > > > } > > > > if (tty != NULL) { > > > > split = strchr(tty, ','); > > > > > > ___ > > > openwrt-devel mailing list > > > openwrt-devel@lists.openwrt.org > > > https://lists.openwrt.org/mailman/listinfo/openwrt-devel ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [RFC] procd: Use /dev/console for serial console if exists
As Daniel mentioned, this change is for providing the capability to container environment to be able to login using PTY. Also, there can be a case when console option is not passed to kernel command line, in that case we should try and check for the presence of /dev/console character device (5,1) and use it if it is present before trying "/sys/class/tty/console/active". On Sat, Apr 24, 2021 at 02:54:26PM +0100, Daniel Golle wrote: > On Sat, Apr 24, 2021 at 03:39:51AM -1000, Paul Spooren wrote: > > > > On 4/24/21 1:01 AM, Gaurav Pathak wrote: > > > Modified inittab.c to use "/dev/console" as preferred console if exists. > > > > > > Signed-off-by: Gaurav Pathak > > > --- > > > > Could you please elaborate why this is useful? > > Container environments typically provide /dev/console PTY, hence it's > nice to be able to login on that console. > > > > > > Edited inittab.c to check and use "/dev/console" as the first > > > console device before parsing "/sys/class/tty/console/active". > > > inittab.c | 8 +++- > > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > > > diff --git a/inittab.c b/inittab.c > > > index 2c2270c..716bcee 100644 > > > --- a/inittab.c > > > +++ b/inittab.c > > > @@ -190,7 +190,13 @@ static void askconsole(struct init_action *a) > > >*/ > > > tty = get_cmdline_val("console", line, sizeof(line)); > > > if (tty == NULL) { > > > - tty = get_active_console(line, sizeof(line)); > > > +if (dev_exist("/dev/console")) { > > > +tty = "/dev/console"; > > > +} > > > +else { > > > +tty = get_active_console(line, sizeof(line)); > > > +} > > > + > > > } > > > if (tty != NULL) { > > > split = strchr(tty, ','); > > > > ___ > > openwrt-devel mailing list > > openwrt-devel@lists.openwrt.org > > https://lists.openwrt.org/mailman/listinfo/openwrt-devel ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [RFC] procd: Use /dev/console for serial console if exists
On Sat, Apr 24, 2021 at 03:39:51AM -1000, Paul Spooren wrote: > > On 4/24/21 1:01 AM, Gaurav Pathak wrote: > > Modified inittab.c to use "/dev/console" as preferred console if exists. > > > > Signed-off-by: Gaurav Pathak > > --- > > Could you please elaborate why this is useful? Container environments typically provide /dev/console PTY, hence it's nice to be able to login on that console. > > > Edited inittab.c to check and use "/dev/console" as the first > > console device before parsing "/sys/class/tty/console/active". > > inittab.c | 8 +++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/inittab.c b/inittab.c > > index 2c2270c..716bcee 100644 > > --- a/inittab.c > > +++ b/inittab.c > > @@ -190,7 +190,13 @@ static void askconsole(struct init_action *a) > > */ > > tty = get_cmdline_val("console", line, sizeof(line)); > > if (tty == NULL) { > > - tty = get_active_console(line, sizeof(line)); > > +if (dev_exist("/dev/console")) { > > +tty = "/dev/console"; > > +} > > +else { > > +tty = get_active_console(line, sizeof(line)); > > +} > > + > > } > > if (tty != NULL) { > > split = strchr(tty, ','); > > ___ > openwrt-devel mailing list > openwrt-devel@lists.openwrt.org > https://lists.openwrt.org/mailman/listinfo/openwrt-devel ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [RFC] procd: Use /dev/console for serial console if exists
On 4/24/21 1:01 AM, Gaurav Pathak wrote: Modified inittab.c to use "/dev/console" as preferred console if exists. Signed-off-by: Gaurav Pathak --- Could you please elaborate why this is useful? Edited inittab.c to check and use "/dev/console" as the first console device before parsing "/sys/class/tty/console/active". inittab.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/inittab.c b/inittab.c index 2c2270c..716bcee 100644 --- a/inittab.c +++ b/inittab.c @@ -190,7 +190,13 @@ static void askconsole(struct init_action *a) */ tty = get_cmdline_val("console", line, sizeof(line)); if (tty == NULL) { - tty = get_active_console(line, sizeof(line)); +if (dev_exist("/dev/console")) { +tty = "/dev/console"; +} +else { +tty = get_active_console(line, sizeof(line)); +} + } if (tty != NULL) { split = strchr(tty, ','); ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[RFC] procd: Use /dev/console for serial console if exists
Modified inittab.c to use "/dev/console" as preferred console if exists. Signed-off-by: Gaurav Pathak --- Edited inittab.c to check and use "/dev/console" as the first console device before parsing "/sys/class/tty/console/active". inittab.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/inittab.c b/inittab.c index 2c2270c..716bcee 100644 --- a/inittab.c +++ b/inittab.c @@ -190,7 +190,13 @@ static void askconsole(struct init_action *a) */ tty = get_cmdline_val("console", line, sizeof(line)); if (tty == NULL) { - tty = get_active_console(line, sizeof(line)); +if (dev_exist("/dev/console")) { +tty = "/dev/console"; +} +else { +tty = get_active_console(line, sizeof(line)); +} + } if (tty != NULL) { split = strchr(tty, ','); -- 2.25.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel