From 28da1a6186fcb55762b1649c6dd1e43545e0eb9a Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sat, 29 Aug 2009 16:38:01 +0200 Subject: [PATCH] util_create_path(): fix errno usage Based on a patch from: Florian Zumbiehl --- libudev/libudev-util-private.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c index b33ee79d..c8656715 100644 --- a/libudev/libudev-util-private.c +++ b/libudev/libudev-util-private.c @@ -30,7 +30,7 @@ int util_create_path(struct udev *udev, const char *path) char p[UTIL_PATH_SIZE]; char *pos; struct stat stats; - int ret; + int err; util_strscpy(p, sizeof(p), path); pos = strrchr(p, '/'); @@ -50,15 +50,12 @@ int util_create_path(struct udev *udev, const char *path) dbg(udev, "mkdir '%s'\n", p); udev_selinux_setfscreatecon(udev, p, S_IFDIR|0755); - ret = mkdir(p, 0755); - udev_selinux_resetfscreatecon(udev); - if (ret == 0) - return 0; - - if (errno == EEXIST) + err = mkdir(p, 0755); + if (err != 0 && errno == EEXIST) if (stat(p, &stats) == 0 && (stats.st_mode & S_IFMT) == S_IFDIR) - return 0; - return -1; + err = 0; + udev_selinux_resetfscreatecon(udev); + return err; } int util_delete_path(struct udev *udev, const char *path) -- 2.39.5