X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Futil.c;h=3dbb5cdca7260f205997a2c936fcaf437c52dccc;hb=7c83ef53090441de11cc78d8d26dc337cd7ac475;hp=c0167826e1ba02ce47dba53c4b184743965e3c14;hpb=16e3b6e5615abcefc9e5bb9607e2804b64d19cc2;p=wimlib diff --git a/src/util.c b/src/util.c index c0167826..3dbb5cdc 100644 --- a/src/util.c +++ b/src/util.c @@ -108,6 +108,8 @@ WIMLIBAPI int wimlib_set_print_errors(bool show_error_messages) static const char *error_strings[] = { [WIMLIB_ERR_SUCCESS] = "Success", + [WIMLIB_ERR_ALREADY_LOCKED] + = "The WIM is already locked for writing", [WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE] = "Lookup table is compressed", [WIMLIB_ERR_DECOMPRESSION] @@ -180,6 +182,8 @@ static const char *error_strings[] = { = "Could not read the target of a symbolic link", [WIMLIB_ERR_RENAME] = "Could not rename a file", + [WIMLIB_ERR_REOPEN] + = "Could not re-open the WIM after overwriting it", [WIMLIB_ERR_RESOURCE_ORDER] = "The components of the WIM were arranged in an unexpected order", [WIMLIB_ERR_SPECIAL_FILE] @@ -377,17 +381,19 @@ ssize_t full_write(int fd, const void *buf, size_t n) static bool seeded = false; +static void seed_random() +{ + srand(time(NULL) * getpid()); + seeded = true; +} + /* Fills @n bytes pointed to by @p with random alphanumeric characters. */ void randomize_char_array_with_alnum(char p[], size_t n) { - int r; - - if (!seeded) { - srand(time(NULL)); - seeded = true; - } + if (!seeded) + seed_random(); while (n--) { - r = rand() % 62; + int r = rand() % 62; if (r < 26) *p++ = r + 'a'; else if (r < 52) @@ -400,10 +406,8 @@ void randomize_char_array_with_alnum(char p[], size_t n) /* Fills @n bytes pointer to by @p with random numbers. */ void randomize_byte_array(u8 *p, size_t n) { - if (!seeded) { - srand(time(NULL)); - seeded = true; - } + if (!seeded) + seed_random(); while (n--) *p++ = rand(); }