This commit is contained in:
2026-08-18 18:11:28 -04:00
parent 0e9a650fa2
commit bbaf47028f
259 changed files with 0 additions and 0 deletions
@@ -0,0 +1,62 @@
/**
* POSIX errno names ↔ numeric hints for guest errors and `/proc` introspection.
* Values follow Linux/x86-64 style where Bare OS surfaces them in messages.
*/
export const BARE_OS_POSIX_ERRNO_MAP = Object.freeze({
EPERM: 1,
ENOENT: 2,
ESRCH: 3,
EINTR: 4,
EIO: 5,
ENXIO: 6,
E2BIG: 7,
ENOEXEC: 8,
EBADF: 9,
ECHILD: 10,
EAGAIN: 11,
ENOMEM: 12,
EACCES: 13,
EFAULT: 14,
ENOTBLK: 15,
EBUSY: 16,
EEXIST: 17,
EXDEV: 18,
ENODEV: 19,
ENOTDIR: 20,
EISDIR: 21,
EINVAL: 22,
ENFILE: 23,
EMFILE: 24,
ENOTTY: 25,
ETXTBSY: 26,
EFBIG: 27,
ENOSPC: 28,
ESPIPE: 29,
EROFS: 30,
EMLINK: 31,
EPIPE: 32,
EDOM: 33,
ERANGE: 34,
ELOOP: 40,
ENAMETOOLONG: 36,
ENOSYS: 38,
ENOTEMPTY: 39,
EOPNOTSUPP: 95
})
/**
* @param {string} name
* @returns {number | undefined}
*/
export function bareOsErrnoNumber(name) {
const k = String(name || '').toUpperCase()
return /** @type {Record<string, number>} */ (BARE_OS_POSIX_ERRNO_MAP)[k]
}
/**
* @returns {Record<string, number>}
*/
export function bareOsErrnoTableForProc() {
return { ...BARE_OS_POSIX_ERRNO_MAP }
}