mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-08 21:17:47 +03:00
Merge pull request #26081 from yuwata/udev-symlink-remove
udev: support -= operator for SYMLINK
This commit is contained in:
commit
2cd1e475dd
@ -38,6 +38,7 @@ void device_set_db_persist(sd_device *device);
|
||||
void device_set_devlink_priority(sd_device *device, int priority);
|
||||
int device_ensure_usec_initialized(sd_device *device, sd_device *device_old);
|
||||
int device_add_devlink(sd_device *device, const char *devlink);
|
||||
void device_remove_devlink(sd_device *device, const char *devlink);
|
||||
bool device_has_devlink(sd_device *device, const char *devlink);
|
||||
int device_add_property(sd_device *device, const char *property, const char *value);
|
||||
int device_add_propertyf(sd_device *device, const char *key, const char *format, ...) _printf_(3, 4);
|
||||
|
@ -1489,6 +1489,20 @@ int device_add_devlink(sd_device *device, const char *devlink) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void device_remove_devlink(sd_device *device, const char *devlink) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
|
||||
assert(device);
|
||||
assert(devlink);
|
||||
|
||||
s = set_remove(device->devlinks, devlink);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
device->devlinks_generation++;
|
||||
device->property_devlinks_outdated = true;
|
||||
}
|
||||
|
||||
bool device_has_devlink(sd_device *device, const char *devlink) {
|
||||
assert(device);
|
||||
assert(devlink);
|
||||
|
@ -579,9 +579,6 @@ static int parse_token(UdevRules *rules, const char *key, char *attr, UdevRuleOp
|
||||
} else if (streq(key, "SYMLINK")) {
|
||||
if (attr)
|
||||
return log_token_invalid_attr(rules, key);
|
||||
if (op == OP_REMOVE)
|
||||
return log_token_invalid_op(rules, key);
|
||||
|
||||
if (!is_match) {
|
||||
check_value_format_and_warn(rules, key, value, false);
|
||||
r = rule_line_add_token(rule_line, TK_A_DEVLINK, op, value, NULL);
|
||||
@ -2313,11 +2310,17 @@ static int udev_rule_apply_token_to_event(
|
||||
if (truncated)
|
||||
continue;
|
||||
|
||||
r = device_add_devlink(dev, filename);
|
||||
if (r < 0)
|
||||
return log_rule_error_errno(dev, rules, r, "Failed to add devlink '%s': %m", filename);
|
||||
if (token->op == OP_REMOVE) {
|
||||
device_remove_devlink(dev, filename);
|
||||
log_rule_debug(dev, rules, "Dropped SYMLINK '%s'", p);
|
||||
} else {
|
||||
r = device_add_devlink(dev, filename);
|
||||
if (r < 0)
|
||||
return log_rule_error_errno(dev, rules, r, "Failed to add devlink '%s': %m", filename);
|
||||
|
||||
log_rule_debug(dev, rules, "Added SYMLINK '%s'", p);
|
||||
}
|
||||
|
||||
log_rule_debug(dev, rules, "LINK '%s'", p);
|
||||
p = next;
|
||||
}
|
||||
break;
|
||||
|
@ -212,12 +212,13 @@ EOF
|
||||
{
|
||||
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda/sda1",
|
||||
exp_links => ["boot_disk1", "boot_diskXY1"],
|
||||
not_exp_links => ["boot_diskXX1"],
|
||||
not_exp_links => ["boot_diskXX1", "hoge"],
|
||||
}],
|
||||
rules => <<EOF
|
||||
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", ATTRS{queue_depth}=="32", SYMLINK+="boot_diskXX%n"
|
||||
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", ATTRS{queue_depth}=="1", SYMLINK+="boot_diskXY%n"
|
||||
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", SYMLINK+="boot_disk%n"
|
||||
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", SYMLINK+="boot_disk%n", SYMLINK+="hoge"
|
||||
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ATTRS{scsi_level}=="6", ATTRS{rev}=="4.06", ATTRS{type}=="0", SYMLINK-="hoge"
|
||||
EOF
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user