Skip to contentSkip to conversation

sgetty: Smart serial console getty

RFC PATCH In review Daniel Kiper 2 participants 7 messages Dec 4, 2013 – Dec 5, 2013 Util-Linux package

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 sgetty: Smart serial console getty

Very often when I was switching from Xen to Linux I was forced to change /etc/inittab to make serial console working. It was boring so I thought how to solve that problem. I was not able to find sensible solution. So I decided to write something. Here it is.

I posted this patch earlier to Xen-devel list but Ian Campbell stated that it is more generic and maybe I should try to include this in util-linux. I am posting sgetty here with minor changes. Maybe this solution should be merged with agetty but I am not sure right now. If you think that it is good idea then I will do that.

Anyway, I am looking for your comments.

I am not subscribed to util-linux list so please
include my email address in your reply.

---
 term-utils/Makemodule.am |    2 +
 term-utils/sgetty.c      |  243 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 245 insertions(+)
 create mode 100644 term-utils/sgetty.c
term-utils/Makemodule.am +2 -0
index e53471f..e9055fc 100644
@@ -21,6 +21,8 @@ sbin_PROGRAMS += agetty
 dist_man_MANS += term-utils/agetty.8
 agetty_SOURCES = term-utils/agetty.c
 agetty_LDADD = $(LDADD) libcommon.la
+sbin_PROGRAMS += sgetty
+sgetty_SOURCES = term-utils/sgetty.c
 endif # BUILD_AGETTY
 
 
term-utils/sgetty.c new file +243 -0

243 lines not on this page · raw message

Signature · 1 line
1.7.10.4
maintainer
#1 lore raw

Hi Daniel,

Quoted 5 lines · Daniel Kiper

Very often when I was switching from Xen to Linux I was forced to change /etc/inittab to make serial console working. It was boring so I thought how to solve that problem. I was not able to find sensible solution. So I decided to write something. Here it is.

Would be better to extend agetty(1) to read console name from kernel command line rather than introduce a special wrapper?

Something like:

   agetty --detect-console [baud_rate...] [term]

Note that in login-utils/sulogin-consoles.c we have code to detect consoles for sulogin, for example detect_consoles_from_cmdline().

We did a lot of work to consolidate and clean up agetty and kill things like mingetty in last years. So I'd like to have only util, especially if all the magic is just console name only.

Quoted 2 lines

I posted this patch earlier to Xen-devel list but Ian Campbell stated that it is more generic and maybe I should try to include

yeah, that's probably a generic issue.

BTW, I guess that systemd does not use hardcoded console names (like /etc/inittab), ... just for the record :-) (I have no problem to support classic inittab.)

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
maintainer
#2 lore raw
In reply to Daniel Kiper

Hi Daniel,

Quoted 5 lines · Daniel Kiper

Very often when I was switching from Xen to Linux I was forced to change /etc/inittab to make serial console working. It was boring so I thought how to solve that problem. I was not able to find sensible solution. So I decided to write something. Here it is.

Would be better to extend agetty(1) to read console name from kernel command line rather than introduce a special wrapper?

Something like:

   agetty --detect-console [baud_rate...] [term]

Note that in login-utils/sulogin-consoles.c we have code to detect consoles for sulogin, for example detect_consoles_from_cmdline().

We did a lot of work to consolidate and clean up agetty and kill things like mingetty in last years. So I'd like to have only util, especially if all the magic is just console name only.

Quoted 2 lines

I posted this patch earlier to Xen-devel list but Ian Campbell stated that it is more generic and maybe I should try to include

yeah, that's probably a generic issue.

BTW, I guess that systemd does not use hardcoded console names (like /etc/inittab), ... just for the record :-) (I have no problem to support classic inittab.)

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#3 lore raw

Hi Karel,

Quoted 10 lines · Karel Zak

Hi Daniel,

Quoted 5 lines · Daniel Kiper

Very often when I was switching from Xen to Linux I was forced to change /etc/inittab to make serial console working. It was boring so I thought how to solve that problem. I was not able to find sensible solution. So I decided to write something. Here it is.

Quoted 6 lines

Would be better to extend agetty(1) to read console name from kernel command line rather than introduce a special wrapper?

Something like:

   agetty --detect-console [baud_rate...] [term]

Make sens.

Quoted 2 lines

Note that in login-utils/sulogin-consoles.c we have code to detect consoles for sulogin, for example detect_consoles_from_cmdline().

Great... I will try to use it. Should I build this file as a library and then link into agetty or just link ordinary object file (login-utils/sulogin-consoles.o) with it?

