github.com/nicocha30/gvisor-ligolo@v0.0.0-20230726075806-989fa2c0a413/pkg/sentry/fsimpl/fuse/fuse_abi_autogen_unsafe.go (about)

     1  // Automatically generated marshal implementation. See tools/go_marshal.
     2  
     3  package fuse
     4  
     5  import (
     6  	"github.com/nicocha30/gvisor-ligolo/pkg/hostarch"
     7  	"github.com/nicocha30/gvisor-ligolo/pkg/marshal"
     8      "io"
     9  )
    10  
    11  // Marshallable types used by this file.
    12  var _ marshal.Marshallable = (*fuseInitRes)(nil)
    13  
    14  // Packed implements marshal.Marshallable.Packed.
    15  //go:nosplit
    16  func (r *fuseInitRes) Packed() bool {
    17      // Type fuseInitRes is dynamic so it might have slice/string headers. Hence, it is not packed.
    18      return false
    19  }
    20  
    21  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
    22  func (r *fuseInitRes) MarshalUnsafe(dst []byte) []byte {
    23      // Type fuseInitRes doesn't have a packed layout in memory, fallback to MarshalBytes.
    24      return r.MarshalBytes(dst)
    25  }
    26  
    27  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
    28  func (r *fuseInitRes) UnmarshalUnsafe(src []byte) []byte {
    29      // Type fuseInitRes doesn't have a packed layout in memory, fallback to UnmarshalBytes.
    30      return r.UnmarshalBytes(src)
    31  }
    32  
    33  // CopyOutN implements marshal.Marshallable.CopyOutN.
    34  //go:nosplit
    35  func (r *fuseInitRes) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
    36      // Type fuseInitRes doesn't have a packed layout in memory, fall back to MarshalBytes.
    37      buf := cc.CopyScratchBuffer(r.SizeBytes()) // escapes: okay.
    38      r.MarshalBytes(buf) // escapes: fallback.
    39      return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
    40  }
    41  
    42  // CopyOut implements marshal.Marshallable.CopyOut.
    43  func (r *fuseInitRes) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
    44      return r.CopyOutN(cc, addr, r.SizeBytes())
    45  }
    46  
    47  // CopyIn implements marshal.Marshallable.CopyIn.
    48  func (r *fuseInitRes) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
    49      // Type fuseInitRes doesn't have a packed layout in memory, fall back to UnmarshalBytes.
    50      buf := cc.CopyScratchBuffer(r.SizeBytes()) // escapes: okay.
    51      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
    52      // Unmarshal unconditionally. If we had a short copy-in, this results in a
    53      // partially unmarshalled struct.
    54      r.UnmarshalBytes(buf) // escapes: fallback.
    55      return length, err
    56  }
    57  
    58  // WriteTo implements io.WriterTo.WriteTo.
    59  func (r *fuseInitRes) WriteTo(writer io.Writer) (int64, error) {
    60      // Type fuseInitRes doesn't have a packed layout in memory, fall back to MarshalBytes.
    61      buf := make([]byte, r.SizeBytes())
    62      r.MarshalBytes(buf)
    63      length, err := writer.Write(buf)
    64      return int64(length), err
    65  }
    66