2 #if defined(HAVE_CONFIG_H)
12 #include <sys/types.h>
16 #include <talloc/talloc.h>
19 const struct pb_system_apps pb_system_apps = {
22 .kexec = HOST_PROG_KEXEC,
23 .mount = HOST_PROG_MOUNT,
24 .shutdown = HOST_PROG_SHUTDOWN,
25 .sftp = HOST_PROG_SFTP,
26 .tftp = HOST_PROG_TFTP,
27 .umount = HOST_PROG_UMOUNT,
28 .wget = HOST_PROG_WGET,
30 .udhcpc = HOST_PROG_UDHCPC,
34 #define TFTP_TYPE TFTP_TYPE_UNKNOWN
37 enum tftp_type tftp_type = TFTP_TYPE;
39 int pb_mkdir_recursive(const char *dir)
48 if (!stat(dir, &statbuf)) {
49 if (!S_ISDIR(statbuf.st_mode)) {
50 pb_log("%s: %s exists, but isn't a directory\n",
57 str = talloc_strdup(NULL, dir);
58 sep = strchr(*str == '/' ? str + 1 : str, '/');
64 /* terminate the path at sep */
68 if (mkdir(str, mode) && errno != EEXIST) {
69 pb_log("mkdir(%s): %s\n", str, strerror(errno));
77 /* reset dir to the full path */
79 sep = strchr(sep + 1, '/');
87 int pb_rmdir_recursive(const char *base, const char *dir)
91 /* sanity check: make sure that dir is within base */
92 if (strncmp(base, dir, strlen(base)))
95 cur = talloc_strdup(NULL, dir);
97 while (strcmp(base, cur)) {
101 /* null-terminate at the last slash */
102 pos = strrchr(cur, '/');