1
author: John Hughes <john@calva.com>
3
when libdirectfb detects zero length reads,
4
it attempts to reopen the console
5
(possibly from a newly mounted root tree)
8
--- a/systems/fbdev/vt.h
9
+++ b/systems/fbdev/vt.h
15
+typedef struct VirtualTerminal {
16
int fd0; /* file descriptor of /dev/tty0 */
17
int fd; /* file descriptor of /dev/ttyN
18
where N is the number of the allocated VT,
24
+ DFBResult (*method_open) (struct VirtualTerminal *);
28
--- a/systems/fbdev/vt.c
29
+++ b/systems/fbdev/vt.c
31
static void vt_set_fb( int vt, int fb );
32
static void *vt_thread( DirectThread *thread, void *arg );
34
+static DFBResult vt_open (VirtualTerminal *vt);
43
+ dfb_vt->method_open = &vt_open;
45
dfb_fbdev->vt = dfb_vt;
54
- const char cursoroff_str[] = "\033[?1;0;0c";
55
- const char blankoff_str[] = "\033[9;0]";
56
+vt_open (VirtualTerminal *vt) {
60
D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ );
62
- /* FIXME: Opening the device should be moved out of this function. */
64
- snprintf(buf, 32, "/dev/tty%d", dfb_vt->num);
65
- dfb_vt->fd = open( buf, O_RDWR | O_NOCTTY );
66
- if (dfb_vt->fd < 0) {
67
+ snprintf(buf, 32, "/dev/tty%d", vt->num);
68
+ vt->fd = open( buf, O_RDWR | O_NOCTTY );
70
if (errno == ENOENT) {
71
- snprintf(buf, 32, "/dev/vc/%d", dfb_vt->num);
72
- dfb_vt->fd = open( buf, O_RDWR | O_NOCTTY );
73
- if (dfb_vt->fd < 0) {
74
+ snprintf(buf, 32, "/dev/vc/%d", vt->num);
75
+ vt->fd = open( buf, O_RDWR | O_NOCTTY );
77
if (errno == ENOENT) {
78
D_PERROR( "DirectFB/core/vt: Couldn't open "
79
"neither `/dev/tty%d' nor `/dev/vc/%d'!\n",
80
- dfb_vt->num, dfb_vt->num );
84
D_PERROR( "DirectFB/core/vt: "
87
/* attach to the new TTY before doing anything like KDSETMODE with it,
88
otherwise we'd get access denied error: */
89
- ioctl( dfb_vt->fd, TIOCSCTTY, 0 );
90
+ if (ioctl( vt->fd, TIOCSCTTY, 0 ) == -1) {
91
+ return errno2result (errno);
101
+ const char cursoroff_str[] = "\033[?1;0;0c";
102
+ const char blankoff_str[] = "\033[9;0]";
105
+ D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ );
107
+ if ((res = vt_open (dfb_vt)) != DFB_OK) return res;
109
write( dfb_vt->fd, cursoroff_str, sizeof(cursoroff_str) );
110
if (dfb_config->kd_graphics) {
111
--- a/inputdrivers/keyboard/keyboard.c
112
+++ b/inputdrivers/keyboard/keyboard.c
114
ioctl( data->vt->fd, KDSKBLED, locks );
118
+keyboard_set_input (KeyboardData *data)
122
+ ts.c_cc[VTIME] = 0;
124
+ ts.c_lflag &= ~(ICANON|ECHO|ISIG);
126
+ tcsetattr( data->vt->fd, TCSAFLUSH, &ts );
130
keyboardEventThread( DirectThread *thread, void *driver_data )
134
direct_thread_testcancel( thread );
136
+ if (readlen == 0) {
137
+ /* Maybe our controlling terminal has been stolen by init */
138
+ close (data->vt->fd);
139
+ if (data->vt->method_open (data->vt) != DFB_OK) break;
140
+ keyboard_set_input (data);
143
for (i = 0; i < readlen; i++) {
147
InputDeviceInfo *info,
152
FBDev *dfb_fbdev = dfb_system_data();
156
tcgetattr( data->vt->fd, &data->old_ts );
159
- ts.c_cc[VTIME] = 0;
161
- ts.c_lflag &= ~(ICANON|ECHO|ISIG);
163
- tcsetattr( data->vt->fd, TCSAFLUSH, &ts );
164
+ keyboard_set_input (data);
166
tcsetpgrp( data->vt->fd, getpgrp() );