if (flags & O_CREAT) {
snprintf(fname, PATH_MAX, "%s%s", node_path, key_dir);
- mkdir(fname, 0755);
+ if (mkdir(fname, 0755) != 0)
+ l_error("Failed to create dir(%d): %s", errno, fname);
}
snprintf(fname, PATH_MAX, "%s%s/%3.3x", node_path, key_dir, idx);
snprintf(key_file, PATH_MAX, "%s%s", node_path, dev_key_dir);
- mkdir(key_file, 0755);
+ if (mkdir(key_file, 0755) != 0)
+ l_error("Failed to create dir(%d): %s", errno, key_file);
for (i = 0; i < count; i++) {
snprintf(key_file, PATH_MAX, "%s%s/%4.4x", node_path,
buf[0] = 0;
memcpy(buf + 1, pvt->unique_name, size + 1);
- send(pvt->fd, buf, size + 2, MSG_DONTWAIT);
+ if (send(pvt->fd, buf, size + 2, MSG_DONTWAIT) < 0)
+ l_error("Failed to send(%d)", errno);
}
return true;
static void send_pkt(struct mesh_io_private *pvt, struct tx_pkt *tx,
uint16_t interval)
{
- send(pvt->fd, tx->pkt, tx->len, MSG_DONTWAIT);
+ if (send(pvt->fd, tx->pkt, tx->len, MSG_DONTWAIT) < 0)
+ l_error("Failed to send(%d)", errno);
if (tx->delete) {
l_queue_remove_if(pvt->tx_pkts, simple_match, tx);
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
+#include <errno.h>
#include <sys/stat.h>
iv_index);
dir = opendir(src_file);
- if (!dir)
- mkdir(src_file, 0755);
- else
+ if (!dir) {
+ if (mkdir(src_file, 0755) != 0)
+ l_error("Failed to create dir: %s", src_file);
+ } else
closedir(dir);
snprintf(src_file, PATH_MAX, "%s%s/%8.8x/%4.4x", node_path, rpl_dir,
iv_index--;
snprintf(src_file, PATH_MAX, "%s%s/%8.8x/%4.4x", node_path, rpl_dir,
iv_index, src);
- remove(src_file);
-
+ if (remove(src_file) < 0)
+ l_error("Failed to remove(%d): %s", errno, src_file);
return result;
}
if (entry->d_type == DT_DIR && entry->d_name[0] != '.') {
snprintf(rpl_path, PATH_MAX, "%s%s/%s/%4.4x",
node_path, rpl_dir, entry->d_name, src);
- remove(rpl_path);
+ if (remove(rpl_path) < 0)
+ l_error("Failed to remove(%d): %s", errno,
+ rpl_path);
}
}
/* Make sure path exists */
snprintf(path, PATH_MAX, "%s%s", node_path, rpl_dir);
- mkdir(path, 0755);
+ if (mkdir(path, 0755) != 0)
+ l_error("Failed to create dir(%d): %s", errno, path);
dir = opendir(path);
if (!dir)
return false;
snprintf(path, PATH_MAX, "%s%s", node_path, rpl_dir);
- mkdir(path, 0755);
+ if (mkdir(path, 0755) != 0)
+ l_error("Failed to create dir(%d): %s", errno, path);
return true;
}
#include <dirent.h>
+#include <errno.h>
#include <ftw.h>
#include <unistd.h>
#include <stdio.h>
}
strncat(dir, prev + 1, next - prev);
- mkdir(dir, 0755);
+ if (mkdir(dir, 0755) != 0)
+ l_error("Failed to create dir(%d): %s", errno, dir);
prev = next;
}
- mkdir(dir_name, 0755);
+ if (mkdir(dir_name, 0755) != 0)
+ l_error("Failed to create dir(%d): %s", errno, dir_name);
return 0;
}
case FTW_SL:
default:
- remove(fpath);
+ if (remove(fpath) < 0)
+ l_error("Failed to remove(%d): %s", errno, fpath);
+
l_debug("RM %s", fpath);
break;
}