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,
31 .udhcpc6 = HOST_PROG_UDHCPC6,
32 .vgscan = HOST_PROG_VGSCAN,
33 .vgchange = HOST_PROG_VGCHANGE,
34 .pb_plugin = HOST_PROG_PB_PLUGIN,
35 .pb_exec = HOST_PROG_PB_EXEC,
37 .scsi_rescan = HOST_PROG_SCSI_RESCAN,
38 .dmidecode = HOST_PROG_DMIDECODE,
42 #define TFTP_TYPE TFTP_TYPE_UNKNOWN
45 enum tftp_type tftp_type = TFTP_TYPE;
47 int pb_mkdir_recursive(const char *dir)
56 if (!stat(dir, &statbuf)) {
57 if (!S_ISDIR(statbuf.st_mode)) {
58 pb_log("%s: %s exists, but isn't a directory\n",
65 str = talloc_strdup(NULL, dir);
66 sep = strchr(*str == '/' ? str + 1 : str, '/');
72 /* terminate the path at sep */
76 if (mkdir(str, mode) && errno != EEXIST) {
77 pb_log("mkdir(%s): %s\n", str, strerror(errno));
85 /* reset dir to the full path */
87 sep = strchr(sep + 1, '/');
95 int pb_rmdir_recursive(const char *base, const char *dir)
99 /* sanity check: make sure that dir is within base */
100 if (strncmp(base, dir, strlen(base)))
103 cur = talloc_strdup(NULL, dir);
105 while (strcmp(base, cur)) {
109 /* null-terminate at the last slash */
110 pos = strrchr(cur, '/');