mirror of
https://github.com/systemd/systemd.git
synced 2025-02-04 21:47:31 +03:00
Merge pull request #27398 from yuwata/udev-rule-negative-match
udev-rule: fix negative match
This commit is contained in:
commit
1db4acbe5d
15
man/udev.xml
15
man/udev.xml
@ -186,10 +186,10 @@
|
||||
<varlistentry>
|
||||
<term><varname>SYMLINK</varname></term>
|
||||
<listitem>
|
||||
<para>Match the name of a symlink targeting the node. It can
|
||||
be used once a SYMLINK key has been set in one of the preceding
|
||||
rules. There may be multiple symlinks; only one needs to match.
|
||||
</para>
|
||||
<para>Match the name of a symlink targeting the node. It can be used once a SYMLINK key has
|
||||
been set in one of the preceding rules. There may be multiple symlinks; only one needs to
|
||||
match. If the operator is <literal>!=</literal>, the token returns true only if there is no
|
||||
symlink matched.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
@ -287,14 +287,17 @@
|
||||
<varlistentry>
|
||||
<term><varname>TAG</varname></term>
|
||||
<listitem>
|
||||
<para>Match against a device tag.</para>
|
||||
<para>Match against one of device tags. It can be used once a TAG key has been set in one of
|
||||
the preceding rules. There may be multiple tags; only one needs to match. If the operator is
|
||||
<literal>!=</literal>, the token returns true only if there is no tag matched.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>TAGS</varname></term>
|
||||
<listitem>
|
||||
<para>Search the devpath upwards for a device with matching tag.</para>
|
||||
<para>Search the devpath upwards for a device with matching tag. If the operator is
|
||||
<literal>!=</literal>, the token returns true only if there is no tag matched.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@ -1896,7 +1896,7 @@ static int udev_rule_apply_token_to_event(
|
||||
const char *val;
|
||||
|
||||
FOREACH_DEVICE_DEVLINK(dev, val)
|
||||
if (token_match_string(token, strempty(startswith(val, "/dev/"))))
|
||||
if (token_match_string(token, strempty(startswith(val, "/dev/"))) == (token->op == OP_MATCH))
|
||||
return token->op == OP_MATCH;
|
||||
return token->op == OP_NOMATCH;
|
||||
}
|
||||
@ -1926,7 +1926,7 @@ static int udev_rule_apply_token_to_event(
|
||||
const char *val;
|
||||
|
||||
FOREACH_DEVICE_CURRENT_TAG(dev, val)
|
||||
if (token_match_string(token, val))
|
||||
if (token_match_string(token, val) == (token->op == OP_MATCH))
|
||||
return token->op == OP_MATCH;
|
||||
return token->op == OP_NOMATCH;
|
||||
}
|
||||
|
@ -231,7 +231,8 @@ EOF
|
||||
"string_escape___replace/foo_bbb",
|
||||
"env_with_space",
|
||||
"default/replace/mode_foo__hoge",
|
||||
"replace_env_harder_foo__hoge"],
|
||||
"replace_env_harder_foo__hoge",
|
||||
"match", "unmatch"],
|
||||
not_exp_links => ["removed1", "removed2", "removed3", "unsafe/../../path", "/nondev/path/will/be/refused"],
|
||||
}],
|
||||
rules => <<EOF
|
||||
@ -250,6 +251,8 @@ SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", OPTIONS="s
|
||||
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ENV{.HOGE}="env with space", SYMLINK+="%E{.HOGE}"
|
||||
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", ENV{.HOGE}="default/replace/mode?foo;;hoge", SYMLINK+="%E{.HOGE}"
|
||||
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", OPTIONS="string_escape=replace", ENV{.HOGE}="replace/env/harder?foo;;hoge", SYMLINK+="%E{.HOGE}"
|
||||
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", SYMLINK=="link1", SYMLINK+="match"
|
||||
SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", ATTRS{model}=="ST910021AS", SYMLINK!="removed1", SYMLINK+="unmatch"
|
||||
EOF
|
||||
},
|
||||
{
|
||||
@ -1853,13 +1856,15 @@ EOF
|
||||
devices => [
|
||||
{
|
||||
devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda",
|
||||
exp_links => ["found"],
|
||||
not_exp_name => "bad",
|
||||
exp_links => ["found", "found2"],
|
||||
not_exp_name => ["bad", "bad2"],
|
||||
}],
|
||||
rules => <<EOF
|
||||
KERNEL=="sda", TAG="foo"
|
||||
TAGS=="foo|", SYMLINK+="found"
|
||||
TAGS=="aaa|", SYMLINK+="bad"
|
||||
KERNEL=="sda", TAGS!="hoge", SYMLINK+="found2"
|
||||
KERNEL=="sda", TAGS!="foo", SYMLINK+="bad2"
|
||||
EOF
|
||||
},
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user