>From http://www.openbsd.org/cgi-bin/cvsweb/src/etc/gettytab:

  Revision 1.3: download - view: text, markup, annotated - select for diffs
  Mon Jun 8 18:03:34 1998 UTC (11 years, 11 months ago) by deraadt
  Branches: MAIN
  CVS tags: OPENBSD_2_7_BASE, OPENBSD_2_7, OPENBSD_2_6_BASE,
    OPENBSD_2_6, OPENBSD_2_5_BASE, OPENBSD_2_5, OPENBSD_2_4_BASE,
    OPENBSD_2_4
  Diff to: previous 1.2: preferred, coloured
  Changes since revision 1.2: +3 -3 lines
  default to 8 bit; let me know if this causes problems

Well, maybe a little bit late, but it causes problems.

Some time ago, I've recycled a french minitel to a serial console.
This console works at 4800 baud, even parity. So I've added that in
/etc/gettytab:

  mini|minitel:\
        :ep:sp#4800:

But it does not work: the parity was still set to 8 bit.  After
searching for a while, I have discovered that getty supposes that the
default is not 8 bit, so that it is impossible to have other parity.

I have found 3 ways to solve this problem:

1. Changing the code to suppose that 8 bits is the default.
      pros: simple patch
      cons: default parity is hard coded

2. Changing the code to not suppose anything about the defaults
      pros: clean fix
      cons: complicated modifications to getty

3. Changing the gettytab file format to have a unique key for
    parity of type integer.  if this integer is 0, then no parity, if
    it is 1, then odd parity, if it is 2, then even parity, else, do
    not care (any parity).
      pros: easy to patch, more consistent model
      cons: change configuration file, different from termcap (termcap
      has only EP and OP boolean keys to my knowledge).

I attached the patch to this mail for the first solution that
I've been using for 4 years.

What do you think?

Index: main.c
===================================================================
RCS file: /cvs/src/libexec/getty/main.c,v
retrieving revision 1.30
diff -u -r1.30 main.c
--- main.c      27 Oct 2009 23:59:31 -0000      1.30
+++ main.c      28 May 2010 16:16:02 -0000
@@ -497,7 +497,7 @@
        char c;
 
        c = cc;
-       if (!NP) {
+       if (AP || EP || OP) {
                c |= partab[c&0177] & 0200;
                if (OP)
                        c ^= 0200;
Index: subr.c
===================================================================
RCS file: /cvs/src/libexec/getty/subr.c,v
retrieving revision 1.19
diff -u -r1.19 subr.c
--- subr.c      27 Oct 2009 23:59:31 -0000      1.19
+++ subr.c      28 May 2010 16:16:03 -0000
@@ -231,11 +231,7 @@
        cflag = omode.c_cflag;
        lflag = omode.c_lflag;
 
-       if (NP) {
-               CLR(cflag, CSIZE|PARENB);
-               SET(cflag, CS8);
-               CLR(iflag, ISTRIP|INPCK|IGNPAR);
-       } else if (AP || EP || OP) {
+       if (AP || EP || OP) {
                CLR(cflag, CSIZE);
                SET(cflag, CS7|PARENB);
                SET(iflag, ISTRIP);
@@ -253,6 +249,10 @@
                        CLR(iflag, INPCK|IGNPAR);
                        CLR(cflag, PARODD);
                }
+       } else if (NP) {
+               CLR(cflag, CSIZE|PARENB);
+               SET(cflag, CS8);
+               CLR(iflag, ISTRIP|INPCK|IGNPAR);
        } /* else, leave as is */
 
        if (UC) {

Reply via email to