Commit 4bbe5e6e by Peter Pettersson

win32: name the dummy union in GIT_REPARSE_DATA_BUFFER

Instead of buf->"typeofbuffer"ReparseBuffer the members will be
referenced with buf->ReparseBuffer."typeofbuffer"

https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_reparse_data_buffer?redirectedfrom=MSDN
calls the union DUMMYUNIONNAME but that looks a bit cluttered.
parent b0189582
......@@ -381,14 +381,14 @@ int git_win32_path_readlink_w(git_win32_path dest, const git_win32_path path)
switch (reparse_buf->ReparseTag) {
case IO_REPARSE_TAG_SYMLINK:
target = reparse_buf->SymbolicLinkReparseBuffer.PathBuffer +
(reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(WCHAR));
target_len = reparse_buf->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
target = reparse_buf->ReparseBuffer.SymbolicLink.PathBuffer +
(reparse_buf->ReparseBuffer.SymbolicLink.SubstituteNameOffset / sizeof(WCHAR));
target_len = reparse_buf->ReparseBuffer.SymbolicLink.SubstituteNameLength / sizeof(WCHAR);
break;
case IO_REPARSE_TAG_MOUNT_POINT:
target = reparse_buf->MountPointReparseBuffer.PathBuffer +
(reparse_buf->MountPointReparseBuffer.SubstituteNameOffset / sizeof(WCHAR));
target_len = reparse_buf->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
target = reparse_buf->ReparseBuffer.MountPoint.PathBuffer +
(reparse_buf->ReparseBuffer.MountPoint.SubstituteNameOffset / sizeof(WCHAR));
target_len = reparse_buf->ReparseBuffer.MountPoint.SubstituteNameLength / sizeof(WCHAR);
break;
default:
errno = EINVAL;
......
......@@ -26,18 +26,18 @@ typedef struct _GIT_REPARSE_DATA_BUFFER {
USHORT PrintNameLength;
ULONG Flags;
WCHAR PathBuffer[1];
} SymbolicLinkReparseBuffer;
} SymbolicLink;
struct {
USHORT SubstituteNameOffset;
USHORT SubstituteNameLength;
USHORT PrintNameOffset;
USHORT PrintNameLength;
WCHAR PathBuffer[1];
} MountPointReparseBuffer;
} MountPoint;
struct {
UCHAR DataBuffer[1];
} GenericReparseBuffer;
};
} Generic;
} ReparseBuffer;
} GIT_REPARSE_DATA_BUFFER;
#define REPARSE_DATA_HEADER_SIZE 8
......
......@@ -123,7 +123,7 @@ static void do_junction(const char *old, const char *new)
reparse_buf = LocalAlloc(LMEM_FIXED|LMEM_ZEROINIT, reparse_buflen);
cl_assert(reparse_buf);
subst_utf16 = reparse_buf->MountPointReparseBuffer.PathBuffer;
subst_utf16 = reparse_buf->ReparseBuffer.MountPoint.PathBuffer;
print_utf16 = subst_utf16 + subst_utf16_len + 1;
ret = git__utf8_to_16(subst_utf16, subst_utf16_len + 1,
......@@ -135,10 +135,10 @@ static void do_junction(const char *old, const char *new)
cl_assert_equal_i(print_utf16_len, ret);
reparse_buf->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
reparse_buf->MountPointReparseBuffer.SubstituteNameOffset = 0;
reparse_buf->MountPointReparseBuffer.SubstituteNameLength = subst_byte_len;
reparse_buf->MountPointReparseBuffer.PrintNameOffset = (USHORT)(subst_byte_len + sizeof(WCHAR));
reparse_buf->MountPointReparseBuffer.PrintNameLength = print_byte_len;
reparse_buf->ReparseBuffer.MountPoint.SubstituteNameOffset = 0;
reparse_buf->ReparseBuffer.MountPoint.SubstituteNameLength = subst_byte_len;
reparse_buf->ReparseBuffer.MountPoint.PrintNameOffset = (USHORT)(subst_byte_len + sizeof(WCHAR));
reparse_buf->ReparseBuffer.MountPoint.PrintNameLength = print_byte_len;
reparse_buf->ReparseDataLength = reparse_buflen - REPARSE_DATA_HEADER_SIZE;
cl_win32_pass(DeviceIoControl(handle, FSCTL_SET_REPARSE_POINT,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment