aboutsummaryrefslogtreecommitdiff
path: root/brightnessctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'brightnessctl.c')
-rw-r--r--brightnessctl.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/brightnessctl.c b/brightnessctl.c
index 86a0e21..3f7cfc1 100644
--- a/brightnessctl.c
+++ b/brightnessctl.c
@@ -395,8 +395,11 @@ int save_device_data(struct device *dev) {
if (stat(c_path, &sb)) {
if (errno != ENOENT)
goto fail;
+ errno = 0;
if (mkdir(c_path, 0777))
goto fail;
+ if (stat(c_path, &sb))
+ goto fail;
}
if (!S_ISDIR(sb.st_mode))
goto fail;
@@ -442,9 +445,12 @@ static int ensure_run_dir() {
if (stat(run_dir, &sb)) {
if (errno != ENOENT)
return 0;
+ errno = 0;
if (mkdir(run_dir, 0777)) {
return 0;
}
+ if (stat(run_dir, &sb))
+ return 0;
}
return S_ISDIR(sb.st_mode);
}