]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm: Propagate return code from verb result
authorJoakim Nohlgård <joakim@nohlgard.se>
Fri, 29 Dec 2023 14:06:50 +0000 (15:06 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 29 Dec 2023 20:26:59 +0000 (05:26 +0900)
udevadm lock did not propagate the return code from the child process
because all positive values were treated as success.

v2:
Now 'udevadm test-builtin' ignores all positive return values from the
builtin commands. Otherwise, as the hwdb builtin returns an positive value
when a matching entry found, 'udevadm test-builtin hwdb' will fail.

v3:
Initialize partition table before calling 'sfdisk --delete'.

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
src/udev/udevadm-test-builtin.c
src/udev/udevadm.c
test/units/testsuite-64.sh

index 5d1fafbd0390a56bc6bc627d4fd71f79b1f0a5bc..f5498a1e5b140046e2060f5c63f4880179b75d10 100644 (file)
@@ -104,9 +104,12 @@ int builtin_main(int argc, char *argv[], void *userdata) {
         }
 
         r = udev_builtin_run(event, cmd, arg_command, true);
-        if (r < 0)
+        if (r < 0) {
                 log_debug_errno(r, "Builtin command '%s' fails: %m", arg_command);
+                goto finish;
+        }
 
+        r = 0;
 finish:
         udev_builtin_exit();
         return r;
index 51dc041a29c39133c865e0f4fcf9051ef7ac37e3..687b927f721d1cff95c4d8e4830465e3aba0e4fc 100644 (file)
@@ -137,4 +137,4 @@ static int run(int argc, char *argv[]) {
         return udevadm_main(argc, argv);
 }
 
-DEFINE_MAIN_FUNCTION(run);
+DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);
index 81edb0ab7a154bf8c50f2a0b3a8f020407d70fb8..65e5f6cd91f6bd9504f7974fe4dfd245e91cc36a 100755 (executable)
@@ -396,6 +396,11 @@ EOF
 
     udevadm control --reload
 
+    # initialize partition table
+    for disk in {0..9}; do
+        echo 'label: gpt' | udevadm lock --device="${devices[$disk]}" sfdisk -q "${devices[$disk]}"
+    done
+
     # Delete the partitions, immediately recreate them, wait for udev to settle
     # down, and then check if we have any dangling symlinks in /dev/disk/. Rinse
     # and repeat.