1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:27:45 +00:00

Kernel+LibC: Move errno definitions to Kernel/API/POSIX

This fixes at least half of our LibC includes in the kernel. The source
of truth for errno codes and their description strings now lives in
Kernel/API/POSIX/errno.h as an enumeration, which LibC includes.
This commit is contained in:
sin-ack 2021-09-12 11:29:28 +00:00 committed by Ali Mohammad Pur
parent 0cca6cef95
commit 69ef211925
23 changed files with 123 additions and 183 deletions

97
Kernel/API/POSIX/errno.h Normal file
View file

@ -0,0 +1,97 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#define ENUMERATE_ERRNO_CODES(E) \
E(ESUCCESS, "Success (not an error)") \
E(EPERM, "Operation not permitted") \
E(ENOENT, "No such file or directory") \
E(ESRCH, "No such process") \
E(EINTR, "Interrupted syscall") \
E(EIO, "I/O error") \
E(ENXIO, "No such device or address") \
E(E2BIG, "Argument list too long") \
E(ENOEXEC, "Exec format error") \
E(EBADF, "Bad fd number") \
E(ECHILD, "No child processes") \
E(EAGAIN, "Try again") \
E(ENOMEM, "Out of memory") \
E(EACCES, "Permission denied") \
E(EFAULT, "Bad address") \
E(ENOTBLK, "Block device required") \
E(EBUSY, "Device or resource busy") \
E(EEXIST, "File already exists") \
E(EXDEV, "Cross-device link") \
E(ENODEV, "No such device") \
E(ENOTDIR, "Not a directory") \
E(EISDIR, "Is a directory") \
E(EINVAL, "Invalid argument") \
E(ENFILE, "File table overflow") \
E(EMFILE, "Too many open files") \
E(ENOTTY, "Not a TTY") \
E(ETXTBSY, "Text file busy") \
E(EFBIG, "File too large") \
E(ENOSPC, "No space left on device") \
E(ESPIPE, "Illegal seek") \
E(EROFS, "Read-only filesystem") \
E(EMLINK, "Too many links") \
E(EPIPE, "Broken pipe") \
E(ERANGE, "Range error") \
E(ENAMETOOLONG, "Name too long") \
E(ELOOP, "Too many symlinks") \
E(EOVERFLOW, "Overflow") \
E(EOPNOTSUPP, "Operation not supported") \
E(ENOSYS, "No such syscall") \
E(ENOTIMPL, "Not implemented") \
E(EAFNOSUPPORT, "Address family not supported") \
E(ENOTSOCK, "Not a socket") \
E(EADDRINUSE, "Address in use") \
E(EWHYTHO, "Failed without setting an error code (bug!)") \
E(ENOTEMPTY, "Directory not empty") \
E(EDOM, "Math argument out of domain") \
E(ECONNREFUSED, "Connection refused") \
E(EHOSTDOWN, "Host is down") \
E(EADDRNOTAVAIL, "Address not available") \
E(EISCONN, "Already connected") \
E(ECONNABORTED, "Connection aborted") \
E(EALREADY, "Connection already in progress") \
E(ECONNRESET, "Connection reset") \
E(EDESTADDRREQ, "Destination address required") \
E(EHOSTUNREACH, "Host unreachable") \
E(EILSEQ, "Illegal byte sequence") \
E(EMSGSIZE, "Message size") \
E(ENETDOWN, "Network down") \
E(ENETUNREACH, "Network unreachable") \
E(ENETRESET, "Network reset") \
E(ENOBUFS, "No buffer space") \
E(ENOLCK, "No lock available") \
E(ENOMSG, "No message") \
E(ENOPROTOOPT, "No protocol option") \
E(ENOTCONN, "Not connected") \
E(ESHUTDOWN, "Transport endpoint has shutdown") \
E(ETOOMANYREFS, "Too many references") \
E(ESOCKTNOSUPPORT, "Socket type not supported") \
E(EPROTONOSUPPORT, "Protocol not supported") \
E(EDEADLK, "Resource deadlock would occur") \
E(ETIMEDOUT, "Timed out") \
E(EPROTOTYPE, "Wrong protocol type") \
E(EINPROGRESS, "Operation in progress") \
E(ENOTHREAD, "No such thread") \
E(EPROTO, "Protocol error") \
E(ENOTSUP, "Not supported") \
E(EPFNOSUPPORT, "Protocol family not supported") \
E(EDIRINTOSELF, "Cannot make directory a subdirectory of itself") \
E(EDQUOT, "Quota exceeded") \
E(ENOTRECOVERABLE, "State not recoverable") \
E(EMAXERRNO, "The highest errno +1 :^)")
enum ErrnoCode {
#define __ENUMERATE_ERRNO_CODE(c, s) c,
ENUMERATE_ERRNO_CODES(__ENUMERATE_ERRNO_CODE)
#undef __ENUMERATE_ERRNO_CODE
};

View file

