summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2012-12-12 12:27:05 +0100
committerKarel Zak2012-12-12 12:28:34 +0100
commit7317ba6d37f8e3600ddac6050f39c87b512c334c (patch)
tree84ee01c599a114c7447bde0c926f9a0006517400
parentswapon: don't care about xasprintf() return code (diff)
downloadkernel-qcow2-util-linux-7317ba6d37f8e3600ddac6050f39c87b512c334c.tar.gz
kernel-qcow2-util-linux-7317ba6d37f8e3600ddac6050f39c87b512c334c.tar.xz
kernel-qcow2-util-linux-7317ba6d37f8e3600ddac6050f39c87b512c334c.zip
libblkid: check mkdir(/run/blkid) return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--libblkid/src/save.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libblkid/src/save.c b/libblkid/src/save.c
index 46925ab2a..c94cc2a82 100644
--- a/libblkid/src/save.c
+++ b/libblkid/src/save.c
@@ -81,11 +81,16 @@ int blkid_flush_cache(blkid_cache cache)
BLKID_RUNTIME_DIR "/", sizeof(BLKID_RUNTIME_DIR)) == 0) {
/* default destination, create the directory if necessary */
- if (stat(BLKID_RUNTIME_DIR, &st) && errno == ENOENT) {
-
- mkdir(BLKID_RUNTIME_DIR, S_IWUSR|
- S_IRUSR|S_IRGRP|S_IROTH|
- S_IXUSR|S_IXGRP|S_IXOTH);
+ if (stat(BLKID_RUNTIME_DIR, &st)
+ && errno == ENOENT
+ && mkdir(BLKID_RUNTIME_DIR, S_IWUSR|
+ S_IRUSR|S_IRGRP|S_IROTH|
+ S_IXUSR|S_IXGRP|S_IXOTH) != 0
+ && errno != EEXIST) {
+ DBG(DEBUG_SAVE,
+ printf("can't create %s directory for cache file\n",
+ BLKID_RUNTIME_DIR));
+ return 0;
}
}