chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
udev: move string copy functions to shared/
[elogind.git]
/
src
/
shared
/
mkdir.c
diff --git
a/src/shared/mkdir.c
b/src/shared/mkdir.c
index d654b632ebc69c497406df3a9ec7461404202327..0e51b64f69331d21228b2dcc1621fb29df18f274 100644
(file)
--- a/
src/shared/mkdir.c
+++ b/
src/shared/mkdir.c
@@
-115,6
+115,13
@@
int mkdir_parents_label(const char *path, mode_t mode) {
return makedir_parents(path, mode, true);
}
return makedir_parents(path, mode, true);
}
+static int is_dir(const char* path) {
+ struct stat st;
+ if (stat(path, &st) < 0)
+ return -errno;
+ return S_ISDIR(st.st_mode);
+}
+
static int makedir_p(const char *path, mode_t mode, bool apply) {
int r;
static int makedir_p(const char *path, mode_t mode, bool apply) {
int r;
@@
-124,7
+131,8
@@
static int makedir_p(const char *path, mode_t mode, bool apply) {
if (r < 0)
return r;
if (r < 0)
return r;
- if (label_mkdir(path, mode, apply) < 0 && errno != EEXIST)
+ r = label_mkdir(path, mode, apply);
+ if (r < 0 && (errno != EEXIST || is_dir(path) <= 0))
return -errno;
return 0;
return -errno;
return 0;