# Fixes raw() and uses it in check_one_sigio; also fixes a silly panic # (EINTR returned by call). # # Signed-off-by: Paolo 'Blaisorblade' Giarrusso Index: um/arch/um/include/user_util.h =================================================================== --- um.orig/arch/um/include/user_util.h 2004-08-10 11:45:12.000000000 -0400 +++ um/arch/um/include/user_util.h 2004-08-10 11:45:13.000000000 -0400 @@ -64,7 +64,6 @@ extern void input_cb(void (*proc)(void *), void *arg, int arg_len); extern int get_pty(void); extern void *um_kmalloc(int size); -extern int raw(int fd, int complain); extern int switcheroo(int fd, int prot, void *from, void *to, int size); extern void setup_machinename(char *machine_out); extern void setup_hostinfo(void); @@ -91,6 +90,9 @@ extern void arch_init_thread(void); extern int setjmp_wrapper(void (*proc)(void *, void *), ...); +extern int __raw(int fd, int complain, int now); +#define raw(fd, complain) __raw((fd), (complain), 1) + #endif /* Index: um/arch/um/kernel/sigio_user.c =================================================================== --- um.orig/arch/um/kernel/sigio_user.c 2004-08-10 11:32:43.000000000 -0400 +++ um/arch/um/kernel/sigio_user.c 2004-08-10 11:45:13.000000000 -0400 @@ -16,6 +16,7 @@ #include "init.h" #include "user.h" #include "kern_util.h" +#include "user_util.h" #include "sigio.h" #include "helper.h" #include "os.h" @@ -50,7 +51,6 @@ void __init check_one_sigio(void (*proc)(int, int)) { struct sigaction old, new; - struct termios tt; struct openpty_arg pty = { .master = -1, .slave = -1 }; int master, slave, err; @@ -68,15 +68,10 @@ return; } - do { - err = tcgetattr(master, &tt); - cfmakeraw(&tt); - if(!err) - err = tcsetattr(master, TCSADRAIN, &tt); - } while((err < 0) && (errno == EINTR)); - - if(err < 0) - panic("check_sigio : tcgetattr failed, errno = %d\n", errno); + /* Not now, but complain so we now where we failed. */ + err = __raw(master, 1, 0); + if (err < 0) + panic("check_sigio : __raw failed, errno = %d\n", -err); err = os_sigio_async(master, slave); if(err < 0) Index: um/arch/um/kernel/user_util.c =================================================================== --- um.orig/arch/um/kernel/user_util.c 2004-08-10 11:45:12.000000000 -0400 +++ um/arch/um/kernel/user_util.c 2004-08-10 11:45:13.000000000 -0400 @@ -118,18 +118,29 @@ } } -int raw(int fd, int complain) +int __raw(int fd, int complain, int now) { struct termios tt; - int err; + int err, when; - CATCH_EINTR(tcgetattr(fd, &tt)); - cfmakeraw(&tt); - CATCH_EINTR(err = tcsetattr(fd, TCSANOW, &tt)); - if((err < 0) && complain){ - printk("tcsetattr failed, errno = %d\n", errno); + CATCH_EINTR(err = tcgetattr(fd, &tt)); + if (err < 0) { + if (complain) + printk("tcgetattr failed, errno = %d\n", errno); return(-errno); } + + cfmakeraw(&tt); + + when = (now ? TCSANOW : TCSADRAIN); + CATCH_EINTR(err = tcsetattr(fd, when, &tt)); + if (err < 0) { + if (complain) + printk("tcsetattr failed, errno = %d\n", errno); + } + + /* XXX tcsetattr could have applied only some changes + * (and cfmakeraw() is a set of changes) */ return(0); }