diff --git a/bootloader/common.c b/bootloader/common.c index 07dd8120ed..705441357a 100644 --- a/bootloader/common.c +++ b/bootloader/common.c @@ -165,3 +165,17 @@ int load_raw_firmware(unsigned char* buf, char* firmware, int buffer_size) close(fd); return len; } + +#if (!defined(MISC_H) && CONFIG_PLATFORM & PLATFORM_HOSTED) +/* open but with a builtin printf for assembling the path */ +int open_pathfmt(char *buf, size_t size, int oflag, const char *pathfmt, ...) +{ + va_list ap; + va_start(ap, pathfmt); + vsnprintf(buf, size, pathfmt, ap); + va_end(ap); + if ((oflag & O_PATH) == O_PATH) + return -1; + return open(buf, oflag, 0666); +} +#endif