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