summaryrefslogtreecommitdiff
path: root/libudev
diff options
context:
space:
mode:
Diffstat (limited to 'libudev')
-rw-r--r--libudev/libudev-queue-private.c8
-rw-r--r--libudev/libudev-util-private.c25
2 files changed, 23 insertions, 10 deletions
diff --git a/libudev/libudev-queue-private.c b/libudev/libudev-queue-private.c
index 4e67a1f9d0..37de67a3d4 100644
--- a/libudev/libudev-queue-private.c
+++ b/libudev/libudev-queue-private.c
@@ -410,13 +410,15 @@ static void update_failed(struct udev_queue_export *udev_queue_export,
/* record event in the failed directory */
udev_queue_export->failed_count++;
do {
- util_create_path(udev, filename);
+ err = util_create_path(udev, filename);
+ if (err != 0 && err != -ENOENT)
+ break;
udev_selinux_setfscreatecon(udev, filename, S_IFLNK);
err = symlink(udev_device_get_devpath(udev_device), filename);
if (err != 0)
- err = errno;
+ err = -errno;
udev_selinux_resetfscreatecon(udev);
- } while (err == ENOENT);
+ } while (err == -ENOENT);
break;
case DEVICE_QUEUED:
diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c
index 585dfc6a41..5b3e337643 100644
--- a/libudev/libudev-util-private.c
+++ b/libudev/libudev-util-private.c
@@ -43,18 +43,29 @@ int util_create_path(struct udev *udev, const char *path)
pos[0] = '\0';
dbg(udev, "stat '%s'\n", p);
- if (stat(p, &stats) == 0 && (stats.st_mode & S_IFMT) == S_IFDIR)
- return 0;
+ if (stat(p, &stats) == 0) {
+ if ((stats.st_mode & S_IFMT) == S_IFDIR)
+ return 0;
+ else
+ return -ENOTDIR;
+ }
- if (util_create_path(udev, p) != 0)
- return -1;
+ err = util_create_path(udev, p);
+ if (err != 0)
+ return err;
dbg(udev, "mkdir '%s'\n", p);
udev_selinux_setfscreatecon(udev, p, S_IFDIR|0755);
err = mkdir(p, 0755);
- if (err != 0 && errno == EEXIST)
- if (stat(p, &stats) == 0 && (stats.st_mode & S_IFMT) == S_IFDIR)
- err = 0;
+ if (err != 0) {
+ err = -errno;
+ if (err == -EEXIST && stat(p, &stats) == 0) {
+ if ((stats.st_mode & S_IFMT) == S_IFDIR)
+ err = 0;
+ else
+ err = -ENOTDIR;
+ }
+ }
udev_selinux_resetfscreatecon(udev);
return err;
}