Changeset 44506


Ignore:
Timestamp:
2015-02-22T09:29:26+01:00 (3 years ago)
Author:
blogic
Message:

comgt: Use TCGETS and TCSETS ioctls for struct termios

When passing struct termios to ioctl TCGETS and TCSETS should be
used instead of TCGETA and TCSETA, which are meant for the older
struct termio. Should fix https://dev.archive.openwrt.org/ticket/19012.html

Signed-off-by: Matti Laakso <malaakso@…>

Location:
trunk/package/network/utils/comgt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/network/utils/comgt/Makefile

    r44182 r44506  
    1010PKG_NAME:=comgt 
    1111PKG_VERSION:=0.32 
    12 PKG_RELEASE:=24 
     12PKG_RELEASE:=25 
    1313 
    1414PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz 
  • trunk/package/network/utils/comgt/patches/002-termios.patch

    r43000 r44506  
    1919 char msg[STRINGL]; /* Massage messages here */ 
    2020 int preturn,returns[MAXGOSUBS]; 
    21 @@ -926,7 +926,7 @@ void setcom(void) { 
     21@@ -172,7 +172,7 @@ void dotestkey(void) { 
     22  
     23 /* Exit after resetting terminal settings */ 
     24 void ext(long xtc) { 
     25-  ioctl(1, TCSETA, &cons); 
     26+  ioctl(1, TCSETS, &cons); 
     27   exit(xtc); 
     28 } 
     29  
     30@@ -920,24 +920,24 @@ BOOL getonoroff(void) { 
     31 void setcom(void) { 
     32   stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB); 
     33   stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits ); 
     34-  if (ioctl(comfd, TCSETA, &stbuf) < 0) { 
     35+  if (ioctl(comfd, TCSETS, &stbuf) < 0) { 
     36     serror("Can't ioctl set device",1); 
     37   } 
    2238 } 
    2339  
     
    2844   gettoken(); 
    2945   if(strcmp(token,"echo")==0) { 
     46     a=0; 
     47     if(getonoroff()) a=ECHO|ECHOE; 
     48-    if(ioctl(0, TCGETA, &console)<0) { 
     49+    if(ioctl(0, TCGETS, &console)<0) { 
     50       serror("Can't ioctl FD zero!\n",2); 
     51     } 
     52     console.c_lflag &= ~(ECHO | ECHOE); 
     53     console.c_lflag |= a; 
     54-    ioctl(0, TCSETA, &console); 
     55+    ioctl(0, TCSETS, &console); 
     56   } 
     57   else if(strcmp(token,"senddelay")==0) { 
     58     senddelay=10000L*getdvalue(); 
     59@@ -1224,7 +1224,7 @@ void doclose(void) { 
     60   if(strcmp(token,"hardcom")==0) { 
     61     if(comfd== -1) serror("Com device not open",1); 
     62     vmsg("Closing device"); 
     63-    if (ioctl(comfd, TCSETA, &svbuf) < 0) { 
     64+    if (ioctl(comfd, TCSETS, &svbuf) < 0) { 
     65       sprintf(msg,"Can't ioctl set device %s.\n",device); 
     66       serror(msg,1); 
     67     } 
     68@@ -1266,12 +1266,12 @@ void opengt(void) { 
     69       ext(1); 
     70     } 
     71   } 
     72-  if (ioctl (comfd, TCGETA, &svbuf) < 0) { 
     73+  if (ioctl (comfd, TCGETS, &svbuf) < 0) { 
     74     sprintf(msg,"Can't control %s, please try again.\n",device); 
     75     serror(msg,1); 
     76   } 
     77   setenv("COMGTDEVICE",device,1); 
     78-  ioctl(comfd, TCGETA, &stbuf); 
     79+  ioctl(comfd, TCGETS, &stbuf); 
     80   speed=stbuf.c_cflag & CBAUD; 
     81   if (high_speed == 0)  strcpy(cspeed,"115200"); 
     82   else strcpy(cspeed,"57600"); 
     83@@ -1303,11 +1303,11 @@ void opendevice(void) { 
     84   } 
     85   else comfd=0; 
     86  
     87-  if (ioctl (comfd, TCGETA, &svbuf) < 0) { 
     88+  if (ioctl (comfd, TCGETS, &svbuf) < 0) { 
     89     sprintf(msg,"Can't ioctl get device %s.\n",device); 
     90     serror(msg,1); 
     91   } 
     92-  ioctl(comfd, TCGETA, &stbuf); 
     93+  ioctl(comfd, TCGETS, &stbuf); 
     94   speed=stbuf.c_cflag & CBAUD; 
     95   switch(speed) { 
     96     case B0: strcpy(cspeed,"0");break; 
     97@@ -1553,7 +1553,7 @@ int main(int argc,char **argv) { 
     98   skip_default=0; 
     99   filep=NULL; 
     100   scriptspace=4096; 
     101-  ioctl(1, TCGETA, &cons); 
     102+  ioctl(1, TCGETS, &cons); 
     103   if((script=( char *)malloc(scriptspace))==NULL) { 
     104     serror("Could not malloc()",3); 
     105   } 
  • trunk/package/network/utils/comgt/patches/004-check_tty.patch

    r44054 r44506  
    1313   stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB); 
    1414   stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits ); 
    15 -  if (ioctl(comfd, TCSETA, &stbuf) < 0) { 
    16 +  if (tty && ioctl(comfd, TCSETA, &stbuf) < 0) { 
     15-  if (ioctl(comfd, TCSETS, &stbuf) < 0) { 
     16+  if (tty && ioctl(comfd, TCSETS, &stbuf) < 0) { 
    1717     serror("Can't ioctl set device",1); 
    1818   } 
     
    2222     if(comfd== -1) serror("Com device not open",1); 
    2323     vmsg("Closing device"); 
    24 -    if (ioctl(comfd, TCSETA, &svbuf) < 0) { 
    25 +    if (tty && ioctl(comfd, TCSETA, &svbuf) < 0) { 
     24-    if (ioctl(comfd, TCSETS, &svbuf) < 0) { 
     25+    if (tty && ioctl(comfd, TCSETS, &svbuf) < 0) { 
    2626       sprintf(msg,"Can't ioctl set device %s.\n",device); 
    2727       serror(msg,1); 
     
    3131     } 
    3232   } 
    33 -  if (ioctl (comfd, TCGETA, &svbuf) < 0) { 
     33-  if (ioctl (comfd, TCGETS, &svbuf) < 0) { 
    3434+  if (isatty (comfd)) 
    3535+    tty=1; 
    3636+  else 
    3737+    tty=0; 
    38 +  if (tty && ioctl (comfd, TCGETA, &svbuf) < 0) { 
     38+  if (tty && ioctl (comfd, TCGETS, &svbuf) < 0) { 
    3939     sprintf(msg,"Can't control %s, please try again.\n",device); 
    4040     serror(msg,1); 
    4141   } 
    4242   setenv("COMGTDEVICE",device,1); 
    43 -  ioctl(comfd, TCGETA, &stbuf); 
     43-  ioctl(comfd, TCGETS, &stbuf); 
    4444+  if (tty) 
    45 +    ioctl(comfd, TCGETA, &stbuf); 
     45+    ioctl(comfd, TCGETS, &stbuf); 
    4646   speed=stbuf.c_cflag & CBAUD; 
    4747   if (high_speed == 0)  strcpy(cspeed,"115200"); 
     
    5252   else comfd=0; 
    5353- 
    54 -  if (ioctl (comfd, TCGETA, &svbuf) < 0) { 
     54-  if (ioctl (comfd, TCGETS, &svbuf) < 0) { 
    5555+  if (isatty (comfd)) 
    5656+    tty=1; 
    5757+  else 
    5858+    tty=0; 
    59 +  if (tty && ioctl (comfd, TCGETA, &svbuf) < 0) { 
     59+  if (tty && ioctl (comfd, TCGETS, &svbuf) < 0) { 
    6060     sprintf(msg,"Can't ioctl get device %s.\n",device); 
    6161     serror(msg,1); 
    6262   } 
    63 -  ioctl(comfd, TCGETA, &stbuf); 
     63-  ioctl(comfd, TCGETS, &stbuf); 
    6464+  if (tty) 
    65 +    ioctl(comfd, TCGETA, &stbuf); 
     65+    ioctl(comfd, TCGETS, &stbuf); 
    6666   speed=stbuf.c_cflag & CBAUD; 
    6767   switch(speed) { 
Note: See TracChangeset for help on using the changeset viewer.