diff --git a/fsutils/mkgpt/mkgpt.c b/fsutils/mkgpt/mkgpt.c index 5b2c3d3f5..953b7fdd8 100644 --- a/fsutils/mkgpt/mkgpt.c +++ b/fsutils/mkgpt/mkgpt.c @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -128,12 +129,12 @@ static const uint8_t g_partition_type_swap[16] = static void get_uuid(FAR uint8_t *uuid) { - int fd; - fd = open("/dev/urandom", O_RDONLY); - if (fd > 0) + /* call getrandom to read /dev/urandom */ + + if (getrandom(uuid, 16, 0) < 0) { - read(fd, uuid, 16); - close(fd); + fprintf(stderr, "error read primary partition table\n"); + return; } }