*/
/*
- * Copyright (C) 2015-2018 Eric Biggers
+ * Copyright 2015-2023 Eric Biggers
*
* This file is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
static inline bool
is_valid_filename_char(utf16lechar c)
{
-#ifdef __WIN32__
+#ifdef _WIN32
return is_valid_windows_filename_char(c);
#else
return c != cpu_to_le16('\0') && c != cpu_to_le16('/');
/* Generate the characters in the name. */
for (int i = 0; i < len; i++) {
do {
- name[i] = rand16();
+ name[i] = cpu_to_le16(rand16());
} while (!is_valid_filename_char(name[i]));
}
static bool
am_root(void)
{
-#ifdef __WIN32__
+#ifdef _WIN32
return false;
#else
return (getuid() == 0);
static u32
generate_uid(void)
{
-#ifdef __WIN32__
+#ifdef _WIN32
return 0;
#else
if (am_root())
static u32
generate_gid(void)
{
-#ifdef __WIN32__
+#ifdef _WIN32
return 0;
#else
if (am_root())
#endif
}
-#ifdef __WIN32__
+#ifdef _WIN32
# ifndef S_IFLNK
# define S_IFLNK 0120000
# endif
struct wim_xattr_entry *entry = (void *)entries;
size_t entries_size;
struct wimlib_unix_data unix_data;
+#ifdef _WIN32
+ const char *prefix = "";
+#else
const char *prefix = "user.";
+#endif
static const char capability_name[] = "security.capability";
bool generated_capability_xattr = false;
int value_len = rand32() % 64;
u8 *p;
+ #ifdef _WIN32
+ if (value_len == 0)
+ value_len++;
+ #endif
+
entry->value_len = cpu_to_le16(value_len);
entry->flags = 0;
entry->name_len = strlen(prefix) + name_len;
p = mempcpy(entry->name, prefix, strlen(prefix));
- *p++ = 'a' + i;
+ *p++ = 'A' + i;
for (int j = 1; j < name_len; j++) {
do {
+ #ifdef _WIN32
+ *p = 'A' + rand8() % 26;
+ #else
*p = rand8();
+ #endif
} while (*p == '\0');
p++;
}
ret = add_random_data_stream(inode, ctx, stream_name);
if (ret)
return ret;
- stream_name[0] += cpu_to_le16(1);
+ stream_name[0] =
+ cpu_to_le16(le16_to_cpu(stream_name[0]) + 1);
}
}
* within the same directory. */
hash = 0;
for (const utf16lechar *p = name; *p; p++)
- hash = (hash * 31) + *p;
+ hash = (hash * 31) + le16_to_cpu(*p);
FREE(child->d_short_name);
child->d_short_name = memdup(name, (name_len + 1) * 2);
child->d_short_name_nbytes = name_len * 2;
if (!xattrs1 && !xattrs2) {
return 0;
} else if (xattrs1 && !xattrs2) {
- if (cmp_flags & (WIMLIB_CMP_FLAG_NTFS_3G_MODE |
- WIMLIB_CMP_FLAG_WINDOWS_MODE))
+ if (cmp_flags & WIMLIB_CMP_FLAG_NTFS_3G_MODE)
return 0;
ERROR("%"TS" unexpectedly lost its xattrs",
inode_any_full_path(inode1));