@ -5,10 +5,10 @@
*/
#include <AK/Memory.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Devices/DeviceManagement.h>
#include <Kernel/Devices/FullDevice.h>
#include <Kernel/Sections.h>
#include <LibC/errno_numbers.h>
namespace Kernel {

View file

@ -9,6 +9,7 @@
#include <AK/MemoryStream.h>
#include <AK/StdLibExtras.h>
#include <AK/StringView.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Debug.h>
#include <Kernel/Devices/BlockDevice.h>
#include <Kernel/FileSystem/Ext2FileSystem.h>
@ -16,7 +17,6 @@
#include <Kernel/FileSystem/ext2_fs.h>
#include <Kernel/Process.h>
#include <Kernel/UnixTypes.h>
#include <LibC/errno_numbers.h>
namespace Kernel {

View file

@ -5,6 +5,7 @@
*/
#include <AK/StringView.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/FileSystem/InodeFile.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
@ -12,7 +13,6 @@
#include <Kernel/Memory/PrivateInodeVMObject.h>
#include <Kernel/Memory/SharedInodeVMObject.h>
#include <Kernel/Process.h>
#include <LibC/errno_numbers.h>
#include <LibC/sys/ioctl_numbers.h>
namespace Kernel {

View file

@ -6,6 +6,7 @@
*/
#include <AK/MemoryStream.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Debug.h>
#include <Kernel/Devices/BlockDevice.h>
#include <Kernel/FileSystem/Custody.h>
@ -20,7 +21,6 @@
#include <Kernel/TTY/MasterPTY.h>
#include <Kernel/TTY/TTY.h>
#include <Kernel/UnixTypes.h>
#include <LibC/errno_numbers.h>
namespace Kernel {

View file

@ -7,6 +7,7 @@
*/
#include <AK/Singleton.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Debug.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
@ -15,7 +16,6 @@
#include <Kernel/Heap/kmalloc.h>
#include <Kernel/Process.h>
#include <Kernel/Sections.h>
#include <LibC/errno_numbers.h>
namespace Kernel {

View file

@ -7,6 +7,7 @@
#include <AK/GenericLexer.h>
#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Debug.h>
#include <Kernel/Devices/BlockDevice.h>
#include <Kernel/Devices/DeviceManagement.h>
@ -19,7 +20,6 @@
#include <Kernel/KSyms.h>
#include <Kernel/Process.h>
#include <Kernel/Sections.h>
#include <LibC/errno_numbers.h>
namespace Kernel {

View file

@ -6,6 +6,7 @@
#include <AK/Checked.h>
#include <AK/Try.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Debug.h>
#include <Kernel/Devices/DeviceManagement.h>
#include <Kernel/Graphics/FramebufferDevice.h>
@ -14,7 +15,6 @@
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/Process.h>
#include <Kernel/Sections.h>
#include <LibC/errno_numbers.h>
#include <LibC/sys/ioctl_numbers.h>
namespace Kernel {

View file

@ -6,6 +6,7 @@
#include <AK/Checked.h>
#include <AK/Try.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Debug.h>
#include <Kernel/Devices/DeviceManagement.h>
#include <Kernel/Graphics/FramebufferDevice.h>
@ -15,7 +16,6 @@
#include <Kernel/Process.h>
#include <Kernel/Sections.h>
#include <Kernel/StdLib.h>
#include <LibC/errno_numbers.h>
#define MAX_RESOLUTION_WIDTH 4096
#define MAX_RESOLUTION_HEIGHT 2160

View file

@ -6,6 +6,7 @@
#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Debug.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
#include <Kernel/Net/ARP.h>
@ -21,7 +22,6 @@
#include <Kernel/Net/UDPSocket.h>
#include <Kernel/Process.h>
#include <Kernel/UnixTypes.h>
#include <LibC/errno_numbers.h>
#include <LibC/sys/ioctl_numbers.h>
namespace Kernel {

View file

@ -6,6 +6,7 @@
#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Debug.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
@ -15,7 +16,6 @@
#include <Kernel/Process.h>
#include <Kernel/StdLib.h>
#include <Kernel/UnixTypes.h>
#include <LibC/errno_numbers.h>
#include <LibC/sys/ioctl_numbers.h>
namespace Kernel {

View file

@ -5,6 +5,7 @@
*/
#include <AK/StringView.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Debug.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
#include <Kernel/Net/IPv4Socket.h>
@ -13,7 +14,6 @@
#include <Kernel/Net/Socket.h>
#include <Kernel/Process.h>
#include <Kernel/UnixTypes.h>
#include <LibC/errno_numbers.h>
namespace Kernel {

View file

@ -17,6 +17,7 @@
#ifdef ENABLE_KERNEL_COVERAGE_COLLECTION
# include <Kernel/Devices/KCOVDevice.h>
#endif
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Devices/NullDevice.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
@ -34,7 +35,6 @@
#include <Kernel/TTY/TTY.h>
#include <Kernel/Thread.h>
#include <Kernel/ThreadTracer.h>
#include <LibC/errno_numbers.h>
#include <LibC/limits.h>
namespace Kernel {

View file

@ -4,13 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Debug.h>
#include <Kernel/Process.h>
#include <Kernel/TTY/MasterPTY.h>
#include <Kernel/TTY/PTYMultiplexer.h>
#include <Kernel/TTY/SlavePTY.h>
#include <LibC/errno_numbers.h>
#include <LibC/signal_numbers.h>
#include <LibC/sys/ioctl_numbers.h>

View file

@ -5,12 +5,12 @@
*/
#include <AK/Singleton.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Debug.h>
#include <Kernel/FileSystem/OpenFileDescription.h>
#include <Kernel/Sections.h>
#include <Kernel/TTY/MasterPTY.h>
#include <Kernel/TTY/PTYMultiplexer.h>
#include <LibC/errno_numbers.h>
namespace Kernel {

View file

@ -6,11 +6,11 @@
#include <AK/ScopeGuard.h>
#include <AK/StringView.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Debug.h>
#include <Kernel/Process.h>
#include <Kernel/TTY/TTY.h>
#include <LibC/errno_numbers.h>
#include <LibC/signal_numbers.h>
#include <LibC/sys/ioctl_numbers.h>
#define TTYDEFCHARS

View file

@ -9,10 +9,10 @@
#include <AK/Types.h>
#include <AK/Userspace.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/StdLib.h>
#include <Kernel/UnixTypes.h>
#include <LibC/errno_numbers.h>
namespace Kernel {