fix(libc): use FreeBSD errlst message texts for strerror and strerror_r
Twenty-five of the ninety-seven errno messages differed from FreeBSD releng/11.4 lib/libc/gen/errlst.c (for example errno 0, 30, 47, 62, 70 and 84). (cherry picked from commit ce14c9ad7dc639335ff72b60122bae2bd0fee302)
This commit is contained in:
parent
262c031692
commit
5830d8e446
|
|
@ -7,31 +7,39 @@ extern "C" int* APS5_VABI __error_nid_postfix();
|
|||
namespace {
|
||||
// Guest FreeBSD errno numbering, not the host CRT's numbering.
|
||||
constexpr const char* messages[] = {
|
||||
"No error", "Operation not permitted", "No such file or directory", "No such process",
|
||||
"Interrupted system call", "Input/output error", "Device not configured", "Argument list too long",
|
||||
"Exec format error", "Bad file descriptor", "No child processes", "Resource deadlock avoided",
|
||||
"Cannot allocate memory", "Permission denied", "Bad address", "Block device required",
|
||||
"Device busy", "File exists", "Cross-device link", "Operation not supported by device",
|
||||
"Not a directory", "Is a directory", "Invalid argument", "Too many open files in system",
|
||||
"Too many open files", "Inappropriate ioctl for device", "Text file busy", "File too large",
|
||||
"No space left on device", "Illegal seek", "Read-only filesystem", "Too many links", "Broken pipe",
|
||||
"No error: 0", "Operation not permitted", "No such file or directory",
|
||||
"No such process", "Interrupted system call", "Input/output error",
|
||||
"Device not configured", "Argument list too long", "Exec format error",
|
||||
"Bad file descriptor", "No child processes", "Resource deadlock avoided",
|
||||
"Cannot allocate memory", "Permission denied", "Bad address",
|
||||
"Block device required", "Device busy", "File exists",
|
||||
"Cross-device link", "Operation not supported by device", "Not a directory",
|
||||
"Is a directory", "Invalid argument", "Too many open files in system",
|
||||
"Too many open files", "Inappropriate ioctl for device", "Text file busy",
|
||||
"File too large", "No space left on device", "Illegal seek",
|
||||
"Read-only file system", "Too many links", "Broken pipe",
|
||||
"Numerical argument out of domain", "Result too large", "Resource temporarily unavailable",
|
||||
"Operation now in progress", "Operation already in progress", "Socket operation on non-socket",
|
||||
"Destination address required", "Message too long", "Protocol wrong type for socket",
|
||||
"Protocol not available", "Protocol not supported", "Socket type not supported",
|
||||
"Operation not supported", "Protocol family not supported", "Address family not supported",
|
||||
"Address already in use", "Cannot assign requested address", "Network is down", "Network is unreachable",
|
||||
"Network connection reset", "Connection aborted", "Connection reset by peer", "No buffer space available",
|
||||
"Socket is already connected", "Socket is not connected", "Socket is shut down", "Too many references",
|
||||
"Operation timed out", "Connection refused", "Too many symbolic links", "File name too long",
|
||||
"Host is down", "No route to host", "Directory not empty", "Too many processes", "Too many users",
|
||||
"Disk quota exceeded", "Stale file handle", "Remote path has too many levels", "Invalid RPC structure",
|
||||
"RPC version mismatch", "RPC program unavailable", "Program version mismatch", "Invalid RPC procedure",
|
||||
"No locks available", "Function not implemented", "Inappropriate file type", "Authentication error",
|
||||
"Authentication required", "Identifier removed", "No message of requested type", "Value too large",
|
||||
"Operation canceled", "Invalid byte sequence", "Attribute not found", "Programming error",
|
||||
"Bad message", "Multihop attempted", "Link severed", "Protocol error", "Insufficient capabilities",
|
||||
"Operation not permitted in capability mode", "State not recoverable", "Previous owner died"
|
||||
"Operation not supported", "Protocol family not supported", "Address family not supported by protocol family",
|
||||
"Address already in use", "Can't assign requested address", "Network is down",
|
||||
"Network is unreachable", "Network dropped connection on reset", "Software caused connection abort",
|
||||
"Connection reset by peer", "No buffer space available", "Socket is already connected",
|
||||
"Socket is not connected", "Can't send after socket shutdown", "Too many references: can't splice",
|
||||
"Operation timed out", "Connection refused", "Too many levels of symbolic links",
|
||||
"File name too long", "Host is down", "No route to host",
|
||||
"Directory not empty", "Too many processes", "Too many users",
|
||||
"Disc quota exceeded", "Stale NFS file handle", "Too many levels of remote in path",
|
||||
"RPC struct is bad", "RPC version wrong", "RPC prog. not avail",
|
||||
"Program version wrong", "Bad procedure for program", "No locks available",
|
||||
"Function not implemented", "Inappropriate file type or format", "Authentication error",
|
||||
"Need authenticator", "Identifier removed", "No message of desired type",
|
||||
"Value too large to be stored in data type", "Operation canceled", "Illegal byte sequence",
|
||||
"Attribute not found", "Programming error", "Bad message",
|
||||
"Multihop attempted", "Link has been severed", "Protocol error",
|
||||
"Capabilities insufficient", "Not permitted in capability mode", "State not recoverable",
|
||||
"Previous owner died"
|
||||
};
|
||||
static_assert(sizeof(messages) / sizeof(messages[0]) == 97);
|
||||
bool Known(int error) { return error >= 0 && error < 97; }
|
||||
|
|
|
|||
|
|
@ -9,6 +9,41 @@ int APS5_VABI strerror_r_nid_postfix(int, char*, std::size_t);
|
|||
int* APS5_VABI __error_nid_postfix();
|
||||
}
|
||||
static void Require(bool value) { if (!value) std::abort(); }
|
||||
static const char* const freebsd[97] = {
|
||||
"No error: 0", "Operation not permitted", "No such file or directory",
|
||||
"No such process", "Interrupted system call", "Input/output error",
|
||||
"Device not configured", "Argument list too long", "Exec format error",
|
||||
"Bad file descriptor", "No child processes", "Resource deadlock avoided",
|
||||
"Cannot allocate memory", "Permission denied", "Bad address",
|
||||
"Block device required", "Device busy", "File exists",
|
||||
"Cross-device link", "Operation not supported by device", "Not a directory",
|
||||
"Is a directory", "Invalid argument", "Too many open files in system",
|
||||
"Too many open files", "Inappropriate ioctl for device", "Text file busy",
|
||||
"File too large", "No space left on device", "Illegal seek",
|
||||
"Read-only file system", "Too many links", "Broken pipe",
|
||||
"Numerical argument out of domain", "Result too large", "Resource temporarily unavailable",
|
||||
"Operation now in progress", "Operation already in progress", "Socket operation on non-socket",
|
||||
"Destination address required", "Message too long", "Protocol wrong type for socket",
|
||||
"Protocol not available", "Protocol not supported", "Socket type not supported",
|
||||
"Operation not supported", "Protocol family not supported", "Address family not supported by protocol family",
|
||||
"Address already in use", "Can't assign requested address", "Network is down",
|
||||
"Network is unreachable", "Network dropped connection on reset", "Software caused connection abort",
|
||||
"Connection reset by peer", "No buffer space available", "Socket is already connected",
|
||||
"Socket is not connected", "Can't send after socket shutdown", "Too many references: can't splice",
|
||||
"Operation timed out", "Connection refused", "Too many levels of symbolic links",
|
||||
"File name too long", "Host is down", "No route to host",
|
||||
"Directory not empty", "Too many processes", "Too many users",
|
||||
"Disc quota exceeded", "Stale NFS file handle", "Too many levels of remote in path",
|
||||
"RPC struct is bad", "RPC version wrong", "RPC prog. not avail",
|
||||
"Program version wrong", "Bad procedure for program", "No locks available",
|
||||
"Function not implemented", "Inappropriate file type or format", "Authentication error",
|
||||
"Need authenticator", "Identifier removed", "No message of desired type",
|
||||
"Value too large to be stored in data type", "Operation canceled", "Illegal byte sequence",
|
||||
"Attribute not found", "Programming error", "Bad message",
|
||||
"Multihop attempted", "Link has been severed", "Protocol error",
|
||||
"Capabilities insufficient", "Not permitted in capability mode", "State not recoverable",
|
||||
"Previous owner died"
|
||||
};
|
||||
int main() {
|
||||
*__error_nid_postfix() = 13;
|
||||
Require(std::strcmp(strerror_nid_postfix(35), "Resource temporarily unavailable") == 0);
|
||||
|
|
@ -25,7 +60,8 @@ int main() {
|
|||
char buffer[128];
|
||||
for (int error = 0; error <= 96; ++error) {
|
||||
Require(strerror_r_nid_postfix(error, buffer, sizeof(buffer)) == 0);
|
||||
Require(buffer[0] && std::strstr(buffer, "Unknown") == nullptr);
|
||||
Require(std::strcmp(buffer, freebsd[error]) == 0);
|
||||
Require(std::strcmp(strerror_nid_postfix(error), freebsd[error]) == 0);
|
||||
}
|
||||
Require(strerror_r_nid_postfix(-1, buffer, sizeof(buffer)) == 22);
|
||||
Require(std::strstr(buffer, "-1") != nullptr);
|
||||
|
|
|
|||
Loading…
Reference in New Issue