1 // Copyright 2016 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 FSCTL_SET_REPARSE_POINT = 0x000900A4
14 IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
15 IO_REPARSE_TAG_DEDUP = 0x80000013
17 SYMLINK_FLAG_RELATIVE = 1
20 // These structures are described
21 // in https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/ca069dad-ed16-42aa-b057-b6b207f447cc
22 // and https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/b41f1cbf-10df-4a47-98d4-1c52a833d913.
24 type REPARSE_DATA_BUFFER struct {
26 ReparseDataLength uint16
31 // REPARSE_DATA_BUFFER_HEADER is a common part of REPARSE_DATA_BUFFER structure.
32 type REPARSE_DATA_BUFFER_HEADER struct {
34 // The size, in bytes, of the reparse data that follows
35 // the common portion of the REPARSE_DATA_BUFFER element.
36 // This value is the length of the data starting at the
37 // SubstituteNameOffset field.
38 ReparseDataLength uint16
42 type SymbolicLinkReparseBuffer struct {
43 // The integer that contains the offset, in bytes,
44 // of the substitute name string in the PathBuffer array,
45 // computed as an offset from byte 0 of PathBuffer. Note that
46 // this offset must be divided by 2 to get the array index.
47 SubstituteNameOffset uint16
48 // The integer that contains the length, in bytes, of the
49 // substitute name string. If this string is null-terminated,
50 // SubstituteNameLength does not include the Unicode null character.
51 SubstituteNameLength uint16
52 // PrintNameOffset is similar to SubstituteNameOffset.
53 PrintNameOffset uint16
54 // PrintNameLength is similar to SubstituteNameLength.
55 PrintNameLength uint16
56 // Flags specifies whether the substitute name is a full path name or
57 // a path name relative to the directory containing the symbolic link.
62 // Path returns path stored in rb.
63 func (rb *SymbolicLinkReparseBuffer) Path() string {
64 n1 := rb.SubstituteNameOffset / 2
65 n2 := (rb.SubstituteNameOffset + rb.SubstituteNameLength) / 2
66 return syscall.UTF16ToString((*[0xffff]uint16)(unsafe.Pointer(&rb.PathBuffer[0]))[n1:n2:n2])
69 type MountPointReparseBuffer struct {
70 // The integer that contains the offset, in bytes,
71 // of the substitute name string in the PathBuffer array,
72 // computed as an offset from byte 0 of PathBuffer. Note that
73 // this offset must be divided by 2 to get the array index.
74 SubstituteNameOffset uint16
75 // The integer that contains the length, in bytes, of the
76 // substitute name string. If this string is null-terminated,
77 // SubstituteNameLength does not include the Unicode null character.
78 SubstituteNameLength uint16
79 // PrintNameOffset is similar to SubstituteNameOffset.
80 PrintNameOffset uint16
81 // PrintNameLength is similar to SubstituteNameLength.
82 PrintNameLength uint16
86 // Path returns path stored in rb.
87 func (rb *MountPointReparseBuffer) Path() string {
88 n1 := rb.SubstituteNameOffset / 2
89 n2 := (rb.SubstituteNameOffset + rb.SubstituteNameLength) / 2
90 return syscall.UTF16ToString((*[0xffff]uint16)(unsafe.Pointer(&rb.PathBuffer[0]))[n1:n2:n2])