]> wimlib.net Git - wimlib/blobdiff - src/util.c
Only access struct stat.mtim if available
[wimlib] / src / util.c
index c0167826e1ba02ce47dba53c4b184743965e3c14..3dbb5cdca7260f205997a2c936fcaf437c52dccc 100644 (file)
@@ -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();
 }