~ubuntu-branches/ubuntu/maverick/directfb/maverick

« back to all changes in this revision

Viewing changes to debian/patches/92_reopen_console.patch

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-06-19 12:07:48 UTC
  • Revision ID: james.westby@ubuntu.com-20080619120748-i1ezulfkowo0aaul
Tags: 1.0.1-9ubuntu1
* Merge with Debian; remaining changes:
  - Install the upstream changelog in the -dev package.
  - Remove (build-)dependency on libmpeg3-dev.
  - Build-depend on libsysfs-dev on lpia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
author: John Hughes <john@calva.com>
 
2
 
 
3
when libdirectfb detects zero length reads,
 
4
it attempts to reopen the console
 
5
(possibly from a newly mounted root tree)
 
6
See Debian bug #462626
 
7
 
 
8
--- a/systems/fbdev/vt.h
 
9
+++ b/systems/fbdev/vt.h
 
10
@@ -34,7 +34,7 @@
 
11
 
 
12
 #include <directfb.h>
 
13
 
 
14
-typedef struct {
 
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,
 
19
@@ -56,6 +56,8 @@
 
20
      pthread_cond_t   wait;
 
21
 
 
22
      int              vt_sig;
 
23
+
 
24
+     DFBResult      (*method_open) (struct VirtualTerminal *);
 
25
 } VirtualTerminal;
 
26
 
 
27
 /*
 
28
--- a/systems/fbdev/vt.c
 
29
+++ b/systems/fbdev/vt.c
 
30
@@ -96,6 +96,8 @@
 
31
 static void      vt_set_fb( int vt, int fb );
 
32
 static void     *vt_thread( DirectThread *thread, void *arg );
 
33
 
 
34
+static DFBResult vt_open (VirtualTerminal *vt);
 
35
+
 
36
 DFBResult
 
37
 dfb_vt_initialize()
 
38
 {
 
39
@@ -219,6 +221,8 @@
 
40
           return ret;
 
41
      }
 
42
 
 
43
+     dfb_vt->method_open = &vt_open;
 
44
+
 
45
      dfb_fbdev->vt = dfb_vt;
 
46
 
 
47
      return DFB_OK;
 
48
@@ -439,27 +443,23 @@
 
49
 }
 
50
 
 
51
 static DFBResult
 
52
-vt_init_switching()
 
53
-{
 
54
-     const char cursoroff_str[] = "\033[?1;0;0c";
 
55
-     const char blankoff_str[] = "\033[9;0]";
 
56
+vt_open (VirtualTerminal *vt) {
 
57
+
 
58
      char buf[32];
 
59
 
 
60
      D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ );
 
61
 
 
62
-     /* FIXME: Opening the device should be moved out of this function. */
 
63
-
 
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 );
 
69
+     if (vt->fd < 0) {
 
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 );
 
76
+               if (vt->fd < 0) {
 
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 );
 
81
+                                    vt->num, vt->num );
 
82
                     }
 
83
                     else {
 
84
                          D_PERROR( "DirectFB/core/vt: "
 
85
@@ -477,7 +477,24 @@
 
86
 
 
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);
 
92
+     }
 
93
+
 
94
+     return DFB_OK;
 
95
+}
 
96
+
 
97
+    
 
98
+static DFBResult
 
99
+vt_init_switching()
 
100
+{
 
101
+     const char cursoroff_str[] = "\033[?1;0;0c";
 
102
+     const char blankoff_str[] = "\033[9;0]";
 
103
+     DFBResult res;
 
104
+
 
105
+     D_DEBUG_AT( VT, "%s()\n", __FUNCTION__ );
 
106
+
 
107
+     if ((res = vt_open (dfb_vt)) != DFB_OK) return res;
 
108
 
 
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
 
113
@@ -287,6 +287,18 @@
 
114
      ioctl( data->vt->fd, KDSKBLED, locks );
 
115
 }
 
116
 
 
117
+static void
 
118
+keyboard_set_input (KeyboardData *data)
 
119
+{
 
120
+     struct termios  ts;
 
121
+     ts = data->old_ts;
 
122
+     ts.c_cc[VTIME] = 0;
 
123
+     ts.c_cc[VMIN] = 1;
 
124
+     ts.c_lflag &= ~(ICANON|ECHO|ISIG);
 
125
+     ts.c_iflag = 0;
 
126
+     tcsetattr( data->vt->fd, TCSAFLUSH, &ts );
 
127
+}
 
128
+
 
129
 static void*
 
130
 keyboardEventThread( DirectThread *thread, void *driver_data )
 
131
 {
 
132
@@ -300,6 +312,13 @@
 
133
 
 
134
           direct_thread_testcancel( thread );
 
135
 
 
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);
 
141
+         }
 
142
+
 
143
           for (i = 0; i < readlen; i++) {
 
144
                DFBInputEvent evt;
 
145
 
 
146
@@ -351,7 +370,6 @@
 
147
                     InputDeviceInfo  *info,
 
148
                     void            **driver_data )
 
149
 {
 
150
-     struct termios  ts;
 
151
      KeyboardData   *data;
 
152
      FBDev          *dfb_fbdev = dfb_system_data();
 
153
 
 
154
@@ -369,12 +387,7 @@
 
155
 
 
156
      tcgetattr( data->vt->fd, &data->old_ts );
 
157
 
 
158
-     ts = data->old_ts;
 
159
-     ts.c_cc[VTIME] = 0;
 
160
-     ts.c_cc[VMIN] = 1;
 
161
-     ts.c_lflag &= ~(ICANON|ECHO|ISIG);
 
162
-     ts.c_iflag = 0;
 
163
-     tcsetattr( data->vt->fd, TCSAFLUSH, &ts );
 
164
+     keyboard_set_input (data);
 
165
 
 
166
      tcsetpgrp( data->vt->fd, getpgrp() );
 
167