Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * linux/fs/9p/error.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Error string handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Plan 9 uses error strings, Unix uses error numbers.  These functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * try to help manage that and provide for dynamically adding error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * mappings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *  Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *  Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/jhash.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <net/9p/9p.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * struct errormap - map string errors from Plan 9 to Linux numeric ids
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * @name: string sent over 9P
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * @val: numeric id most closely representing @name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * @namelen: length of string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * @list: hash-table list for string lookup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) struct errormap {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	int val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	int namelen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	struct hlist_node list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define ERRHASHSZ		32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static struct hlist_head hash_errmap[ERRHASHSZ];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /* FixMe - reduce to a reasonable size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static struct errormap errmap[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	{"Operation not permitted", EPERM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	{"wstat prohibited", EPERM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	{"No such file or directory", ENOENT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	{"directory entry not found", ENOENT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	{"file not found", ENOENT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	{"Interrupted system call", EINTR},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	{"Input/output error", EIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	{"No such device or address", ENXIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	{"Argument list too long", E2BIG},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	{"Bad file descriptor", EBADF},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	{"Resource temporarily unavailable", EAGAIN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	{"Cannot allocate memory", ENOMEM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	{"Permission denied", EACCES},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	{"Bad address", EFAULT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	{"Block device required", ENOTBLK},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	{"Device or resource busy", EBUSY},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	{"File exists", EEXIST},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	{"Invalid cross-device link", EXDEV},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	{"No such device", ENODEV},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	{"Not a directory", ENOTDIR},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	{"Is a directory", EISDIR},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	{"Invalid argument", EINVAL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	{"Too many open files in system", ENFILE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	{"Too many open files", EMFILE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	{"Text file busy", ETXTBSY},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	{"File too large", EFBIG},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	{"No space left on device", ENOSPC},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	{"Illegal seek", ESPIPE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	{"Read-only file system", EROFS},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	{"Too many links", EMLINK},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	{"Broken pipe", EPIPE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	{"Numerical argument out of domain", EDOM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	{"Numerical result out of range", ERANGE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	{"Resource deadlock avoided", EDEADLK},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	{"File name too long", ENAMETOOLONG},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	{"No locks available", ENOLCK},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	{"Function not implemented", ENOSYS},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	{"Directory not empty", ENOTEMPTY},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	{"Too many levels of symbolic links", ELOOP},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	{"No message of desired type", ENOMSG},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	{"Identifier removed", EIDRM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	{"No data available", ENODATA},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	{"Machine is not on the network", ENONET},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	{"Package not installed", ENOPKG},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	{"Object is remote", EREMOTE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	{"Link has been severed", ENOLINK},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	{"Communication error on send", ECOMM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	{"Protocol error", EPROTO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	{"Bad message", EBADMSG},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	{"File descriptor in bad state", EBADFD},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	{"Streams pipe error", ESTRPIPE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	{"Too many users", EUSERS},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	{"Socket operation on non-socket", ENOTSOCK},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	{"Message too long", EMSGSIZE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	{"Protocol not available", ENOPROTOOPT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	{"Protocol not supported", EPROTONOSUPPORT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	{"Socket type not supported", ESOCKTNOSUPPORT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	{"Operation not supported", EOPNOTSUPP},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	{"Protocol family not supported", EPFNOSUPPORT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	{"Network is down", ENETDOWN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	{"Network is unreachable", ENETUNREACH},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	{"Network dropped connection on reset", ENETRESET},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	{"Software caused connection abort", ECONNABORTED},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	{"Connection reset by peer", ECONNRESET},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	{"No buffer space available", ENOBUFS},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	{"Transport endpoint is already connected", EISCONN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	{"Transport endpoint is not connected", ENOTCONN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	{"Cannot send after transport endpoint shutdown", ESHUTDOWN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	{"Connection timed out", ETIMEDOUT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	{"Connection refused", ECONNREFUSED},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	{"Host is down", EHOSTDOWN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	{"No route to host", EHOSTUNREACH},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	{"Operation already in progress", EALREADY},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	{"Operation now in progress", EINPROGRESS},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	{"Is a named type file", EISNAM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	{"Remote I/O error", EREMOTEIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	{"Disk quota exceeded", EDQUOT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /* errors from fossil, vacfs, and u9fs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	{"fid unknown or out of range", EBADF},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	{"permission denied", EACCES},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	{"file does not exist", ENOENT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	{"authentication failed", ECONNREFUSED},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	{"bad offset in directory read", ESPIPE},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	{"bad use of fid", EBADF},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	{"wstat can't convert between files and directories", EPERM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	{"directory is not empty", ENOTEMPTY},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	{"file exists", EEXIST},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	{"file already exists", EEXIST},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	{"file or directory already exists", EEXIST},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	{"fid already in use", EBADF},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	{"file in use", ETXTBSY},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	{"i/o error", EIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	{"file already open for I/O", ETXTBSY},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	{"illegal mode", EINVAL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	{"illegal name", ENAMETOOLONG},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	{"not a directory", ENOTDIR},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	{"not a member of proposed group", EPERM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	{"not owner", EACCES},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	{"only owner can change group in wstat", EACCES},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	{"read only file system", EROFS},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	{"no access to special file", EPERM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	{"i/o count too large", EIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	{"unknown group", EINVAL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	{"unknown user", EINVAL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	{"bogus wstat buffer", EPROTO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	{"exclusive use file already open", EAGAIN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	{"corrupted directory entry", EIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	{"corrupted file entry", EIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	{"corrupted block label", EIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	{"corrupted meta data", EIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	{"illegal offset", EINVAL},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	{"illegal path element", ENOENT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	{"root of file system is corrupted", EIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	{"corrupted super block", EIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	{"protocol botch", EPROTO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	{"file system is full", ENOSPC},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	{"file is in use", EAGAIN},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	{"directory entry is not allocated", ENOENT},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	{"file is read only", EROFS},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	{"file has been removed", EIDRM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	{"only support truncation to zero length", EPERM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	{"cannot remove root", EPERM},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	{"file too big", EFBIG},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	{"venti i/o error", EIO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	/* these are not errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	{"u9fs rhostsauth: no authentication required", 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	{"u9fs authnone: no authentication required", 0},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	{NULL, -1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * p9_error_init - preload mappings into hash list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) int p9_error_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	struct errormap *c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	int bucket;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	/* initialize hash table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	for (bucket = 0; bucket < ERRHASHSZ; bucket++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		INIT_HLIST_HEAD(&hash_errmap[bucket]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	/* load initial error map into hash table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	for (c = errmap; c->name != NULL; c++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		c->namelen = strlen(c->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		bucket = jhash(c->name, c->namelen, 0) % ERRHASHSZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		INIT_HLIST_NODE(&c->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		hlist_add_head(&c->list, &hash_errmap[bucket]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) EXPORT_SYMBOL(p9_error_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)  * errstr2errno - convert error string to error number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)  * @errstr: error string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)  * @len: length of error string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) int p9_errstr2errno(char *errstr, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	int errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	struct errormap *c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	int bucket;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	errno = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	c = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	bucket = jhash(errstr, len, 0) % ERRHASHSZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	hlist_for_each_entry(c, &hash_errmap[bucket], list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		if (c->namelen == len && !memcmp(c->name, errstr, len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 			errno = c->val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	if (errno == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		/* TODO: if error isn't found, add it dynamically */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		errstr[len] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		pr_err("%s: server reported unknown error %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		       __func__, errstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 		errno = ESERVERFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	return -errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) EXPORT_SYMBOL(p9_errstr2errno);