Commit 8e2d10e1 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

uml: tidy recently-moved code

Now that the generic console operations are in a userspace file, we
can do the following:
	directly call into libc instead of through the os_* wrappers
	eliminate os_window_size since it has only one user
Signed-off-by: default avatarJeff Dike <jdike@linux.intel.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 89fe6476
...@@ -23,43 +23,43 @@ ...@@ -23,43 +23,43 @@
void generic_close(int fd, void *unused) void generic_close(int fd, void *unused)
{ {
os_close_file(fd); close(fd);
} }
int generic_read(int fd, char *c_out, void *unused) int generic_read(int fd, char *c_out, void *unused)
{ {
int n; int n;
n = os_read_file(fd, c_out, sizeof(*c_out)); n = read(fd, c_out, sizeof(*c_out));
if (n > 0)
if(n == -EAGAIN) return n;
else if (errno == EAGAIN)
return 0; return 0;
else if(n == 0) else if (n == 0)
return -EIO; return -EIO;
return n; return -errno;
} }
/* XXX Trivial wrapper around os_write_file */ /* XXX Trivial wrapper around write */
int generic_write(int fd, const char *buf, int n, void *unused) int generic_write(int fd, const char *buf, int n, void *unused)
{ {
return os_write_file(fd, buf, n); return write(fd, buf, n);
} }
int generic_window_size(int fd, void *unused, unsigned short *rows_out, int generic_window_size(int fd, void *unused, unsigned short *rows_out,
unsigned short *cols_out) unsigned short *cols_out)
{ {
int rows, cols; struct winsize size;
int ret; int ret;
ret = os_window_size(fd, &rows, &cols); if(ioctl(fd, TIOCGWINSZ, &size) < 0)
if(ret < 0) return -errno;
return ret;
ret = ((*rows_out != rows) || (*cols_out != cols)); ret = ((*rows_out != size.ws_row) || (*cols_out != size.ws_col));
*rows_out = rows; *rows_out = size.ws_row;
*cols_out = cols; *cols_out = size.ws_col;
return ret; return ret;
} }
......
...@@ -134,7 +134,6 @@ extern void os_print_error(int error, const char* str); ...@@ -134,7 +134,6 @@ extern void os_print_error(int error, const char* str);
extern int os_get_exec_close(int fd, int *close_on_exec); extern int os_get_exec_close(int fd, int *close_on_exec);
extern int os_set_exec_close(int fd, int close_on_exec); extern int os_set_exec_close(int fd, int close_on_exec);
extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg); extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
extern int os_window_size(int fd, int *rows, int *cols);
extern int os_new_tty_pgrp(int fd, int pid); extern int os_new_tty_pgrp(int fd, int pid);
extern int os_get_ifname(int fd, char *namebuf); extern int os_get_ifname(int fd, char *namebuf);
extern int os_set_slip(int fd); extern int os_set_slip(int fd);
......
...@@ -101,19 +101,6 @@ int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg) ...@@ -101,19 +101,6 @@ int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg)
return err; return err;
} }
int os_window_size(int fd, int *rows, int *cols)
{
struct winsize size;
if(ioctl(fd, TIOCGWINSZ, &size) < 0)
return -errno;
*rows = size.ws_row;
*cols = size.ws_col;
return 0;
}
int os_new_tty_pgrp(int fd, int pid) int os_new_tty_pgrp(int fd, int pid)
{ {
if(ioctl(fd, TIOCSCTTY, 0) < 0) if(ioctl(fd, TIOCSCTTY, 0) < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment