github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/cmn/cos/err_darwin.go (about)

     1  // Package cmn provides common constants, types, and utilities for AIS clients
     2  // and AIStore.
     3  /*
     4   * Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
     5   */
     6  package cos
     7  
     8  import (
     9  	"errors"
    10  	"io"
    11  	"os"
    12  	"syscall"
    13  )
    14  
    15  // Checks if the error is generated by any IO operation and if the error
    16  // is severe enough to run the FSHC for mountpath testing
    17  //
    18  // For mountpath definition, see fs/mountfs.go
    19  func IsIOError(err error) bool {
    20  	if err == nil {
    21  		return false
    22  	}
    23  
    24  	ioErrs := []error{
    25  		io.ErrShortWrite,
    26  
    27  		syscall.EIO,     // I/O error
    28  		syscall.ENOTDIR, // mountpath is missing
    29  		syscall.EBUSY,   // device or resource is busy
    30  		syscall.ENXIO,   // No such device
    31  		syscall.EBADF,   // Bad file number
    32  		syscall.ENODEV,  // No such device
    33  		syscall.EROFS,   // readonly filesystem
    34  		syscall.EDQUOT,  // quota exceeded
    35  		syscall.ESTALE,  // stale file handle
    36  		syscall.ENOSPC,  // no space left
    37  	}
    38  	for _, ioErr := range ioErrs {
    39  		if errors.Is(err, ioErr) {
    40  			return true
    41  		}
    42  	}
    43  	return false
    44  }
    45  
    46  func IsErrXattrNotFound(err error) bool {
    47  	// NOTE: syscall.ENOATTR confirmed to be returned on Darwin, instead of syscall.ENODATA.
    48  	return os.IsNotExist(err) || err == syscall.ENOATTR
    49  }