go-hep.org/x/hep@v0.38.1/xrootd/xrdproto/stat/stat.go (about) 1 // Copyright ©2018 The go-hep 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 stat contains the structures describing request and response for stat request. 6 // See xrootd protocol specification (http://xrootd.org/doc/dev45/XRdv310.pdf, p. 113) for details. 7 package stat // import "go-hep.org/x/hep/xrootd/xrdproto/stat" 8 9 import ( 10 "go-hep.org/x/hep/xrootd/internal/xrdenc" 11 "go-hep.org/x/hep/xrootd/xrdfs" 12 "go-hep.org/x/hep/xrootd/xrdproto" 13 ) 14 15 // RequestID is the id of the request, it is sent as part of message. 16 // See xrootd protocol specification for details: http://xrootd.org/doc/dev45/XRdv310.pdf, 2.3 Client Request Format. 17 const RequestID uint16 = 3017 18 19 // DefaultResponse is a response for the stat request which contains stat information such as: 20 // the OS-dependent identifier, the size of the data, the entry attributes and the modification time. 21 type DefaultResponse struct { 22 xrdfs.EntryStat 23 } 24 25 // VirtualFSResponse is a response for the stat request 26 // which contains virtual file system stat information such as: 27 // nrw - the number of nodes that can provide read/write access, 28 // frw - the size of the largest contiguous area of r/w free space, 29 // urw - the percent utilization of the partition represented by frw, 30 // nstg - the number of nodes that can provide staging access, 31 // fstg - the size of the largest contiguous area of staging free space, 32 // ustg - the percent utilization of the partition represebted by fstg, 33 type VirtualFSResponse struct { 34 xrdfs.VirtualFSStat 35 } 36 37 // RespID implements xrdproto.Response.RespID. 38 func (resp *VirtualFSResponse) RespID() uint16 { return RequestID } 39 40 // RespID implements xrdproto.Response.RespID. 41 func (resp *DefaultResponse) RespID() uint16 { return RequestID } 42 43 // Options are stat processing options. 44 type Options uint8 45 46 const ( 47 OptionsVFS Options = 1 // OptionsVFS indicates that virtual file system information is requested. 48 ) 49 50 // Request holds open request parameters. 51 type Request struct { 52 Options Options 53 _ [11]uint8 54 FileHandle xrdfs.FileHandle 55 Path string 56 } 57 58 // MarshalXrd implements xrdproto.Marshaler. 59 func (o Request) MarshalXrd(wBuffer *xrdenc.WBuffer) error { 60 wBuffer.WriteU8(uint8(o.Options)) 61 wBuffer.Next(11) 62 wBuffer.WriteBytes(o.FileHandle[:]) 63 wBuffer.WriteStr(o.Path) 64 return nil 65 } 66 67 // UnmarshalXrd implements xrdproto.Unmarshaler. 68 func (o *Request) UnmarshalXrd(rBuffer *xrdenc.RBuffer) error { 69 o.Options = Options(rBuffer.ReadU8()) 70 rBuffer.Skip(11) 71 rBuffer.ReadBytes(o.FileHandle[:]) 72 o.Path = rBuffer.ReadStr() 73 return nil 74 } 75 76 // ReqID implements xrdproto.Request.ReqID. 77 func (req *Request) ReqID() uint16 { return RequestID } 78 79 // ShouldSign implements xrdproto.Request.ShouldSign. 80 func (req *Request) ShouldSign() bool { return false } 81 82 // Opaque implements xrdproto.FilepathRequest.Opaque. 83 func (req *Request) Opaque() string { 84 return xrdproto.Opaque(req.Path) 85 } 86 87 // SetOpaque implements xrdproto.FilepathRequest.SetOpaque. 88 func (req *Request) SetOpaque(opaque string) { 89 xrdproto.SetOpaque(&req.Path, opaque) 90 }