diff options
author | Kay Sievers <kay@vrfy.org> | 2012-07-15 22:10:46 +0200 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2012-07-15 22:10:46 +0200 |
commit | 4cb72937d3c10948e4904388ea27efae75775f08 (patch) | |
tree | bf7feaedf35aece23c30365747e75204b762ba60 /src/udev | |
parent | cf3fb69acba245356022ccc087da640a6093584d (diff) |
udev: get rid of TEST_PREFIX and use unshare() to fake /sys, /dev, /run
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/udev-event.c | 12 | ||||
-rw-r--r-- | src/udev/udev-node.c | 8 | ||||
-rw-r--r-- | src/udev/udev-rules.c | 16 |
3 files changed, 18 insertions, 18 deletions
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index d5dd1f3ba4..2ade0ab81a 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -319,7 +319,7 @@ subst: break; devnode = udev_device_get_devnode(dev_parent); if (devnode != NULL) - l = util_strpcpy(&s, l, devnode + strlen(TEST_PREFIX "/dev/")); + l = util_strpcpy(&s, l, devnode + strlen("/dev/")); break; } case SUBST_DEVNODE: @@ -330,7 +330,7 @@ subst: if (event->name != NULL) l = util_strpcpy(&s, l, event->name); else if (udev_device_get_devnode(dev) != NULL) - l = util_strpcpy(&s, l, udev_device_get_devnode(dev) + strlen(TEST_PREFIX "/dev/")); + l = util_strpcpy(&s, l, udev_device_get_devnode(dev) + strlen("/dev/")); else l = util_strpcpy(&s, l, udev_device_get_sysname(dev)); break; @@ -340,16 +340,16 @@ subst: list_entry = udev_device_get_devlinks_list_entry(dev); if (list_entry == NULL) break; - l = util_strpcpy(&s, l, udev_list_entry_get_name(list_entry) + strlen(TEST_PREFIX "/dev/")); + l = util_strpcpy(&s, l, udev_list_entry_get_name(list_entry) + strlen("/dev/")); udev_list_entry_foreach(list_entry, udev_list_entry_get_next(list_entry)) - l = util_strpcpyl(&s, l, " ", udev_list_entry_get_name(list_entry) + strlen(TEST_PREFIX "/dev/"), NULL); + l = util_strpcpyl(&s, l, " ", udev_list_entry_get_name(list_entry) + strlen("/dev/"), NULL); break; } case SUBST_ROOT: - l = util_strpcpy(&s, l, TEST_PREFIX "/dev"); + l = util_strpcpy(&s, l, "/dev"); break; case SUBST_SYS: - l = util_strpcpy(&s, l, TEST_PREFIX "/sys"); + l = util_strpcpy(&s, l, "/sys"); break; case SUBST_ENV: if (attr == NULL) { diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c index 9add76547f..738d02fa25 100644 --- a/src/udev/udev-node.c +++ b/src/udev/udev-node.c @@ -190,8 +190,8 @@ static void link_update(struct udev_device *dev, const char *slink, bool add) const char *target; char buf[UTIL_PATH_SIZE]; - util_path_encode(slink + strlen(TEST_PREFIX "/dev"), name_enc, sizeof(name_enc)); - util_strscpyl(dirname, sizeof(dirname), TEST_PREFIX "/run/udev/links/", name_enc, NULL); + util_path_encode(slink + strlen("/dev"), name_enc, sizeof(name_enc)); + util_strscpyl(dirname, sizeof(dirname), "/run/udev/links/", name_enc, NULL); util_strscpyl(filename, sizeof(filename), dirname, "/", udev_device_get_id_filename(dev), NULL); if (!add && unlink(filename) == 0) @@ -315,7 +315,7 @@ void udev_node_add(struct udev_device *dev, mode_t mode, uid_t uid, gid_t gid) return; /* always add /dev/{block,char}/$major:$minor */ - snprintf(filename, sizeof(filename), TEST_PREFIX "/dev/%s/%u:%u", + snprintf(filename, sizeof(filename), "/dev/%s/%u:%u", strcmp(udev_device_get_subsystem(dev), "block") == 0 ? "block" : "char", major(udev_device_get_devnum(dev)), minor(udev_device_get_devnum(dev))); node_symlink(udev, udev_device_get_devnode(dev), filename); @@ -340,7 +340,7 @@ void udev_node_remove(struct udev_device *dev) link_update(dev, udev_list_entry_get_name(list_entry), 0); /* remove /dev/{block,char}/$major:$minor */ - snprintf(filename, sizeof(filename), TEST_PREFIX "/dev/%s/%u:%u", + snprintf(filename, sizeof(filename), "/dev/%s/%u:%u", strcmp(udev_device_get_subsystem(dev), "block") == 0 ? "block" : "char", major(udev_device_get_devnum(dev)), minor(udev_device_get_devnum(dev))); unlink(filename); diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index c571c82877..d3b33e4bbf 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -1757,9 +1757,9 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) memset(rules->trie_nodes, 0x00, sizeof(struct trie_node)); rules->trie_nodes_cur = 1; - rules->dirs = strv_new(TEST_PREFIX SYSCONFDIR "/udev/rules.d", - TEST_PREFIX "/run/udev/rules.d", - TEST_PREFIX UDEVLIBEXECDIR "/rules.d", + rules->dirs = strv_new(SYSCONFDIR "/udev/rules.d", + "/run/udev/rules.d", + UDEVLIBEXECDIR "/rules.d", NULL); if (!rules->dirs) { log_error("failed to build config directory array"); @@ -2059,7 +2059,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(event->dev)) { const char *devlink; - devlink = udev_list_entry_get_name(list_entry) + strlen(TEST_PREFIX "/dev/"); + devlink = udev_list_entry_get_name(list_entry) + strlen("/dev/"); if (match_key(rules, cur, devlink) == 0) { match = true; break; @@ -2533,7 +2533,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event log_debug("%i character(s) replaced\n", count); } if (major(udev_device_get_devnum(event->dev)) && - (!streq(name_str, udev_device_get_devnode(event->dev) + strlen(TEST_PREFIX "/dev/")))) { + (!streq(name_str, udev_device_get_devnode(event->dev) + strlen("/dev/")))) { log_error("NAME=\"%s\" ignored, kernel device nodes " "can not be renamed; please fix it in %s:%u\n", name, &rules->buf[rule->rule.filename_off], rule->rule.filename_line); @@ -2578,7 +2578,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event next[0] = '\0'; log_debug("LINK '%s' %s:%u\n", pos, &rules->buf[rule->rule.filename_off], rule->rule.filename_line); - util_strscpyl(filename, sizeof(filename), TEST_PREFIX "/dev/", pos, NULL); + util_strscpyl(filename, sizeof(filename), "/dev/", pos, NULL); udev_device_add_devlink(event->dev, filename, cur->key.devlink_unique); while (isspace(next[1])) next++; @@ -2588,7 +2588,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event if (pos[0] != '\0') { log_debug("LINK '%s' %s:%u\n", pos, &rules->buf[rule->rule.filename_off], rule->rule.filename_line); - util_strscpyl(filename, sizeof(filename), TEST_PREFIX "/dev/", pos, NULL); + util_strscpyl(filename, sizeof(filename), "/dev/", pos, NULL); udev_device_add_devlink(event->dev, filename, cur->key.devlink_unique); } break; @@ -2698,7 +2698,7 @@ void udev_rules_apply_static_dev_perms(struct udev_rules *rules) /* we assure, that the permissions tokens are sorted before the static token */ if (mode == 0 && uid == 0 && gid == 0) goto next; - util_strscpyl(filename, sizeof(filename), TEST_PREFIX "/dev/", + util_strscpyl(filename, sizeof(filename), "/dev/", &rules->buf[cur->key.value_off], NULL); if (stat(filename, &stats) != 0) goto next; |