setconsole: open console for writing rather than reading
authorPeter Korsgaard <jacmet@sunsite.dk>
Thu, 26 May 2011 15:51:37 +0000 (17:51 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 28 May 2011 23:51:33 +0000 (01:51 +0200)
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>
console-tools/setconsole.c

index 59c83361cc6d43394585afe1344166b1fb106d24..771974ae3d1011bcad40cb4cc9618ba7efc804d0 100644 (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;
 }