X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fum%2Fdrivers%2Fxterm.c;h=850221d9b4c953306d87817bfd455551dc4aee67;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=f417b3b668ade33eede3fa2de6a2f5fceec3c86b;hpb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;p=linux-2.6.git diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c index f417b3b66..850221d9b 100644 --- a/arch/um/drivers/xterm.c +++ b/arch/um/drivers/xterm.c @@ -14,7 +14,6 @@ #include #include "kern_util.h" #include "chan_user.h" -#include "helper.h" #include "user_util.h" #include "user.h" #include "os.h" @@ -31,7 +30,8 @@ struct xterm_chan { int direct_rcv; }; -void *xterm_init(char *str, int device, struct chan_opts *opts) +/* Not static because it's called directly by the tt mode gdb code */ +void *xterm_init(char *str, int device, const struct chan_opts *opts) { struct xterm_chan *data; @@ -83,8 +83,11 @@ __uml_setup("xterm=", xterm_setup, " are 'xterm=gnome-terminal,-t,-x'.\n\n" ); -/* XXX This badly needs some cleaning up in the error paths */ -int xterm_open(int input, int output, int primary, void *d, char **dev_out) +/* XXX This badly needs some cleaning up in the error paths + * Not static because it's called directly by the tt mode gdb code + */ +int xterm_open(int input, int output, int primary, void *d, + char **dev_out) { struct xterm_chan *data = d; unsigned long stack; @@ -97,15 +100,24 @@ int xterm_open(int input, int output, int primary, void *d, char **dev_out) if(os_access(argv[4], OS_ACC_X_OK) < 0) argv[4] = "port-helper"; + /* Check that DISPLAY is set, this doesn't guarantee the xterm + * will work but w/o it we can be pretty sure it won't. */ + if (!getenv("DISPLAY")) { + printk("xterm_open: $DISPLAY not set.\n"); + return -ENODEV; + } + fd = mkstemp(file); if(fd < 0){ + err = -errno; printk("xterm_open : mkstemp failed, errno = %d\n", errno); - return(-errno); + return err; } if(unlink(file)){ + err = -errno; printk("xterm_open : unlink failed, errno = %d\n", errno); - return(-errno); + return err; } os_close_file(fd); @@ -124,11 +136,9 @@ int xterm_open(int input, int output, int primary, void *d, char **dev_out) return(pid); } - if(data->stack == 0) free_stack(stack, 0); - - if(data->direct_rcv) + if (data->direct_rcv) { new = os_rcv_fd(fd, &data->helper_pid); - else { + } else { err = os_set_fd_block(fd, 0); if(err < 0){ printk("xterm_open : failed to set descriptor " @@ -163,6 +173,7 @@ int xterm_open(int input, int output, int primary, void *d, char **dev_out) return(new); } +/* Not static because it's called directly by the tt mode gdb code */ void xterm_close(int fd, void *d) { struct xterm_chan *data = d; @@ -176,26 +187,19 @@ void xterm_close(int fd, void *d) os_close_file(fd); } -void xterm_free(void *d) +static void xterm_free(void *d) { free(d); } -int xterm_console_write(int fd, const char *buf, int n, void *d) -{ - struct xterm_chan *data = d; - - return(generic_console_write(fd, buf, n, &data->tt)); -} - -struct chan_ops xterm_ops = { +const struct chan_ops xterm_ops = { .type = "xterm", .init = xterm_init, .open = xterm_open, .close = xterm_close, .read = generic_read, .write = generic_write, - .console_write = xterm_console_write, + .console_write = generic_console_write, .window_size = generic_window_size, .free = xterm_free, .winch = 1,