about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-08-27 15:17:29 +0000
committerLaurent Bercot <ska@appnovation.com>2021-08-27 15:17:29 +0000
commit8797fba30db6f2587753346bee4d1f11c9d5b8ed (patch)
treeb036b7e85f35cfda9c05da3f91fba62895abf98b
parenta7b093b0eb1db7dde2463271ee15766df8e584a2 (diff)
downloadmdevd-8797fba30db6f2587753346bee4d1f11c9d5b8ed.tar.gz
mdevd-8797fba30db6f2587753346bee4d1f11c9d5b8ed.tar.xz
mdevd-8797fba30db6f2587753346bee4d1f11c9d5b8ed.zip
Support any action type in * and & command directives
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--doc/mdevd.html10
-rw-r--r--src/mdevd/mdevd.c5
2 files changed, 11 insertions, 4 deletions
diff --git a/doc/mdevd.html b/doc/mdevd.html
index dfb44a3..7b509d1 100644
--- a/doc/mdevd.html
+++ b/doc/mdevd.html
@@ -156,6 +156,12 @@ configuration where it can create device nodes as root or delete them, and does
 nothing else.
 </p>
 
+<p>
+ A semantic difference with <tt>mdev</tt> is that a <tt>*</tt> command will
+be run on <em>every</em> action type, not just <tt>ACTION=add</tt> and
+<tt>ACTION=remove</tt>.
+</p>
+
 <h3> execline command support </h3>
 
 <p>
@@ -174,8 +180,8 @@ equivalent of <tt>@<em>cmd</em></tt>. </li>
 when this line catches an event that has <tt>ACTION=remove</tt>. This is the
 equivalent of <tt>$<em>cmd</em></tt>. </li>
  <li> <tt>&amp;<em>cmd</em></tt>&nbsp;: spawns <tt>execlineb -Pc <em>cmd</em></tt>
-when this line catches an event no matter its action type. This is the
-equivalent of <tt>*<em>cmd</em></tt>. </li>
+when this line catches an event no matter its action type (<tt>add</tt>,
+<tt>remove</tt>, or anything else). This is the equivalent of <tt>*<em>cmd</em></tt>. </li>
 </ul>
 
 <p>
diff --git a/src/mdevd/mdevd.c b/src/mdevd/mdevd.c
index a486a9a..6bcdf98 100644
--- a/src/mdevd/mdevd.c
+++ b/src/mdevd/mdevd.c
@@ -52,6 +52,7 @@
 #define ACTION_NONE 0x0
 #define ACTION_ADD 0x1
 #define ACTION_REMOVE 0x2
+#define ACTION_ANY 0x3
 
 static int dryrun = 0 ;
 static int cont = 1 ;
@@ -823,7 +824,7 @@ static inline int run_scriptelem (struct uevent_s *event, scriptelem const *elem
     }
   }
 
-  if (action & elem->cmdtype)
+  if (elem->cmdtype == ACTION_ANY || action == elem->cmdtype)
   {
     if (!event_getvar(event, "MDEV"))
     {
@@ -952,7 +953,7 @@ static inline void on_event (struct uevent_s *event, scriptelem const *script, u
   if (!x) return ;
   if (!strcmp(x, "add")) action = ACTION_ADD ;
   else if (!strcmp(x, "remove")) action = ACTION_REMOVE ;
-  else return ;
+  else action = ACTION_ANY ;
   x = event_getvar(event, "DEVPATH") ;
   if (!x) return ;
   {