Quoted 3 lines

We did a lot of work to consolidate and clean up agetty and kill things like mingetty in last years. So I'd like to have only util, especially if all the magic is just console name only.

Agreed.

Quoted 8 lines
Quoted 2 lines

I posted this patch earlier to Xen-devel list but Ian Campbell stated that it is more generic and maybe I should try to include

yeah, that's probably a generic issue.

BTW, I guess that systemd does not use hardcoded console names (like /etc/inittab), ... just for the record :-) (I have no problem to support classic inittab.)

That is great. However, I do not know systemd (I only heard about that) and maybe my question is stupid but I am curious how it starts getty on serial console, i.e. how it gets a name of serial console and passes it to getty.

Daniel

#4 lore raw
In reply to Karel Zak

Hi Karel,

Quoted 10 lines · Karel Zak

Hi Daniel,

Quoted 5 lines · Daniel Kiper

Very often when I was switching from Xen to Linux I was forced to change /etc/inittab to make serial console working. It was boring so I thought how to solve that problem. I was not able to find sensible solution. So I decided to write something. Here it is.

Quoted 6 lines

Would be better to extend agetty(1) to read console name from kernel command line rather than introduce a special wrapper?

Something like:

   agetty --detect-console [baud_rate...] [term]

Make sens.

Quoted 2 lines

Note that in login-utils/sulogin-consoles.c we have code to detect consoles for sulogin, for example detect_consoles_from_cmdline().

Great... I will try to use it. Should I build this file as a library and then link into agetty or just link ordinary object file (login-utils/sulogin-consoles.o) with it?

Quoted 3 lines

We did a lot of work to consolidate and clean up agetty and kill things like mingetty in last years. So I'd like to have only util, especially if all the magic is just console name only.

Agreed.

Quoted 8 lines
Quoted 2 lines

I posted this patch earlier to Xen-devel list but Ian Campbell stated that it is more generic and maybe I should try to include

yeah, that's probably a generic issue.

BTW, I guess that systemd does not use hardcoded console names (like /etc/inittab), ... just for the record :-) (I have no problem to support classic inittab.)

That is great. However, I do not know systemd (I only heard about that) and maybe my question is stupid but I am curious how it starts getty on serial console, i.e. how it gets a name of serial console and passes it to getty.

Daniel

maintainer
#5 lore raw
Quoted 10 lines · Daniel Kiper
Quoted 1 line
   agetty --detect-console [baud_rate...] [term]

Make sens.

Quoted 2 lines

Note that in login-utils/sulogin-consoles.c we have code to detect consoles for sulogin, for example detect_consoles_from_cmdline().

Great... I will try to use it. Should I build this file as a library and then link into agetty or just link ordinary object file (login-utils/sulogin-consoles.o) with it?

You can move the function (or some fragment of the function) to the lib/ttyutils.c, the file is already used for libcommon.so (lib used everywhere in the package).

Quoted 8 lines
Quoted 3 lines

BTW, I guess that systemd does not use hardcoded console names (like /etc/inittab), ... just for the record :-) (I have no problem to support classic inittab.)

That is great. However, I do not know systemd (I only heard about that) and maybe my question is stupid but I am curious how it starts getty on serial console, i.e. how it gets a name of serial console and passes it to getty.

from kernel command line, more details:
http://0pointer.de/blog/projects/serial-console.html

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
maintainer
#6 lore raw
In reply to Daniel Kiper
Quoted 10 lines · Daniel Kiper
Quoted 1 line
   agetty --detect-console [baud_rate...] [term]

Make sens.

Quoted 2 lines

Note that in login-utils/sulogin-consoles.c we have code to detect consoles for sulogin, for example detect_consoles_from_cmdline().

Great... I will try to use it. Should I build this file as a library and then link into agetty or just link ordinary object file (login-utils/sulogin-consoles.o) with it?

You can move the function (or some fragment of the function) to the lib/ttyutils.c, the file is already used for libcommon.so (lib used everywhere in the package).

Quoted 8 lines
Quoted 3 lines

BTW, I guess that systemd does not use hardcoded console names (like /etc/inittab), ... just for the record :-) (I have no problem to support classic inittab.)

That is great. However, I do not know systemd (I only heard about that) and maybe my question is stupid but I am curious how it starts getty on serial console, i.e. how it gets a name of serial console and passes it to getty.

from kernel command line, more details:
http://0pointer.de/blog/projects/serial-console.html

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com