summaryrefslogtreecommitdiff
path: root/libudev/libudev-util-private.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2009-10-28 11:37:20 +0100
committerKay Sievers <kay.sievers@vrfy.org>2009-10-28 11:37:20 +0100
commit6834a4429997480b3959c04ac9a74de7f29b3056 (patch)
treec6198d509a428aebf3af9f894b6d9c3cbddea329 /libudev/libudev-util-private.c
parentd316d27c17d8915f4c1356a1b95de1ea7fe8306b (diff)
break loops if util_create_path() returns error
Dangling symlinks in path components return -ENOENT. Do not retry to create the file in a loop in such case.
Diffstat (limited to 'libudev/libudev-util-private.c')
-rw-r--r--libudev/libudev-util-private.c25
1 files changed, 18 insertions, 7 deletions
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;
}