chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cgroup: Handle error when destroying cgroup
[elogind.git]
/
src
/
udev
/
udev-builtin-keyboard.c
diff --git
a/src/udev/udev-builtin-keyboard.c
b/src/udev/udev-builtin-keyboard.c
index ddd853594e96cd3792805fe7c35282143fb60e05..273b27ddcb624bd0b702a7e6f7020b2574d2a1b0 100644
(file)
--- a/
src/udev/udev-builtin-keyboard.c
+++ b/
src/udev/udev-builtin-keyboard.c
@@
-59,10
+59,10
@@
static int install_force_release(struct udev_device *dev, const unsigned int *re
for (i = 0; i < release_count; i++)
l = strpcpyf(&s, l, ",%d", release[i]);
for (i = 0; i < release_count; i++)
l = strpcpyf(&s, l, ",%d", release[i]);
- log_debug("keyboard: updating force-release list with '%s'
\n
", codes);
+ log_debug("keyboard: updating force-release list with '%s'", codes);
ret = udev_device_set_sysattr_value(atkbd, "force_release", codes);
if (ret < 0)
ret = udev_device_set_sysattr_value(atkbd, "force_release", codes);
if (ret < 0)
- log_error
("Error writing force-release attribute: %s", strerror(-ret)
);
+ log_error
_errno(ret, "Error writing force-release attribute: %m"
);
return ret;
}
return ret;
}
@@
-78,7
+78,7
@@
static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev)) {
const char *key;
udev_list_entry_foreach(entry, udev_device_get_properties_list_entry(dev)) {
const char *key;
- unsigned int scancode;
+ unsigned int scancode
, keycode_num
;
char *endptr;
const char *keycode;
const struct key *k;
char *endptr;
const char *keycode;
const struct key *k;
@@
-88,9
+88,9
@@
static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
continue;
/* KEYBOARD_KEY_<hex scan code>=<key identifier string> */
continue;
/* KEYBOARD_KEY_<hex scan code>=<key identifier string> */
- scancode = strtol(key + 13, &endptr, 16);
+ scancode = strto
u
l(key + 13, &endptr, 16);
if (endptr[0] != '\0') {
if (endptr[0] != '\0') {
- log_error("Error, unable to parse scan code from '%s'
\n
", key);
+ log_error("Error, unable to parse scan code from '%s'", key);
continue;
}
continue;
}
@@
-110,13
+110,19
@@
static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
/* translate identifier to key code */
k = keyboard_lookup_key(keycode, strlen(keycode));
/* translate identifier to key code */
k = keyboard_lookup_key(keycode, strlen(keycode));
- if (!k) {
- log_error("Error, unknown key identifier '%s'\n", keycode);
- continue;
+ if (k) {
+ keycode_num = k->id;
+ } else {
+ /* check if it's a numeric code already */
+ keycode_num = strtoul(keycode, &endptr, 0);
+ if (endptr[0] !='\0') {
+ log_error("Error, unknown key identifier '%s'", keycode);
+ continue;
+ }
}
map[map_count].scan = scancode;
}
map[map_count].scan = scancode;
- map[map_count].key = k
->id
;
+ map[map_count].key = k
eycode_num
;
if (map_count < ELEMENTSOF(map)-1)
map_count++;
}
if (map_count < ELEMENTSOF(map)-1)
map_count++;
}
@@
-128,22
+134,22
@@
static int builtin_keyboard(struct udev_device *dev, int argc, char *argv[], boo
node = udev_device_get_devnode(dev);
if (!node) {
node = udev_device_get_devnode(dev);
if (!node) {
- log_error("Error, no device node for '%s'
\n
", udev_device_get_syspath(dev));
+ log_error("Error, no device node for '%s'", udev_device_get_syspath(dev));
return EXIT_FAILURE;
}
fd = open(udev_device_get_devnode(dev), O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (fd < 0) {
return EXIT_FAILURE;
}
fd = open(udev_device_get_devnode(dev), O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (fd < 0) {
- log_error
("Error, opening device '%s': %m\n
", node);
+ log_error
_errno(errno, "Error, opening device '%s': %m
", node);
return EXIT_FAILURE;
}
/* install list of map codes */
for (i = 0; i < map_count; i++) {
return EXIT_FAILURE;
}
/* install list of map codes */
for (i = 0; i < map_count; i++) {
- log_debug("keyboard: mapping scan code %d (0x%x) to key code %d (0x%x)
\n
",
+ log_debug("keyboard: mapping scan code %d (0x%x) to key code %d (0x%x)",
map[i].scan, map[i].scan, map[i].key, map[i].key);
if (ioctl(fd, EVIOCSKEYCODE, &map[i]) < 0)
map[i].scan, map[i].scan, map[i].key, map[i].key);
if (ioctl(fd, EVIOCSKEYCODE, &map[i]) < 0)
- log_error
("Error calling EVIOCSKEYCODE: %m\n"
);
+ log_error
_errno(errno, "Error calling EVIOCSKEYCODE on device node '%s' (scan code 0x%x, key code %d): %m", node, map[i].scan, map[i].key
);
}
/* install list of force-release codes */
}
/* install list of force-release codes */