Lines Matching refs:key

69         /* every key in the rules file becomes a token */
74 /* all key strings are copied and de-duplicated in a single continuous string buffer */
190 unsigned char type; /* same in rule and key */
218 } key;
328 enum operation_type op = token->key.op;
329 enum string_glob_type glob = token->key.glob;
330 const char *value = str(rules, token->key.value_off);
331 const char *attr = &rules->buf[token->key.attr_off];
376 log_debug("%s %i '%s'", token_str(type), token->key.builtin_cmd, value);
399 token_str(type), operation_str(op), value, string_glob_str(glob), token->key.mode);
402 log_debug("%s %u", token_str(type), token->key.watch);
405 log_debug("%s %u", token_str(type), token->key.devlink_prio);
408 log_debug("%s %s %u", token_str(type), operation_str(op), token->key.uid);
411 log_debug("%s %s %u", token_str(type), operation_str(op), token->key.gid);
414 log_debug("%s %s %#o", token_str(type), operation_str(op), token->key.mode);
423 log_debug("%s '%s' %u", token_str(type), value, token->key.rule_goto);
570 char *key;
574 /* find key */
575 key = line;
576 while (isspace(key[0]))
577 key++;
580 if (key[0] == '#' || key[0] == '\0')
583 /* split key/value */
584 val = strchr(key, '=');
594 /* terminate key */
595 len = strlen(key);
598 while (isspace(key[len-1]))
600 key[len] = '\0';
623 udev_device_add_property(dev, key, val);
680 const char *key = udev_list_entry_get_name(list_entry);
683 if (fnmatch(filter, key, 0) == 0)
684 udev_device_add_property(dev, key, val);
726 static int get_key(struct udev *udev, char **line, char **key, enum operation_type *op, char **value) {
738 /* get the key */
741 *key = linepos;
756 /* remember end of key */
759 /* skip whitespace after key */
787 /* terminate key */
810 /* move line to next key */
871 token->key.value_off = rules_add_string(rule_tmp->rules, value);
874 token->key.value_off = rules_add_string(rule_tmp->rules, value);
875 token->key.builtin_cmd = *(enum udev_builtin_cmd *)data;
886 token->key.value_off = rules_add_string(rule_tmp->rules, value);
887 token->key.attr_off = rules_add_string(rule_tmp->rules, attr);
890 token->key.value_off = rules_add_string(rule_tmp->rules, value);
892 token->key.mode = *(mode_t *)data;
900 token->key.builtin_cmd = *(enum udev_builtin_cmd *)data;
901 token->key.value_off = rules_add_string(rule_tmp->rules, value);
905 token->key.devlink_prio = *(int *)data;
908 token->key.uid = *(uid_t *)data;
911 token->key.gid = *(gid_t *)data;
914 token->key.mode = *(mode_t *)data;
946 token->key.glob = glob;
952 token->key.subst = SB_SUBSYS;
954 token->key.subst = SB_FORMAT;
956 token->key.subst = SB_NONE;
962 token->key.attrsubst = SB_SUBSYS;
964 token->key.attrsubst = SB_FORMAT;
966 token->key.attrsubst = SB_NONE;
969 token->key.type = type;
970 token->key.op = op;
1029 char *key;
1033 if (get_key(rules->udev, &linepos, &key, &op, &value) != 0) {
1047 log_error("invalid key/value pair in file %s on line %u, starting at character %tu ('%s')",
1055 if (streq(key, "ACTION")) {
1064 if (streq(key, "DEVPATH")) {
1073 if (streq(key, "KERNEL")) {
1082 if (streq(key, "SUBSYSTEM")) {
1100 if (streq(key, "DRIVER")) {
1109 if (startswith(key, "ATTR{")) {
1110 attr = get_key_attribute(rules->udev, key + strlen("ATTR"));
1126 if (startswith(key, "SYSCTL{")) {
1127 attr = get_key_attribute(rules->udev, key + strlen("SYSCTL"));
1143 if (startswith(key, "SECLABEL{")) {
1144 attr = get_key_attribute(rules->udev, key + strlen("SECLABEL"));
1158 if (streq(key, "KERNELS")) {
1167 if (streq(key, "SUBSYSTEMS")) {
1176 if (streq(key, "DRIVERS")) {
1185 if (startswith(key, "ATTRS{")) {
1190 attr = get_key_attribute(rules->udev, key + strlen("ATTRS"));
1205 if (streq(key, "TAGS")) {
1214 if (startswith(key, "ENV{")) {
1215 attr = get_key_attribute(rules->udev, key + strlen("ENV"));
1255 if (streq(key, "TAG")) {
1263 if (streq(key, "PROGRAM")) {
1272 if (streq(key, "RESULT")) {
1281 if (startswith(key, "IMPORT")) {
1282 attr = get_key_attribute(rules->udev, key + strlen("IMPORT"));
1325 if (startswith(key, "TEST")) {
1332 attr = get_key_attribute(rules->udev, key + strlen("TEST"));
1342 if (startswith(key, "RUN")) {
1343 attr = get_key_attribute(rules->udev, key + strlen("RUN"));
1369 if (streq(key, "LABEL")) {
1378 if (streq(key, "GOTO")) {
1387 if (startswith(key, "NAME")) {
1411 if (streq(key, "SYMLINK")) {
1424 if (streq(key, "OWNER")) {
1446 if (streq(key, "GROUP")) {
1468 if (streq(key, "MODE")) {
1486 if (streq(key, "OPTIONS")) {
1537 log_error("unknown key '%s' in %s:%u", key, filename, lineno);
1582 char *key;
1587 key = line;
1588 while (isspace(key[0]))
1589 key++;
1592 if (key[0] == '#')
1613 add_rule(rules, key, filename, filename_off, line_nr);
1619 char *label = rules_str(rules, rules->tokens[i].key.value_off);
1629 rules->tokens[i].key.rule_goto = j;
1632 if (rules->tokens[i].key.rule_goto == 0)
1726 char *key_value = rules_str(rules, token->key.value_off);
1733 switch (token->key.glob) {
1745 s = rules_str(rules, token->key.value_off);
1769 strscpy(value, sizeof(value), rules_str(rules, token->key.value_off));
1791 if (match && (token->key.op == OP_MATCH))
1793 if (!match && (token->key.op == OP_NOMATCH))
1805 name = rules_str(rules, cur->key.attr_off);
1806 switch (cur->key.attrsubst) {
1831 key_value = rules_str(rules, cur->key.value_off);
1917 const char *key_name = rules_str(rules, cur->key.attr_off);
1943 if (streq(rules_str(rules, cur->key.value_off), udev_list_entry_get_name(list_entry))) {
1948 if ((!match && (cur->key.op != OP_NOMATCH)) ||
1949 (match && (cur->key.op == OP_NOMATCH)))
1970 udev_event_apply_format(event, rules_str(rules, cur->key.attr_off), filename, sizeof(filename));
1997 struct token *key;
2000 for (key = cur; key < next; key++ ) {
2001 dump_token(rules, key);
2002 switch(key->type) {
2004 if (match_key(rules, key, udev_device_get_sysname(event->dev_parent)) != 0)
2008 if (match_key(rules, key, udev_device_get_subsystem(event->dev_parent)) != 0)
2012 if (match_key(rules, key, udev_device_get_driver(event->dev_parent)) != 0)
2016 if (match_attr(rules, event->dev_parent, event, key) != 0)
2020 bool match = udev_device_has_tag(event->dev_parent, rules_str(rules, cur->key.value_off));
2022 if (match && key->key.op == OP_NOMATCH)
2024 if (!match && key->key.op == OP_MATCH)
2048 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), filename, sizeof(filename));
2061 if (match && cur->key.mode > 0)
2062 match = ((statbuf.st_mode & cur->key.mode) > 0);
2063 if (match && cur->key.op == OP_NOMATCH)
2065 if (!match && cur->key.op == OP_MATCH)
2074 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), program, sizeof(program));
2081 if (cur->key.op != OP_NOMATCH)
2093 if (cur->key.op == OP_NOMATCH)
2101 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), import, sizeof(import));
2103 if (cur->key.op != OP_NOMATCH)
2110 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), import, sizeof(import));
2117 if (cur->key.op != OP_NOMATCH)
2124 if (udev_builtin_run_once(cur->key.builtin_cmd)) {
2126 if (event->builtin_run & (1 << cur->key.builtin_cmd)) {
2128 udev_builtin_name(cur->key.builtin_cmd),
2132 if (event->builtin_ret & (1 << cur->key.builtin_cmd))
2133 if (cur->key.op != OP_NOMATCH)
2138 event->builtin_run |= (1 << cur->key.builtin_cmd);
2141 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), command, sizeof(command));
2143 udev_builtin_name(cur->key.builtin_cmd),
2147 if (udev_builtin_run(event->dev, cur->key.builtin_cmd, command, false) != 0) {
2150 udev_builtin_name(cur->key.builtin_cmd));
2151 event->builtin_ret |= (1 << cur->key.builtin_cmd);
2152 if (cur->key.op != OP_NOMATCH)
2158 const char *key = rules_str(rules, cur->key.value_off);
2161 value = udev_device_get_property_value(event->dev_db, key);
2163 udev_device_add_property(event->dev, key, value);
2165 if (cur->key.op != OP_NOMATCH)
2179 const char *key = rules_str(rules, cur->key.value_off);
2182 pos = strstr(cmdline, key);
2184 pos += strlen(key);
2187 udev_device_add_property(event->dev, key, "1");
2197 udev_device_add_property(event->dev, key, value);
2204 if (!imported && cur->key.op != OP_NOMATCH)
2211 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), import, sizeof(import));
2213 if (cur->key.op != OP_NOMATCH)
2233 if (cur->key.op == OP_ASSIGN_FINAL)
2235 event->inotify_watch = cur->key.watch;
2238 udev_device_set_devlink_priority(event->dev, cur->key.devlink_prio);
2247 if (cur->key.op == OP_ASSIGN_FINAL)
2249 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), owner, sizeof(owner));
2273 if (cur->key.op == OP_ASSIGN_FINAL)
2275 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), group, sizeof(group));
2299 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), mode_str, sizeof(mode_str));
2305 if (cur->key.op == OP_ASSIGN_FINAL)
2318 if (cur->key.op == OP_ASSIGN_FINAL)
2321 event->uid = cur->key.uid;
2330 if (cur->key.op == OP_ASSIGN_FINAL)
2333 event->gid = cur->key.gid;
2342 if (cur->key.op == OP_ASSIGN_FINAL)
2345 event->mode = cur->key.mode;
2354 name = rules_str(rules, cur->key.attr_off);
2355 label = rules_str(rules, cur->key.value_off);
2356 if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL)
2366 const char *name = rules_str(rules, cur->key.attr_off);
2367 char *value = rules_str(rules, cur->key.value_off);
2372 if (cur->key.op == OP_ADD)
2378 if (cur->key.op == OP_ADD)
2396 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), tag, sizeof(tag));
2397 if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL)
2408 if (cur->key.op == OP_REMOVE)
2415 const char *name = rules_str(rules, cur->key.value_off);
2422 if (cur->key.op == OP_ASSIGN_FINAL)
2454 if (cur->key.op == OP_ASSIGN_FINAL)
2456 if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL)
2460 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), temp, sizeof(temp));
2491 const char *key_name = rules_str(rules, cur->key.attr_off);
2500 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), value, sizeof(value));
2519 udev_event_apply_format(event, rules_str(rules, cur->key.attr_off), filename, sizeof(filename));
2521 udev_event_apply_format(event, rules_str(rules, cur->key.value_off), value, sizeof(value));
2533 if (cur->key.op == OP_ASSIGN || cur->key.op == OP_ASSIGN_FINAL)
2536 rules_str(rules, cur->key.value_off),
2539 entry = udev_list_entry_add(&event->run_list, rules_str(rules, cur->key.value_off), NULL);
2540 udev_list_entry_set_num(entry, cur->key.builtin_cmd);
2544 if (cur->key.rule_goto == 0)
2546 cur = &rules->tokens[cur->key.rule_goto];
2600 uid = cur->key.uid;
2603 gid = cur->key.gid;
2606 mode = cur->key.mode;
2609 r = strv_extend(&tags, rules_str(rules, cur->key.value_off));
2625 strscpyl(device_node, sizeof(device_node), "/dev/", rules_str(rules, cur->key.value_off), NULL);
2641 unescaped_filename = xescape(rules_str(rules, cur->key.value_off), "/.");