github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/pkg/sentry/fs/seek.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 fs
    16  
    17  // SeekWhence determines seek direction.
    18  type SeekWhence int
    19  
    20  const (
    21  	// SeekSet sets the absolute offset.
    22  	SeekSet SeekWhence = iota
    23  
    24  	// SeekCurrent sets relative to the current position.
    25  	SeekCurrent
    26  
    27  	// SeekEnd sets relative to the end of the file.
    28  	SeekEnd
    29  )
    30  
    31  // String returns a human readable string for whence.
    32  func (s SeekWhence) String() string {
    33  	switch s {
    34  	case SeekSet:
    35  		return "Set"
    36  	case SeekCurrent:
    37  		return "Current"
    38  	case SeekEnd:
    39  		return "End"
    40  	default:
    41  		return "Unknown"
    42  	}
    43  }