4295f9
From 18d2fb228bc155fc357262ec2dc5713318bab453 Mon Sep 17 00:00:00 2001
4295f9
From: Yu Watanabe <watanabe.yu+github@gmail.com>
4295f9
Date: Wed, 1 Sep 2021 04:14:42 +0900
4295f9
Subject: [PATCH] udev-node: stack directory must exist when adding device node
4295f9
 symlink
4295f9
4295f9
(cherry picked from commit 46070dbf26435ba0def099121f46a6253f3f19b6)
4295f9
4295f9
Related: #1977994
4295f9
---
4295f9
 src/udev/udev-node.c | 11 ++++++-----
4295f9
 1 file changed, 6 insertions(+), 5 deletions(-)
4295f9
4295f9
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
4295f9
index 7cc9ee3670..4496a2bd9b 100644
4295f9
--- a/src/udev/udev-node.c
4295f9
+++ b/src/udev/udev-node.c
4295f9
@@ -161,12 +161,13 @@ static int link_find_prioritized(sd_device *dev, bool add, const char *stackdir,
4295f9
 
4295f9
         dir = opendir(stackdir);
4295f9
         if (!dir) {
4295f9
-                if (errno == ENOENT) {
4295f9
-                        *ret = TAKE_PTR(target);
4295f9
-                        return !!*ret;
4295f9
-                }
4295f9
+                if (add) /* The stack directory must exist. */
4295f9
+                        return -errno;
4295f9
+                if (errno != ENOENT)
4295f9
+                        return -errno;
4295f9
 
4295f9
-                return -errno;
4295f9
+                *ret = NULL;
4295f9
+                return 0;
4295f9
         }
4295f9
 
4295f9
         r = device_get_device_id(dev, &id;;