github.com/MerlinKodo/gvisor@v0.0.0-20231110090155-957f62ecf90e/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/MerlinKodo/gvisor/pkg/hostarch"
     7      "github.com/MerlinKodo/gvisor/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  // CopyInN implements marshal.Marshallable.CopyInN.
    48  //go:nosplit
    49  func (r *fuseInitRes) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
    50      // Type fuseInitRes doesn't have a packed layout in memory, fall back to UnmarshalBytes.
    51      buf := cc.CopyScratchBuffer(r.SizeBytes()) // escapes: okay.
    52      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
    53      // Unmarshal unconditionally. If we had a short copy-in, this results in a
    54      // partially unmarshalled struct.
    55      r.UnmarshalBytes(buf) // escapes: fallback.
    56      return length, err
    57  }
    58  
    59  // CopyIn implements marshal.Marshallable.CopyIn.
    60  func (r *fuseInitRes) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
    61      return r.CopyInN(cc, addr, r.SizeBytes())
    62  }
    63  
    64  // WriteTo implements io.WriterTo.WriteTo.
    65  func (r *fuseInitRes) WriteTo(writer io.Writer) (int64, error) {
    66      // Type fuseInitRes doesn't have a packed layout in memory, fall back to MarshalBytes.
    67      buf := make([]byte, r.SizeBytes())
    68      r.MarshalBytes(buf)
    69      length, err := writer.Write(buf)
    70      return int64(length), err
    71  }
    72