setconsole: open console for writing rather than reading

The console passed to TIOCCONS has to be writable, otherwise future
console writes will fail.

This presumably used to work, but in current kernels (see
drivers/tty/tty_io.c:redirected_tty_write) console writes are sent to
vfs_write(device), which checks if the device is writable. A quick look
in the linux git history doesn't show any recent changes to either tty_io
or vfs_write.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Peter Korsgaard 2011-05-26 17:51:37 +02:00 committed by Denys Vlasenko
parent abb0952e63
commit 8dc6195c97

View File

@ -41,6 +41,6 @@ int setconsole_main(int argc UNUSED_PARAM, char **argv)
device = DEV_CONSOLE;
}
xioctl(xopen(device, O_RDONLY), TIOCCONS, NULL);
xioctl(xopen(device, O_WRONLY), TIOCCONS, NULL);
return EXIT_SUCCESS;
}