@@ -21,6 +21,7 @@
#include <dirent.h>
#include <limits.h>
#include <time.h>
+#include <libgen.h>
#include "swupdate.h"
#include "util.h"
@@ -181,6 +182,24 @@ int openfileoutput(const char *filename)
return fdout;
}
+int mkpath(char *dir, mode_t mode)
+{
+ if (!dir) {
+ return -EINVAL;
+ }
+
+ if (strlen(dir) == 1 && dir[0] == '/')
+ return 0;
+
+ mkpath(dirname(strdupa(dir)), mode);
+
+ if (mkdir(dir, mode) == -1) {
+ if (errno != EEXIST)
+ return 1;
+ }
+ return 0;
+}
+
/*
* This function is strict bounded with the hardware
* It reads some GPIOs to get the hardware revision
@@ -45,24 +45,6 @@ static int install_raw_image(struct img_type *img,
return ret;
}
-static int mkpath(char *dir, mode_t mode)
-{
- if (!dir) {
- return -EINVAL;
- }
-
- if (strlen(dir) == 1 && dir[0] == '/')
- return 0;
-
- mkpath(dirname(strdupa(dir)), mode);
-
- if (mkdir(dir, mode) == -1) {
- if (errno != EEXIST)
- return 1;
- }
- return 0;
-}
-
static int install_raw_file(struct img_type *img,
void __attribute__ ((__unused__)) *data)
{
@@ -168,6 +168,7 @@ int extract_sw_description(int fd, const char *descfile, off_t *offs);
off_t extract_next_file(int fd, int fdout, off_t start, int compressed,
int encrypted, unsigned char *hash);
int openfileoutput(const char *filename);
+int mkpath(char *dir, mode_t mode);
int register_notifier(notifier client);
void notify(RECOVERY_STATUS status, int error, int level, const char *msg);
Shift mkpath() from raw_handler.c to util.c so that other parts of SWUpdate may use it as well. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- core/util.c | 19 +++++++++++++++++++ handlers/raw_handler.c | 18 ------------------ include/util.h | 1 + 3 files changed, 20 insertions(+), 18 deletions(-)