#include "utf8.h"
#include "util.h"
-const char *net_get_name(sd_device *device) {
+const char *net_get_name_persistent(sd_device *device) {
const char *name, *field;
assert(device);
#define HASH_KEY SD_ID128_MAKE(d3,1e,48,fa,90,fe,4b,4c,9d,af,d5,d7,a1,b1,2e,8a)
-int net_get_unique_predictable_data(sd_device *device, uint64_t *result) {
+int net_get_unique_predictable_data(sd_device *device, bool use_sysname, uint64_t *result) {
size_t l, sz = 0;
const char *name;
int r;
assert(device);
- /* net_get_name() will return one of the device names based on stable information about the
- * device. If this is not available, we fall back to using the device name. */
- name = net_get_name(device);
- if (!name)
+ /* net_get_name_persistent() will return one of the device names based on stable information about
+ * the device. If this is not available, we fall back to using the actual device name. */
+ name = net_get_name_persistent(device);
+ if (!name && use_sysname)
(void) sd_device_get_sysname(device, &name);
if (!name)
return log_device_debug_errno(device, SYNTHETIC_ERRNO(ENODATA),
char * const *match_drivers,
char * const *match_types,
char * const *match_names,
- Condition *match_host,
- Condition *match_virt,
- Condition *match_kernel_cmdline,
- Condition *match_kernel_version,
- Condition *match_arch,
const struct ether_addr *dev_mac,
const char *dev_path,
const char *dev_driver,
const char *dev_type,
const char *dev_name) {
- if (match_host && condition_test(match_host) <= 0)
- return false;
-
- if (match_virt && condition_test(match_virt) <= 0)
- return false;
-
- if (match_kernel_cmdline && condition_test(match_kernel_cmdline) <= 0)
- return false;
-
- if (match_kernel_version && condition_test(match_kernel_version) <= 0)
- return false;
-
- if (match_arch && condition_test(match_arch) <= 0)
- return false;
-
if (match_mac && (!dev_mac || !set_contains(match_mac, dev_mac)))
return false;
void *userdata) {
ConditionType cond = ltype;
- Condition **ret = data;
+ Condition **list = data, *c;
bool negate;
- Condition *c;
- _cleanup_free_ char *s = NULL;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
+ if (isempty(rvalue)) {
+ *list = condition_free_list_type(*list, cond);
+ return 0;
+ }
+
negate = rvalue[0] == '!';
if (negate)
rvalue++;
- s = strdup(rvalue);
- if (!s)
- return log_oom();
-
- c = condition_new(cond, s, false, negate);
+ c = condition_new(cond, rvalue, false, negate);
if (!c)
return log_oom();
- if (*ret)
- condition_free(*ret);
+ /* Drop previous assignment. */
+ *list = condition_free_list_type(*list, cond);
- *ret = c;
+ LIST_PREPEND(conditions, *list, c);
return 0;
}
assert(data);
hex_buf = hexmem(data, size);
- if (hex_buf == NULL)
+ if (!hex_buf)
return -ENOMEM;
fprintf(f, "%s=%s\n", key, hex_buf);