View | Details | Raw Unified | Return to bug 196678 | Differences between
and this patch

Collapse All | Expand All

(-)files/patch-config_devd.c (-199 / +246 lines)
Lines 1-6 Link Here
1
--- config/devd.c.orig	2015-05-19 19:41:49 UTC
1
--- config/devd.c.orig	2015-09-14 10:51:06.986114000 +0200
2
+++ config/devd.c
2
+++ config/devd.c	2015-09-14 10:53:12.523679000 +0200
3
@@ -0,0 +1,531 @@
3
@@ -0,0 +1,578 @@
4
+/*
4
+/*
5
+ * Copyright (c) 2012 Baptiste Daroussin
5
+ * Copyright (c) 2012 Baptiste Daroussin
6
+ * Copyright (c) 2013, 2014 Alex Kozlov
6
+ * Copyright (c) 2013, 2014 Alex Kozlov
Lines 41-46 Link Here
41
+#include <sys/un.h>
41
+#include <sys/un.h>
42
+
42
+
43
+#include <ctype.h>
43
+#include <ctype.h>
44
+#include <dirent.h>
44
+#include <errno.h>
45
+#include <errno.h>
45
+#include <fcntl.h>
46
+#include <fcntl.h>
46
+#include <stdlib.h>
47
+#include <stdlib.h>
Lines 47-52 Link Here
47
+#include <stdio.h>
48
+#include <stdio.h>
48
+#include <stdbool.h>
49
+#include <stdbool.h>
49
+#include <unistd.h>
50
+#include <unistd.h>
51
+#include <paths.h>
50
+
52
+
51
+#include "input.h"
53
+#include "input.h"
52
+#include "inputstr.h"
54
+#include "inputstr.h"
Lines 56-68 Link Here
56
+
58
+
57
+#define DEVD_SOCK_PATH "/var/run/devd.pipe"
59
+#define DEVD_SOCK_PATH "/var/run/devd.pipe"
58
+
60
+
59
+#define DEVD_EVENT_ADD		'+'
61
+#define RECONNECT_DELAY		(5 * 1000)
60
+#define DEVD_EVENT_REMOVE	'-'
61
+
62
+
62
+#define RECONNECT_DELAY		5 * 1000
63
+
64
+static int sock_devd;
63
+static int sock_devd;
65
+static bool is_console_kbd = false;
66
+static bool is_kbdmux = false;
64
+static bool is_kbdmux = false;
67
+OsTimerPtr rtimer;
65
+OsTimerPtr rtimer;
68
+
66
+
Lines 70-140 Link Here
70
+	const char *driver;
68
+	const char *driver;
71
+	int flag;
69
+	int flag;
72
+	const char *xdriver;
70
+	const char *xdriver;
71
+	const char *sysctldesc;
73
+};
72
+};
74
+
73
+
75
+static struct hw_type hw_types[] = {
74
+static const struct hw_type hw_types0[] = {
76
+	{ "ukbd", ATTR_KEYBOARD, "kbd" },
75
+	{ _PATH_DEV "sysmouse", ATTR_POINTER, "mouse", NULL },
77
+	{ "atkbd", ATTR_KEYBOARD, "kbd" },
76
+	{ NULL, 0, NULL, NULL },
78
+	{ "kbdmux", ATTR_KEYBOARD, "kbd" },
79
+	{ "sysmouse", ATTR_POINTER, "mouse" },
80
+	{ "ums", ATTR_POINTER, "mouse" },
81
+	{ "psm", ATTR_POINTER, "mouse" },
82
+	{ "vboxguest", ATTR_POINTER, "vboxmouse" },
83
+	{ "joy", ATTR_JOYSTICK, NULL },
84
+	{ "atp", ATTR_TOUCHPAD, NULL },
85
+	{ "uep", ATTR_TOUCHSCREEN, NULL },
86
+	{ NULL, -1, NULL },
87
+};
77
+};
88
+
78
+
89
+static bool
79
+static const struct hw_type hw_types1[] = {
90
+sysctl_exists(const struct hw_type *device, int unit,
80
+	{ _PATH_DEV "ukbd%d", ATTR_KEYBOARD, "kbd", "dev.ukbd.%d.%%desc" },
91
+	char *devname, size_t devname_len)
81
+	{ _PATH_DEV "atkbd%d", ATTR_KEYBOARD, "kbd", "dev.atkbd.%d.%%desc" },
82
+	{ _PATH_DEV "kbdmux%d", ATTR_KEYBOARD, "kbd", NULL },
83
+	{ _PATH_DEV "ums%d", ATTR_POINTER, "mouse", "dev.ums.%d.%%desc" },
84
+	{ _PATH_DEV "psm%d", ATTR_POINTER, "mouse", "dev.psm.%d.%%desc" },
85
+	{ _PATH_DEV "joy%d", ATTR_JOYSTICK, "mouse", "dev.joy.%d.%%desc" },
86
+	{ _PATH_DEV "atp%d", ATTR_TOUCHPAD, "mouse", "dev.atp.%d.%%desc" },
87
+	{ _PATH_DEV "wsp%d", ATTR_TOUCHPAD, "mouse", "dev.wsp.%d.%%desc" },
88
+	{ _PATH_DEV "uep%d", ATTR_TOUCHSCREEN, "mouse", "dev.uep.%d.%%desc" },
89
+	{ _PATH_DEV "vboxguest", ATTR_POINTER, "vboxmouse", NULL },
90
+	{ _PATH_DEV "input/event%d", ATTR_TOUCHPAD, "evdev", NULL },
91
+	{ NULL, 0, NULL, NULL },
92
+};
93
+
94
+static void
95
+get_usb_id(char **pptr, int fd)
92
+{
96
+{
93
+	char sysctlname[PATH_MAX];
97
+	unsigned short vendor;
94
+	size_t len;
98
+	unsigned short product;
95
+	int ret;
99
+	unsigned int speed;
96
+
100
+#define	WEBCAMD_IOCTL_GET_USB_VENDOR_ID _IOR('q', 250, unsigned short)
97
+	if (device == NULL || device->driver == NULL)
101
+#define	WEBCAMD_IOCTL_GET_USB_PRODUCT_ID _IOR('q', 251, unsigned short)
98
+		return false;
102
+#define	WEBCAMD_IOCTL_GET_USB_SPEED _IOR('q', 252, unsigned int)
99
+
103
+	if (ioctl(fd, WEBCAMD_IOCTL_GET_USB_VENDOR_ID, &vendor) == 0 &&
100
+	/* Check if a sysctl exists. */
104
+	    ioctl(fd, WEBCAMD_IOCTL_GET_USB_PRODUCT_ID, &product) == 0 &&
101
+	snprintf(sysctlname, sizeof(sysctlname), "dev.%s.%i.%%desc",
105
+	    ioctl(fd, WEBCAMD_IOCTL_GET_USB_SPEED, &speed) == 0) {
102
+	    device->driver, unit);
106
+		if (asprintf(pptr, "%04x:%04x", vendor, product) == -1)
103
+	ret = sysctlbyname(sysctlname, NULL, &len, NULL, 0);
107
+			*pptr = NULL;
104
+
105
+	if (ret == 0 && len > 0) {
106
+		snprintf(devname, devname_len, "%s%i", device->driver, unit);
107
+		return true;
108
+	}
108
+	}
109
+
110
+	return false;
111
+}
109
+}
112
+
110
+
113
+static bool
111
+static const char *
114
+devpath_exists(const struct hw_type *device,
112
+skip_path_dev(const char *ptr)
115
+	char *devname, size_t devname_len)
116
+{
113
+{
117
+	char *devpath;
114
+	if (strstr(ptr, _PATH_DEV) == ptr)
118
+	struct stat st;
115
+		ptr += strlen(_PATH_DEV);
119
+	int ret;
116
+	return (ptr);
120
+
121
+	if (device == NULL || device->driver == NULL)
122
+		return false;
123
+
124
+	/* Check if /dev/$driver exists. */
125
+	asprintf(&devpath, "/dev/%s", device->driver);
126
+	if (devpath == NULL)
127
+		return false;
128
+
129
+	ret = stat(devpath, &st);
130
+	free(devpath);
131
+
132
+	if (ret == 0) {
133
+		strncpy(devname, device->driver, devname_len);
134
+		return true;
135
+	}
136
+
137
+	return false;
138
+}
117
+}
139
+
118
+
140
+static char *
119
+static char *
Lines 162-219 Link Here
162
+}
141
+}
163
+
142
+
164
+static void
143
+static void
165
+device_added(const char *devname)
144
+device_added(const char *devicename, bool allow_no_device)
166
+{
145
+{
167
+	char path[PATH_MAX];
146
+	InputAttributes attrs = { };
168
+	char sysctlname[PATH_MAX];
147
+	InputOption *options = NULL;
169
+	char *vendor;
148
+	char *config_info = NULL;
149
+	DeviceIntPtr dev = NULL;
150
+	struct hw_type hw_type;
170
+	char *product = NULL;
151
+	char *product = NULL;
171
+	char *config_info = NULL;
152
+	char sysctlname[64];
153
+	char *vendor = NULL;
154
+	int unit = 0;
155
+	int fd = -1;
172
+	char *walk;
156
+	char *walk;
173
+	InputOption *options = NULL;
174
+	InputAttributes attrs = { };
175
+	DeviceIntPtr dev = NULL;
176
+	int i;
157
+	int i;
177
+	int fd;
178
+
158
+
179
+	for (i = 0; hw_types[i].driver != NULL; i++) {
159
+	for (i = 0; hw_types0[i].driver != NULL; i++) {
180
+		size_t len;
160
+		if (strcmp(devicename, hw_types0[i].driver) == 0) {
181
+
161
+			hw_type = hw_types0[i];
182
+		len = strlen(hw_types[i].driver);
162
+			goto found;
183
+		if (strcmp(devname, hw_types[i].driver) == 0 ||
184
+			(strncmp(devname, hw_types[i].driver, len) == 0 &&
185
+				isnumber(*(devname + len)))) {
186
+			attrs.flags |= hw_types[i].flag;
187
+			break;
188
+		}
163
+		}
189
+	}
164
+	}
190
+
165
+	for (i = 0; hw_types1[i].driver != NULL; i++) {
191
+	if (hw_types[i].driver == NULL || hw_types[i].xdriver == NULL) {
166
+		if (sscanf(devicename, hw_types1[i].driver, &unit) == 1) {
192
+		LogMessage(X_INFO, "config/devd: ignoring device %s\n",
167
+			hw_type = hw_types1[i];
193
+				devname);
168
+			goto found;
194
+		return;
169
+		}
195
+	}
170
+	}
171
+	goto ignore;
196
+
172
+
197
+	/* Skip keyboard devices if kbdmux is enabled */
173
+found:
198
+	if (is_kbdmux && is_console_kbd && hw_types[i].flag & ATTR_KEYBOARD) {
174
+	if (hw_type.xdriver == NULL)
199
+		LogMessage(X_INFO, "config/devd: kbdmux is enabled, ignoring device %s\n",
175
+		goto ignore;
200
+				devname);
176
+
201
+		return;
177
+	/* set flags, if any */
178
+	attrs.flags |= hw_type.flag;
179
+
180
+	if (strcmp(hw_type.xdriver, "kbd") == 0) {
181
+		bool match = (strstr(hw_type.driver,
182
+		    _PATH_DEV "kbdmux") == hw_type.driver);
183
+
184
+		if (is_kbdmux) {
185
+			if (!match)
186
+				goto ignore;
187
+		} else {
188
+			if (match)
189
+				goto ignore;
190
+		}
202
+	}
191
+	}
203
+
192
+
204
+	snprintf(path, sizeof(path), "/dev/%s", devname);
205
+
206
+	options = input_option_new(NULL, "_source", "server/devd");
193
+	options = input_option_new(NULL, "_source", "server/devd");
207
+	if (!options)
194
+	if (options == NULL)
208
+		return;
195
+		goto error;
209
+
196
+
210
+	snprintf(sysctlname, sizeof(sysctlname), "dev.%s.%s.%%desc",
197
+	if (hw_type.sysctldesc != NULL) {
211
+	    hw_types[i].driver, devname + strlen(hw_types[i].driver));
198
+		snprintf(sysctlname, sizeof(sysctlname),
212
+	vendor = sysctl_get_str(sysctlname);
199
+		    hw_type.sysctldesc, unit);
200
+		vendor = sysctl_get_str(sysctlname);
201
+	}
202
+
213
+	if (vendor == NULL) {
203
+	if (vendor == NULL) {
214
+		options = input_option_new(options, "name", devname);
204
+		options = input_option_new(options, "name",
215
+	}
205
+		    skip_path_dev(devicename));
216
+	else {
206
+	} else {
217
+		if ((walk = strchr(vendor, ' ')) != NULL) {
207
+		if ((walk = strchr(vendor, ' ')) != NULL) {
218
+			walk[0] = '\0';
208
+			walk[0] = '\0';
219
+			walk++;
209
+			walk++;
Lines 223-299 Link Here
223
+		}
213
+		}
224
+
214
+
225
+		attrs.vendor = strdup(vendor);
215
+		attrs.vendor = strdup(vendor);
226
+		if (product) {
216
+		if (product != NULL) {
227
+			attrs.product = strdup(product);
217
+			attrs.product = strdup(product);
228
+			options = input_option_new(options, "name", product);
218
+			options = input_option_new(options,
219
+			    "name", product);
220
+		} else {
221
+			options = input_option_new(options,
222
+			    "name", "Unknown");
229
+		}
223
+		}
230
+		else
231
+			options = input_option_new(options, "name", "(unnamed)");
232
+
233
+		free(vendor);
234
+	}
224
+	}
225
+	attrs.device = strdup(devicename);
235
+
226
+
236
+	/* XXX implement usb_id */
227
+	fd = open(devicename, O_RDONLY);
237
+	attrs.usb_id = NULL;
228
+	if (fd > -1) {
238
+	attrs.device = strdup(path);
229
+	  	get_usb_id(&attrs.usb_id, fd);
239
+	options = input_option_new(options, "driver", hw_types[i].xdriver);
240
+
241
+	fd = open(path, O_RDONLY);
242
+	if (fd > 0) {
243
+		close(fd);
230
+		close(fd);
244
+		options = input_option_new(options, "device", path);
231
+		options = input_option_new(options, "device", devicename);
232
+		if (options == NULL)
233
+			goto error;
234
+	} else if (allow_no_device) {
235
+		/*
236
+		 * Don't pass "device" option if the keyboard is
237
+		 * already attached to the console (ie. open() fails).
238
+		 * This would activate a special logic in
239
+		 * xf86-input-keyboard. Prevent any other attached to
240
+		 * console keyboards being processed. There can be
241
+		 * only one such device.
242
+		 */
243
+	} else {
244
+		goto ignore;
245
+	}
245
+	}
246
+	else {
247
+		if (attrs.flags & ~ATTR_KEYBOARD) {
248
+			LogMessage(X_INFO, "config/devd: device %s already opened\n",
249
+					 path);
250
+
246
+
251
+			/*
247
+	options = input_option_new(options, "driver", hw_type.xdriver);
252
+			 * Fail if cannot open device, it breaks AllowMouseOpenFail,
248
+	if (options == NULL)
253
+			 * but it should not matter when config/devd enabled
249
+		goto error;
254
+			 */
255
+			goto unwind;
256
+		}
257
+
250
+
258
+		if (is_console_kbd) {
251
+	if (asprintf(&config_info, "devd:%s",
259
+			/*
252
+	    skip_path_dev(devicename)) == -1) {
260
+			 * There can be only one keyboard attached to console and
261
+			 * it is already added.
262
+			 */
263
+			LogMessage(X_WARNING, "config/devd: console keyboard is "
264
+					"already added, ignoring %s (%s)\n",
265
+					attrs.product, path);
266
+			goto unwind;
267
+		}
268
+		else
269
+			/*
270
+			 * Don't pass "device" option if the keyboard is already
271
+			 * attached to the console (ie. open() fails).
272
+			 * This would activate a special logic in xf86-input-keyboard.
273
+			 * Prevent any other attached to console keyboards being
274
+			 * processed. There can be only one such device.
275
+			 */
276
+			is_console_kbd = true;
277
+	}
278
+
279
+	if (asprintf(&config_info, "devd:%s", devname) == -1) {
280
+		config_info = NULL;
253
+		config_info = NULL;
281
+		goto unwind;
254
+		goto error;
282
+	}
255
+	}
283
+
256
+
284
+	if (device_is_duplicate(config_info)) {
257
+	if (device_is_duplicate(config_info))
285
+		LogMessage(X_WARNING, "config/devd: device %s (%s) already added. "
258
+		goto duplicate;
286
+				"ignoring\n", attrs.product, path);
287
+		goto unwind;
288
+	}
289
+
259
+
290
+	options = input_option_new(options, "config_info", config_info);
260
+	options = input_option_new(options, "config_info", config_info);
291
+	LogMessage(X_INFO, "config/devd: adding input device %s (%s)\n",
261
+	if (options == NULL)
292
+			attrs.product, path);
262
+		goto error;
293
+
263
+
264
+	LogMessage(X_INFO, "config/devd: adding input device '%s'\n",
265
+	    devicename);
266
+
294
+	NewInputDeviceRequest(options, &attrs, &dev);
267
+	NewInputDeviceRequest(options, &attrs, &dev);
268
+	goto done;
295
+
269
+
296
+unwind:
270
+duplicate:
271
+	LogMessage(X_WARNING, "config/devd: device '%s' already "
272
+	    "added. Ignoring\n", devicename);
273
+	goto done;
274
+
275
+error:
276
+	LogMessage(X_INFO, "config/devd: error adding device '%s'\n",
277
+	    devicename);
278
+	goto done;
279
+
280
+ignore:
281
+	LogMessage(X_INFO, "config/devd: ignoring device '%s'\n",
282
+	    devicename);
283
+	goto done;
284
+
285
+done:
297
+	free(config_info);
286
+	free(config_info);
298
+	input_option_free_list(&options);
287
+	input_option_free_list(&options);
299
+	free(attrs.usb_id);
288
+	free(attrs.usb_id);
Lines 300-315 Link Here
300
+	free(attrs.product);
289
+	free(attrs.product);
301
+	free(attrs.device);
290
+	free(attrs.device);
302
+	free(attrs.vendor);
291
+	free(attrs.vendor);
292
+	free(vendor);
303
+}
293
+}
304
+
294
+
305
+static void
295
+static void
306
+device_removed(char *devname)
296
+devpath_scan_sub(char *path, int off, int rem)
307
+{
297
+{
298
+	struct dirent *entry;
299
+	DIR *dp;
300
+
301
+	if ((dp = opendir(path)) == NULL) {
302
+		LogMessage(X_INFO, "Cannot open directory '%s'\n", path);
303
+		return;
304
+	}
305
+	while ((entry = readdir(dp)) != NULL) {
306
+		int len = strlen(entry->d_name);
307
+		if (len > rem)
308
+			continue;
309
+		strcpy(path + off, entry->d_name);
310
+		off += len;
311
+		rem -= len;
312
+		switch (entry->d_type) {
313
+		case DT_DIR:
314
+			if (strcmp(entry->d_name, ".") == 0 ||
315
+			    strcmp(entry->d_name, "..") == 0)
316
+				break;
317
+			if (rem < 1)
318
+				break;
319
+			path[off] = '/';
320
+			path[off+1] = '\0';
321
+			off++;
322
+			rem--;
323
+			/* recurse */
324
+			devpath_scan_sub(path, off, rem);
325
+			off--;
326
+			rem++;
327
+			break;
328
+		case DT_SOCK:
329
+		case DT_FIFO:
330
+		case DT_LNK:
331
+		case DT_CHR:
332
+			/* add device, if any */			
333
+			device_added(path, false);
334
+			break;
335
+		default:
336
+			break;
337
+		}
338
+		off -= len;
339
+		rem += len;
340
+	}
341
+	closedir(dp);
342
+}
343
+
344
+static void
345
+devpath_scan(void)
346
+{
347
+	char path[PATH_MAX + 1];
348
+
349
+	strlcpy(path, _PATH_DEV, sizeof(path));
350
+
351
+	devpath_scan_sub(path, strlen(path), PATH_MAX - strlen(path));
352
+}
353
+
354
+static void
355
+device_removed(char *devicename)
356
+{
308
+	char *config_info;
357
+	char *config_info;
309
+
358
+
310
+	if (asprintf(&config_info, "devd:%s", devname) == -1)
359
+	if (asprintf(&config_info, "devd:%s",
360
+	    skip_path_dev(devicename)) == -1)
311
+		return;
361
+		return;
312
+
362
+
363
+	if (device_is_duplicate(config_info)) {
364
+		LogMessage(X_INFO, "config/devd: removing input device '%s'\n",
365
+		    devicename);
366
+	}
313
+	remove_devices("devd", config_info);
367
+	remove_devices("devd", config_info);
314
+
368
+
315
+	free(config_info);
369
+	free(config_info);
Lines 318-325 Link Here
318
+static bool is_kbdmux_enabled(void)
372
+static bool is_kbdmux_enabled(void)
319
+{
373
+{
320
+	/* Xorg uses /dev/ttyv0 as a console device */
374
+	/* Xorg uses /dev/ttyv0 as a console device */
321
+	/* const char device[]="/dev/console"; */
375
+	static const char device[]= { _PATH_DEV "ttyv0" };
322
+	const char device[]="/dev/ttyv0";
323
+	keyboard_info_t info;
376
+	keyboard_info_t info;
324
+	int fd;
377
+	int fd;
325
+
378
+
Lines 448-454 Link Here
448
+static void
501
+static void
449
+wakeup_handler(void *data, int err, void *read_mask)
502
+wakeup_handler(void *data, int err, void *read_mask)
450
+{
503
+{
504
+	static const char cdev_create[] = { "!system=DEVFS subsystem=CDEV type=CREATE cdev=" };
505
+	static const char cdev_destroy[] = { "!system=DEVFS subsystem=CDEV type=DESTROY cdev=" };
506
+	static const char cdev_path[] = { _PATH_DEV };
451
+	char *line = NULL;
507
+	char *line = NULL;
508
+	char *devicename;
452
+	char *walk;
509
+	char *walk;
453
+
510
+
454
+	if (err < 0)
511
+	if (err < 0)
Lines 457-476 Link Here
457
+	if (FD_ISSET(sock_devd, (fd_set *) read_mask)) {
514
+	if (FD_ISSET(sock_devd, (fd_set *) read_mask)) {
458
+		if (socket_getline(sock_devd, &line) < 0)
515
+		if (socket_getline(sock_devd, &line) < 0)
459
+			return;
516
+			return;
460
+
517
+		if (strstr(line, cdev_create) == line) {
461
+		walk = strchr(line + 1, ' ');
518
+			devicename = line + strlen(cdev_create) - strlen(cdev_path);
462
+		if (walk != NULL)
519
+			memcpy(devicename, cdev_path, strlen(cdev_path));
463
+			walk[0] = '\0';
520
+			walk = strchr(devicename, ' ');
464
+
521
+			if (walk != NULL)
465
+		switch (*line) {
522
+				walk[0] = '\0';
466
+		case DEVD_EVENT_ADD:
523
+			device_added(devicename, false);
467
+			device_added(line + 1);
524
+		} else if (strstr(line, cdev_destroy) == line) {
468
+			break;
525
+			devicename = line + strlen(cdev_destroy) - strlen(cdev_path);
469
+		case DEVD_EVENT_REMOVE:
526
+			memcpy(devicename, cdev_path, strlen(cdev_path));
470
+			device_removed(line + 1);
527
+			walk = strchr(devicename, ' ');
471
+			break;
528
+			if (walk != NULL)
472
+		default:
529
+				walk[0] = '\0';
473
+			break;
530
+			device_removed(devicename);
474
+		}
531
+		}
475
+		free(line);
532
+		free(line);
476
+	}
533
+	}
Lines 484-518 Link Here
484
+int
541
+int
485
+config_devd_init(void)
542
+config_devd_init(void)
486
+{
543
+{
487
+	char devicename[1024];
488
+	int i, j;
489
+
490
+	LogMessage(X_INFO, "config/devd: probing input devices...\n");
544
+	LogMessage(X_INFO, "config/devd: probing input devices...\n");
491
+
545
+
492
+	/*
546
+	/* Check if kbdmux is enabled */
493
+	 * Add fake keyboard and give up on keyboards management
547
+	is_kbdmux = is_kbdmux_enabled();
494
+	 * if kbdmux is enabled
495
+	 */
496
+	if ((is_kbdmux = is_kbdmux_enabled()) == true)
497
+		device_added("kbdmux");
498
+
548
+
499
+	for (i = 0; hw_types[i].driver != NULL; i++) {
549
+	/* Try to add kbdmux device first */
500
+		/* First scan the sysctl to determine the hardware */
550
+	if (is_kbdmux)
501
+		for (j = 0; j < 16; j++) {
551
+		device_added(_PATH_DEV "kbdmux0", true);
502
+			if (sysctl_exists(&hw_types[i], j,
503
+					devicename, sizeof(devicename)) != 0)
504
+				device_added(devicename);
505
+		}
506
+
552
+
507
+		if (devpath_exists(&hw_types[i], devicename, sizeof(devicename)) != 0)
553
+	/* Connect to devd, so that we don't loose any events */
508
+			device_added(devicename);
509
+	}
510
+
511
+	if ((sock_devd = connect_devd()) < 0)
554
+	if ((sock_devd = connect_devd()) < 0)
512
+		return 0;
555
+		return 0;
513
+
556
+
514
+	RegisterBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
557
+	/* Scan what is currently connected */
558
+	devpath_scan();
515
+
559
+
560
+	/* Register wakeup handler */
561
+	RegisterBlockAndWakeupHandlers(block_handler,
562
+	    wakeup_handler, NULL);
563
+
516
+	return 1;
564
+	return 1;
517
+}
565
+}
518
+
566
+
Lines 528-534 Link Here
528
+
576
+
529
+	disconnect_devd(sock_devd);
577
+	disconnect_devd(sock_devd);
530
+
578
+
531
+	RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
579
+	RemoveBlockAndWakeupHandlers(block_handler,
532
+
580
+	    wakeup_handler, NULL);
533
+	is_console_kbd = false;
534
+}
581
+}

Return to bug 196678