summaryrefslogtreecommitdiff
path: root/libudev/libudev-util-private.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2009-08-29 16:38:01 +0200
committerKay Sievers <kay.sievers@vrfy.org>2009-08-29 16:38:01 +0200
commit28da1a6186fcb55762b1649c6dd1e43545e0eb9a (patch)
tree31fd15957ef803bd321daf2e4fb8536fabdcf1db /libudev/libudev-util-private.c
parent72c0373f795a5c326e6bd0f7469601f492124d70 (diff)
util_create_path(): fix errno usage
Based on a patch from: Florian Zumbiehl <florz@florz.de>
Diffstat (limited to 'libudev/libudev-util-private.c')
-rw-r--r--libudev/libudev-util-private.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/libudev/libudev-util-private.c b/libudev/libudev-util-private.c
index b33ee79d6b..c86567159e 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)