Documentation
¶
Index ¶
- Constants
- Variables
- func MarshalBinary(fields ...interface{}) ([]byte, error)
- func ProtocolError(err error) error
- func UnmarshalBinary(data []byte, fields ...interface{}) error
- type ArchiveHandler
- type AttrV2
- type Capability
- type File
- type FileHandler
- type FileName
- type FileNameV3
- type Header
- type Packet
- type Reply
- type ReplyClose
- type ReplyCreateSessionV4
- type ReplyDestroySessionV4
- type ReplyGetattrV2
- type ReplyOpen
- type ReplyOpenV3
- type ReplyReadV3
- type ReplySetattrV2
- type ReplyWriteV3
- type Request
- type RequestClose
- type RequestCreateSessionV4
- type RequestDestroySessionV4
- type RequestGetattrV2
- type RequestOpen
- type RequestOpenV3
- type RequestReadV3
- type RequestSetattrV2
- type RequestWriteV3
- type Server
- func (s *Server) Close(p *Packet) (interface{}, error)
- func (s *Server) CreateSessionV4(p *Packet) (interface{}, error)
- func (s *Server) DestroySessionV4(p *Packet) (interface{}, error)
- func (s *Server) Dispatch(packet []byte) ([]byte, error)
- func (s *Server) GetattrV2(p *Packet) (interface{}, error)
- func (s *Server) Open(p *Packet) (interface{}, error)
- func (s *Server) OpenFile(name string, mode int32) (File, error)
- func (s *Server) OpenV3(p *Packet) (interface{}, error)
- func (s *Server) ReadV3(p *Packet) (interface{}, error)
- func (s *Server) RegisterFileHandler(scheme string, handler FileHandler)
- func (s *Server) SetattrV2(p *Packet) (interface{}, error)
- func (s *Server) Stat(name string) (os.FileInfo, error)
- func (s *Server) WriteV3(p *Packet) (interface{}, error)
- type Status
Constants ¶
const ( OpOpen = iota /* Open file */ OpRead /* Read from file */ OpWrite /* Write to file */ OpClose /* Close file */ OpSearchOpen /* Start new search */ OpSearchRead /* Get next search response */ OpSearchClose /* End a search */ OpGetattr /* Get file attributes */ OpSetattr /* Set file attributes */ OpCreateDir /* Create new directory */ OpDeleteFile /* Delete a file */ OpDeleteDir /* Delete a directory */ OpRename /* Rename a file or directory */ OpQueryVolumeInfo /* Query volume information */ OpOpenV2 /* Open file */ OpGetattrV2 /* Get file attributes */ OpSetattrV2 /* Set file attributes */ OpSearchReadV2 /* Get next search response */ OpCreateSymlink /* Create a symlink */ OpServerLockChange /* Change the oplock on a file */ OpCreateDirV2 /* Create a directory */ OpDeleteFileV2 /* Delete a file */ OpDeleteDirV2 /* Delete a directory */ OpRenameV2 /* Rename a file or directory */ OpOpenV3 /* Open file */ OpReadV3 /* Read from file */ OpWriteV3 /* Write to file */ OpCloseV3 /* Close file */ OpSearchOpenV3 /* Start new search */ OpSearchReadV3 /* Read V3 directory entries */ OpSearchCloseV3 /* End a search */ OpGetattrV3 /* Get file attributes */ OpSetattrV3 /* Set file attributes */ OpCreateDirV3 /* Create new directory */ OpDeleteFileV3 /* Delete a file */ OpDeleteDirV3 /* Delete a directory */ OpRenameV3 /* Rename a file or directory */ OpQueryVolumeInfoV3 /* Query volume information */ OpCreateSymlinkV3 /* Create a symlink */ OpServerLockChangeV3 /* Change the oplock on a file */ OpWriteWin32StreamV3 /* Write WIN32_STREAM_ID format data to file */ OpCreateSessionV4 /* Create a session and return host capabilities. */ OpDestroySessionV4 /* Destroy/close session. */ OpReadFastV4 /* Read */ OpWriteFastV4 /* Write */ OpSetWatchV4 /* Start monitoring directory changes. */ OpRemoveWatchV4 /* Stop monitoring directory changes. */ OpNotifyV4 /* Notification for a directory change event. */ OpSearchReadV4 /* Read V4 directory entries. */ OpOpenV4 /* Open file */ OpEnumerateStreamsV4 /* Enumerate alternative named streams for a file. */ OpGetattrV4 /* Get file attributes */ OpSetattrV4 /* Set file attributes */ OpDeleteV4 /* Delete a file or a directory */ OpLinkmoveV4 /* Rename/move/create hard link. */ OpFsctlV4 /* Sending FS control requests. */ OpAccessCheckV4 /* Access check. */ OpFsyncV4 /* Flush all cached data to the disk. */ OpQueryVolumeInfoV4 /* Query volume information. */ OpOplockAcquireV4 /* Acquire OPLOCK. */ OpOplockBreakV4 /* Break or downgrade OPLOCK. */ OpLockByteRangeV4 /* Acquire byte range lock. */ OpUnlockByteRangeV4 /* Release byte range lock. */ OpQueryEasV4 /* Query extended attributes. */ OpSetEasV4 /* Add or modify extended attributes. */ OpNewHeader = 0xff /* Header op, must be unique, distinguishes packet headers. */ )
Opcodes for server operations as defined in hgfsProto.h
const ( StatusSuccess = iota StatusNoSuchFileOrDir StatusInvalidHandle StatusOperationNotPermitted StatusFileExists StatusNotDirectory StatusDirNotEmpty StatusProtocolError StatusAccessDenied StatusInvalidName StatusGenericError StatusSharingViolation StatusNoSpace StatusOperationNotSupported StatusNameTooLong StatusInvalidParameter StatusNotSameDevice StatusStaleSession StatusTooManySessions StatusTransportError )
Status codes
const ( AttrValidType = 1 << iota AttrValidSize AttrValidCreateTime AttrValidAccessTime AttrValidWriteTime AttrValidChangeTime AttrValidSpecialPerms AttrValidOwnerPerms AttrValidGroupPerms AttrValidOtherPerms AttrValidFlags AttrValidAllocationSize AttrValidUserID AttrValidGroupID AttrValidFileID AttrValidVolID AttrValidNonStaticFileID AttrValidEffectivePerms AttrValidExtendAttrSize AttrValidReparsePoint AttrValidShortName )
Flags for attr mask
const ( PacketFlagRequest = 1 << iota PacketFlagReply PacketFlagInfoExterror PacketFlagValidFlags = 0x7 )
Packet flags
const ( FileTypeRegular = iota FileTypeDirectory FileTypeSymlink )
FileType
const ( OpenModeReadOnly = iota OpenModeWriteOnly OpenModeReadWrite OpenModeAccmodes )
OpenMode
const ( Open = iota OpenEmpty OpenCreate OpenCreateSafe OpenCreateEmpty )
OpenFlags
const ( PermRead = 4 PermWrite = 2 PermExec = 1 )
Permissions
const ( LockNone = iota LockOpportunistic LockExclusive LockBatch LockLease )
Lock type
const HeaderVersion = 0x1
HeaderVersion for HGFS protocol version 4
const LargePacketMax = 0xf800 // HGFS_LARGE_PACKET_MAX
LargePacketMax is maximum size of an hgfs packet
const (
WriteAppend = 1
)
Write flags
Variables ¶
var ArchiveScheme = "archive"
ArchiveScheme is the default scheme used to register the archive FileHandler
var ( // Trace enables hgfs packet tracing Trace = false )
Functions ¶
func MarshalBinary ¶
MarshalBinary is a wrapper around binary.Write
func ProtocolError ¶
ProtocolError wraps the given error as a Status type
func UnmarshalBinary ¶
UnmarshalBinary is a wrapper around binary.Read
Types ¶
type ArchiveHandler ¶
type ArchiveHandler struct {
Read func(*url.URL, *tar.Reader) error
Write func(*url.URL, *tar.Writer) error
}
ArchiveHandler implements a FileHandler for transferring directories.
type AttrV2 ¶
type AttrV2 struct {
Mask uint64
Type int32
Size uint64
CreationTime uint64
AccessTime uint64
WriteTime uint64
AttrChangeTime uint64
SpecialPerms uint8
OwnerPerms uint8
GroupPerms uint8
OtherPerms uint8
AttrFlags uint64
AllocationSize uint64
UserID uint32
GroupID uint32
HostFileID uint64
VolumeID uint32
EffectivePerms uint32
Reserved2 uint64
}
AttrV2 as defined in hgfsProto.h:HgfsAttrV2
type Capability ¶
Capability as defined in hgfsProto.h:HgfsCapability
type File ¶
File interface abstracts standard i/o methods to support transfer of regular files and archives of directories.
type FileHandler ¶
type FileHandler interface {
Stat(*url.URL) (os.FileInfo, error)
Open(*url.URL, int32) (File, error)
}
FileHandler is the plugin interface for hgfs file transport.
func NewArchiveHandler ¶
func NewArchiveHandler() FileHandler
NewArchiveHandler returns a FileHandler implementation for transferring directories using gzip'd tar files.
type FileName ¶
FileName as defined in hgfsProto.h:HgfsFileName
func (*FileName) FromString ¶
FromString converts name to a FileName
func (*FileName) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*FileName) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type FileNameV3 ¶
FileNameV3 as defined in hgfsProto.h:HgfsFileNameV3
func (*FileNameV3) FromString ¶
func (f *FileNameV3) FromString(name string)
FromString converts name to a FileNameV3
func (*FileNameV3) MarshalBinary ¶
func (f *FileNameV3) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*FileNameV3) UnmarshalBinary ¶
func (f *FileNameV3) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type Header ¶
type Header struct {
Version uint8
Reserved1 [3]uint8
Dummy int32
PacketSize uint32
HeaderSize uint32
RequestID uint32
Op int32
Status uint32
Flags uint32
Information uint32
SessionID uint64
Reserved uint64
}
Header as defined in hgfsProto.h:HgfsHeader
func (*Header) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type Packet ¶
Packet encapsulates an hgfs Header and Payload
func (*Packet) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*Packet) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type ReplyClose ¶
type ReplyClose struct {
Reply
}
ReplyClose as defined in hgfsProto.h:HgfsReplyClose
type ReplyCreateSessionV4 ¶
type ReplyCreateSessionV4 struct {
SessionID uint64
NumCapabilities uint32
MaxPacketSize uint32
IdentityOffset uint32
Flags uint32
Reserved uint32
Capabilities []Capability
}
ReplyCreateSessionV4 as defined in hgfsProto.h:HgfsReplyCreateSessionV4
func (*ReplyCreateSessionV4) MarshalBinary ¶
func (r *ReplyCreateSessionV4) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*ReplyCreateSessionV4) UnmarshalBinary ¶
func (r *ReplyCreateSessionV4) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type ReplyDestroySessionV4 ¶
type ReplyDestroySessionV4 struct {
Reserved uint64
}
ReplyDestroySessionV4 as defined in hgfsProto.h:HgfsReplyDestroySessionV4
type ReplyGetattrV2 ¶
ReplyGetattrV2 as defined in hgfsProto.h:HgfsReplyGetattrV2
func (*ReplyGetattrV2) MarshalBinary ¶
func (r *ReplyGetattrV2) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*ReplyGetattrV2) UnmarshalBinary ¶
func (r *ReplyGetattrV2) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type ReplyOpenV3 ¶
ReplyOpenV3 as defined in hgfsProto.h:HgfsReplyOpenV3
type ReplyReadV3 ¶
ReplyReadV3 as defined in hgfsProto.h:HgfsReplyReadV3
func (*ReplyReadV3) MarshalBinary ¶
func (r *ReplyReadV3) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*ReplyReadV3) UnmarshalBinary ¶
func (r *ReplyReadV3) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type ReplySetattrV2 ¶
type ReplySetattrV2 struct {
Header Reply
}
ReplySetattrV2 as defined in hgfsProto.h:HgfsReplySetattrV2
type ReplyWriteV3 ¶
ReplyWriteV3 as defined in hgfsProto.h:HgfsReplyWriteV3
type RequestClose ¶
RequestClose as defined in hgfsProto.h:HgfsRequestClose
type RequestCreateSessionV4 ¶
type RequestCreateSessionV4 struct {
NumCapabilities uint32
MaxPacketSize uint32
Flags uint32
Reserved uint32
Capabilities []Capability
}
RequestCreateSessionV4 as defined in hgfsProto.h:HgfsRequestCreateSessionV4
func (*RequestCreateSessionV4) MarshalBinary ¶
func (r *RequestCreateSessionV4) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*RequestCreateSessionV4) UnmarshalBinary ¶
func (r *RequestCreateSessionV4) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type RequestDestroySessionV4 ¶
type RequestDestroySessionV4 struct {
Reserved uint64
}
RequestDestroySessionV4 as defined in hgfsProto.h:HgfsRequestDestroySessionV4
type RequestGetattrV2 ¶
RequestGetattrV2 as defined in hgfsProto.h:HgfsRequestGetattrV2
func (*RequestGetattrV2) MarshalBinary ¶
func (r *RequestGetattrV2) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*RequestGetattrV2) UnmarshalBinary ¶
func (r *RequestGetattrV2) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type RequestOpen ¶
type RequestOpen struct {
Request
OpenMode int32
OpenFlags int32
Permissions uint8
FileName FileName
}
RequestOpen as defined in hgfsProto.h:HgfsRequestOpen
func (*RequestOpen) MarshalBinary ¶
func (r *RequestOpen) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*RequestOpen) UnmarshalBinary ¶
func (r *RequestOpen) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type RequestOpenV3 ¶
type RequestOpenV3 struct {
Mask uint64
OpenMode int32
OpenFlags int32
SpecialPerms uint8
OwnerPerms uint8
GroupPerms uint8
OtherPerms uint8
AttrFlags uint64
AllocationSize uint64
DesiredAccess uint32
DesiredLock int32
Reserved1 uint64
Reserved2 uint64
FileName FileNameV3
}
RequestOpenV3 as defined in hgfsProto.h:HgfsRequestOpenV3
func (*RequestOpenV3) MarshalBinary ¶
func (r *RequestOpenV3) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*RequestOpenV3) UnmarshalBinary ¶
func (r *RequestOpenV3) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type RequestReadV3 ¶
RequestReadV3 as defined in hgfsProto.h:HgfsRequestReadV3
type RequestSetattrV2 ¶
RequestSetattrV2 as defined in hgfsProto.h:HgfsRequestSetattrV2
func (*RequestSetattrV2) MarshalBinary ¶
func (r *RequestSetattrV2) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*RequestSetattrV2) UnmarshalBinary ¶
func (r *RequestSetattrV2) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type RequestWriteV3 ¶
type RequestWriteV3 struct {
Handle uint32
WriteFlags uint8
Offset uint64
RequiredSize uint32
Reserved uint64
Payload []byte
}
RequestWriteV3 as defined in hgfsProto.h:HgfsRequestWriteV3
func (*RequestWriteV3) MarshalBinary ¶
func (r *RequestWriteV3) MarshalBinary() ([]byte, error)
MarshalBinary implements the encoding.BinaryMarshaler interface
func (*RequestWriteV3) UnmarshalBinary ¶
func (r *RequestWriteV3) UnmarshalBinary(data []byte) error
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface
type Server ¶
type Server struct {
Capabilities []Capability
// contains filtered or unexported fields
}
Server provides an HGFS protocol implementation to support guest tools VmxiHgfsSendPacketCommand
func NewServer ¶
func NewServer() *Server
NewServer creates a new Server instance with the default handlers
func (*Server) CreateSessionV4 ¶
CreateSessionV4 handls OpCreateSessionV4 requests
func (*Server) DestroySessionV4 ¶
DestroySessionV4 handls OpDestroySessionV4 requests
func (*Server) Dispatch ¶
Dispatch unpacks the given request packet and dispatches to the appropriate handler
func (*Server) RegisterFileHandler ¶
func (s *Server) RegisterFileHandler(scheme string, handler FileHandler)
RegisterFileHandler enables dispatch to handler for the given scheme.
func (*Server) Stat ¶
Stat wraps os.Stat such that we can report directory types as regular files to support archive streaming. In the case of standard vmware-tools, attempts to transfer directories result with a VIX_E_NOT_A_FILE (see InitiateFileTransfer{To,From}Guest). Note that callers on the VMX side that reach this path are only concerned with: - does the file exist? - size:
- used for UI progress with desktop Drag-N-Drop operations, which toolbox does not support.
- sent to as Content-Length header in response to GET of FileTransferInformation.Url, if the first ReadV3 size is > HGFS_LARGE_PACKET_MAX