github.com/nicocha30/gvisor-ligolo@v0.0.0-20230726075806-989fa2c0a413/pkg/abi/linux/aio.go (about)

     1  // Copyright 2018 The gVisor Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package linux
    16  
    17  import "encoding/binary"
    18  
    19  // AIORingSize is sizeof(struct aio_ring).
    20  const AIORingSize = 32
    21  
    22  // I/O commands.
    23  const (
    24  	IOCB_CMD_PREAD  = 0
    25  	IOCB_CMD_PWRITE = 1
    26  	IOCB_CMD_FSYNC  = 2
    27  	IOCB_CMD_FDSYNC = 3
    28  	// 4 was the experimental IOCB_CMD_PREADX.
    29  	IOCB_CMD_POLL    = 5
    30  	IOCB_CMD_NOOP    = 6
    31  	IOCB_CMD_PREADV  = 7
    32  	IOCB_CMD_PWRITEV = 8
    33  )
    34  
    35  // I/O flags.
    36  const (
    37  	IOCB_FLAG_RESFD  = 1
    38  	IOCB_FLAG_IOPRIO = 2
    39  )
    40  
    41  // IOCallback describes an I/O request.
    42  //
    43  // The priority field is currently ignored in the implementation below. Also
    44  // note that the IOCB_FLAG_RESFD feature is not supported.
    45  //
    46  // +marshal
    47  type IOCallback struct {
    48  	Data uint64
    49  	Key  uint32
    50  	_    uint32
    51  
    52  	OpCode  uint16
    53  	ReqPrio int16
    54  	FD      int32
    55  
    56  	Buf    uint64
    57  	Bytes  uint64
    58  	Offset int64
    59  
    60  	Reserved2 uint64
    61  	Flags     uint32
    62  
    63  	// eventfd to signal if IOCB_FLAG_RESFD is set in flags.
    64  	ResFD int32
    65  }
    66  
    67  // IOEvent describes an I/O result.
    68  //
    69  // +marshal
    70  // +stateify savable
    71  type IOEvent struct {
    72  	Data    uint64
    73  	Obj     uint64
    74  	Result  int64
    75  	Result2 int64
    76  }
    77  
    78  // IOEventSize is the size of an ioEvent encoded.
    79  var IOEventSize = binary.Size(IOEvent{})