// "Standard" errno values -- Copied from newlib /usr/include/sys/errno.h // Copyright (C)2020-2023, Philip Munts dba Munts Technologies. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. /// /// Define Unix errno values and services. /// public static class errno { /// /// No error. /// public const int EOK = 0; /// /// Operation not permitted. /// public const int EPERM = 1; /// /// No such file or directory. /// public const int ENOENT = 2; /// /// No such process. /// public const int ESRCH = 3; /// /// Interrupted system call. /// public const int EINTR = 4; /// /// Input/output error. /// public const int EIO = 5; /// /// No such device or address. /// public const int ENXIO = 6; /// /// Argument list too long. /// public const int E2BIG = 7; /// /// Exec format error. /// public const int ENOEXEC = 8; /// /// Bad file descriptor. /// public const int EBADF = 9; /// /// No child processes. /// public const int ECHILD = 10; /// /// Resource temporarily unavailable. /// public const int EAGAIN = 11; /// /// Cannot allocate memory. /// public const int ENOMEM = 12; /// /// Permission denied. /// public const int EACCES = 13; /// /// Bad address. /// public const int EFAULT = 14; /// /// Block device required. /// public const int ENOTBLK = 15; /// /// Device or resource busy. /// public const int EBUSY = 16; /// /// File exists. /// public const int EEXIST = 17; /// /// Invalid cross-device link. /// public const int EXDEV = 18; /// /// No such device. /// public const int ENODEV = 19; /// /// Not a directory. /// public const int ENOTDIR = 20; /// /// Is a directory. /// public const int EISDIR = 21; /// /// Invalid argument. /// public const int EINVAL = 22; /// /// Too many open files in system. /// public const int ENFILE = 23; /// /// Too many open files. /// public const int EMFILE = 24; /// /// Inappropriate ioctl for device. /// public const int ENOTTY = 25; /// /// Text file busy. /// public const int ETXTBSY = 26; /// /// File too large. /// public const int EFBIG = 27; /// /// No space left on device. /// public const int ENOSPC = 28; /// /// Illegal seek. /// public const int ESPIPE = 29; /// /// Read-only file system. /// public const int EROFS = 30; /// /// Too many links. /// public const int EMLINK = 31; /// /// Broken pipe. /// public const int EPIPE = 32; /// /// Numerical argument out of domain. /// public const int EDOM = 33; /// /// Numerical result out of range. /// public const int ERANGE = 34; /// /// Connection reset by peer. /// public const int ECONNRESET = 104; /// /// Return the error message text for a given errno value. /// /// Unix errno value. /// Error message string. public static string strerror(int errno) { switch (errno) { case EOK : return "No error"; case EPERM : return "Operation not permitted"; case ENOENT : return "No such file or directory"; case ESRCH : return "No such process"; case EINTR : return "Interrupted system call"; case EIO : return "Input/output error"; case ENXIO : return "No such device or address"; case E2BIG : return "Argument list too long"; case ENOEXEC : return "Exec format error"; case EBADF : return "Bad file descriptor"; case ECHILD : return "No child processes"; case EAGAIN : return "Resource temporarily unavailable"; case ENOMEM : return "Cannot allocate memory"; case EACCES : return "Permission denied"; case EFAULT : return "Bad address"; case ENOTBLK : return "Block device required"; case EBUSY : return "Device or resource busy"; case EEXIST : return "File exists"; case EXDEV : return "Invalid cross-device link"; case ENODEV : return "No such device"; case ENOTDIR : return "Not a directory"; case EISDIR : return "Is a directory"; case EINVAL : return "Invalid argument"; case ENFILE : return "Too many open files in system"; case EMFILE : return "Too many open files"; case ENOTTY : return "Inappropriate ioctl for device"; case ETXTBSY : return "Text file busy"; case EFBIG : return "File too large"; case ENOSPC : return "No space left on device"; case ESPIPE : return "Illegal seek"; case EROFS : return "Read-only file system"; case EMLINK : return "Too many links"; case EPIPE : return "Broken pipe"; case EDOM : return "Numerical argument out of domain"; case ERANGE : return "Numerical result out of range"; case ECONNRESET : return "Connection reset by peer"; default : return "Error number " + errno.ToString(); } } }