#else
if (show_error_messages)
return WIMLIB_ERR_UNSUPPORTED;
+ else
+ return 0;
#endif
}
static const char *error_strings[] = {
[WIMLIB_ERR_SUCCESS]
= "Success",
+ [WIMLIB_ERR_ALREADY_LOCKED]
+ = "The WIM is already locked for writing",
+ [WIMLIB_ERR_CHAR_CONVERSION]
+ = "Failed to perform a conversion between UTF-8 and UTF-16LE",
[WIMLIB_ERR_COMPRESSED_LOOKUP_TABLE]
= "Lookup table is compressed",
[WIMLIB_ERR_DECOMPRESSION]
= "An entry in the WIM's lookup table is invalid",
[WIMLIB_ERR_INVALID_PARAM]
= "An invalid parameter was given",
+ [WIMLIB_ERR_INVALID_PART_NUMBER]
+ = "The part number or total parts of the WIM is invalid",
[WIMLIB_ERR_INVALID_RESOURCE_HASH]
= "The SHA1 message digest of a WIM resource did not match the expected value",
[WIMLIB_ERR_INVALID_RESOURCE_SIZE]
= "A resource entry in the WIM has an invalid size",
+ [WIMLIB_ERR_INVALID_UNMOUNT_MESSAGE]
+ = "The version of wimlib that has mounted a WIM image is incompatible with the "
+ "version being used to unmount it",
[WIMLIB_ERR_LINK]
= "Failed to create a hard or symbolic link when extracting "
"a file from the WIM",
= "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]
return orig_utf16_str;
}
-/* Write @n bytes from @buf to the file descriptor @fd, retrying on interupt and
- * on short writes.
- *
- * Returns short count and set errno on failure. */
-ssize_t full_write(int fd, const void *buf, size_t n)
+static bool seeded = false;
+
+static void seed_random()
{
- const char *p = buf;
- ssize_t ret;
- ssize_t total = 0;
-
- while (total != n) {
- ret = write(fd, p, n);
- if (ret < 0) {
- if (errno == EINTR)
- continue;
- else
- break;
- }
- total += ret;
- p += ret;
- }
- return total;
+ srand(time(NULL) * getpid());
+ seeded = true;
}
-
-static bool seeded = false;
-
/* 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)
/* 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();
}
return timeval_to_wim_timestamp(&tv);
}
-
+void wim_timestamp_to_str(u64 timestamp, char *buf, size_t len)
+{
+ struct tm tm;
+ time_t t = wim_timestamp_to_unix(timestamp);
+ gmtime_r(&t, &tm);
+ strftime(buf, len, "%a %b %d %H:%M:%S %Y UTC", &tm);
+}