github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/syscall/windows/reparse_windows.go (about)

     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.
     4  
     5  package windows
     6  
     7  // Reparse tag values are taken from
     8  // https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/c8e77b37-3909-4fe6-a4ea-2b9d423b1ee4
     9  const (
    10  	FSCTL_SET_REPARSE_POINT    = 0x000900A4
    11  	IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
    12  	IO_REPARSE_TAG_DEDUP       = 0x80000013
    13  	IO_REPARSE_TAG_AF_UNIX     = 0x80000023
    14  
    15  	SYMLINK_FLAG_RELATIVE = 1
    16  )
    17  
    18  type REPARSE_DATA_BUFFER struct {
    19  	ReparseTag        uint32
    20  	ReparseDataLength uint16
    21  	Reserved          uint16
    22  	DUMMYUNIONNAME    byte
    23  }
    24  
    25  // REPARSE_DATA_BUFFER_HEADER is a common part of REPARSE_DATA_BUFFER structure.
    26  type REPARSE_DATA_BUFFER_HEADER struct {
    27  	ReparseTag uint32
    28  	// The size, in bytes, of the reparse data that follows
    29  	// the common portion of the REPARSE_DATA_BUFFER element.
    30  	// This value is the length of the data starting at the
    31  	// SubstituteNameOffset field.
    32  	ReparseDataLength uint16
    33  	Reserved          uint16
    34  }
    35  
    36  type SymbolicLinkReparseBuffer struct {
    37  	// The integer that contains the offset, in bytes,
    38  	// of the substitute name string in the PathBuffer array,
    39  	// computed as an offset from byte 0 of PathBuffer. Note that
    40  	// this offset must be divided by 2 to get the array index.
    41  	SubstituteNameOffset uint16
    42  	// The integer that contains the length, in bytes, of the
    43  	// substitute name string. If this string is null-terminated,
    44  	// SubstituteNameLength does not include the Unicode null character.
    45  	SubstituteNameLength uint16
    46  	// PrintNameOffset is similar to SubstituteNameOffset.
    47  	PrintNameOffset uint16
    48  	// PrintNameLength is similar to SubstituteNameLength.
    49  	PrintNameLength uint16
    50  	// Flags specifies whether the substitute name is a full path name or
    51  	// a path name relative to the directory containing the symbolic link.
    52  	Flags      uint32
    53  	PathBuffer [1]uint16
    54  }
    55  
    56  // Path returns path stored in rb.
    57  func (rb *SymbolicLinkReparseBuffer) Path() string
    58  
    59  type MountPointReparseBuffer struct {
    60  	// The integer that contains the offset, in bytes,
    61  	// of the substitute name string in the PathBuffer array,
    62  	// computed as an offset from byte 0 of PathBuffer. Note that
    63  	// this offset must be divided by 2 to get the array index.
    64  	SubstituteNameOffset uint16
    65  	// The integer that contains the length, in bytes, of the
    66  	// substitute name string. If this string is null-terminated,
    67  	// SubstituteNameLength does not include the Unicode null character.
    68  	SubstituteNameLength uint16
    69  	// PrintNameOffset is similar to SubstituteNameOffset.
    70  	PrintNameOffset uint16
    71  	// PrintNameLength is similar to SubstituteNameLength.
    72  	PrintNameLength uint16
    73  	PathBuffer      [1]uint16
    74  }
    75  
    76  // Path returns path stored in rb.
    77  func (rb *MountPointReparseBuffer) Path() string