diff --git a/qemu/include/qemu-common.h b/qemu/include/qemu-common.h index e2c3e3b1..29cc754a 100644 --- a/qemu/include/qemu-common.h +++ b/qemu/include/qemu-common.h @@ -98,6 +98,7 @@ int qemu_ftruncate64(int, int64_t); /* cutils.c */ void pstrcpy(char *buf, int buf_size, const char *str); +void strpadcpy(char *buf, int buf_size, const char *str, char pad); char *pstrcat(char *buf, int buf_size, const char *s); int strstart(const char *str, const char *val, const char **ptr); int qemu_fls(int i); diff --git a/qemu/util/cutils.c b/qemu/util/cutils.c index 0272f467..4190862e 100644 --- a/qemu/util/cutils.c +++ b/qemu/util/cutils.c @@ -27,6 +27,12 @@ #include #include +void strpadcpy(char *buf, int buf_size, const char *str, char pad) +{ + int len = qemu_strnlen(str, buf_size); + memcpy(buf, str, len); + memset(buf + len, pad, buf_size - len); +} void pstrcpy(char *buf, int buf_size, const char *str) {