.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* miscellaneous bits |
---|
2 | 3 | * |
---|
3 | 4 | * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. |
---|
4 | 5 | * Written by David Howells (dhowells@redhat.com) |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or |
---|
7 | | - * modify it under the terms of the GNU General Public License |
---|
8 | | - * as published by the Free Software Foundation; either version |
---|
9 | | - * 2 of the License, or (at your option) any later version. |
---|
10 | 6 | */ |
---|
11 | 7 | |
---|
12 | 8 | #include <linux/kernel.h> |
---|
.. | .. |
---|
14 | 10 | #include <linux/errno.h> |
---|
15 | 11 | #include "internal.h" |
---|
16 | 12 | #include "afs_fs.h" |
---|
| 13 | +#include "protocol_uae.h" |
---|
17 | 14 | |
---|
18 | 15 | /* |
---|
19 | 16 | * convert an AFS abort code to a Linux error number |
---|
.. | .. |
---|
69 | 66 | case AFSVL_PERM: return -EACCES; |
---|
70 | 67 | case AFSVL_NOMEM: return -EREMOTEIO; |
---|
71 | 68 | |
---|
72 | | - /* Unified AFS error table; ET "uae" == 0x2f6df00 */ |
---|
73 | | - case 0x2f6df00: return -EPERM; |
---|
74 | | - case 0x2f6df01: return -ENOENT; |
---|
75 | | - case 0x2f6df04: return -EIO; |
---|
76 | | - case 0x2f6df0a: return -EAGAIN; |
---|
77 | | - case 0x2f6df0b: return -ENOMEM; |
---|
78 | | - case 0x2f6df0c: return -EACCES; |
---|
79 | | - case 0x2f6df0f: return -EBUSY; |
---|
80 | | - case 0x2f6df10: return -EEXIST; |
---|
81 | | - case 0x2f6df11: return -EXDEV; |
---|
82 | | - case 0x2f6df12: return -ENODEV; |
---|
83 | | - case 0x2f6df13: return -ENOTDIR; |
---|
84 | | - case 0x2f6df14: return -EISDIR; |
---|
85 | | - case 0x2f6df15: return -EINVAL; |
---|
86 | | - case 0x2f6df1a: return -EFBIG; |
---|
87 | | - case 0x2f6df1b: return -ENOSPC; |
---|
88 | | - case 0x2f6df1d: return -EROFS; |
---|
89 | | - case 0x2f6df1e: return -EMLINK; |
---|
90 | | - case 0x2f6df20: return -EDOM; |
---|
91 | | - case 0x2f6df21: return -ERANGE; |
---|
92 | | - case 0x2f6df22: return -EDEADLK; |
---|
93 | | - case 0x2f6df23: return -ENAMETOOLONG; |
---|
94 | | - case 0x2f6df24: return -ENOLCK; |
---|
95 | | - case 0x2f6df26: return -ENOTEMPTY; |
---|
96 | | - case 0x2f6df28: return -EWOULDBLOCK; |
---|
97 | | - case 0x2f6df69: return -ENOTCONN; |
---|
98 | | - case 0x2f6df6c: return -ETIMEDOUT; |
---|
99 | | - case 0x2f6df78: return -EDQUOT; |
---|
| 69 | + /* Unified AFS error table */ |
---|
| 70 | + case UAEPERM: return -EPERM; |
---|
| 71 | + case UAENOENT: return -ENOENT; |
---|
| 72 | + case UAEAGAIN: return -EAGAIN; |
---|
| 73 | + case UAEACCES: return -EACCES; |
---|
| 74 | + case UAEBUSY: return -EBUSY; |
---|
| 75 | + case UAEEXIST: return -EEXIST; |
---|
| 76 | + case UAENOTDIR: return -ENOTDIR; |
---|
| 77 | + case UAEISDIR: return -EISDIR; |
---|
| 78 | + case UAEFBIG: return -EFBIG; |
---|
| 79 | + case UAENOSPC: return -ENOSPC; |
---|
| 80 | + case UAEROFS: return -EROFS; |
---|
| 81 | + case UAEMLINK: return -EMLINK; |
---|
| 82 | + case UAEDEADLK: return -EDEADLK; |
---|
| 83 | + case UAENAMETOOLONG: return -ENAMETOOLONG; |
---|
| 84 | + case UAENOLCK: return -ENOLCK; |
---|
| 85 | + case UAENOTEMPTY: return -ENOTEMPTY; |
---|
| 86 | + case UAELOOP: return -ELOOP; |
---|
| 87 | + case UAEOVERFLOW: return -EOVERFLOW; |
---|
| 88 | + case UAENOMEDIUM: return -ENOMEDIUM; |
---|
| 89 | + case UAEDQUOT: return -EDQUOT; |
---|
100 | 90 | |
---|
101 | 91 | /* RXKAD abort codes; from include/rxrpc/packet.h. ET "RXK" == 0x1260B00 */ |
---|
102 | 92 | case RXKADINCONSISTENCY: return -EPROTO; |
---|
.. | .. |
---|
118 | 108 | default: return -EREMOTEIO; |
---|
119 | 109 | } |
---|
120 | 110 | } |
---|
| 111 | + |
---|
| 112 | +/* |
---|
| 113 | + * Select the error to report from a set of errors. |
---|
| 114 | + */ |
---|
| 115 | +void afs_prioritise_error(struct afs_error *e, int error, u32 abort_code) |
---|
| 116 | +{ |
---|
| 117 | + switch (error) { |
---|
| 118 | + case 0: |
---|
| 119 | + return; |
---|
| 120 | + default: |
---|
| 121 | + if (e->error == -ETIMEDOUT || |
---|
| 122 | + e->error == -ETIME) |
---|
| 123 | + return; |
---|
| 124 | + fallthrough; |
---|
| 125 | + case -ETIMEDOUT: |
---|
| 126 | + case -ETIME: |
---|
| 127 | + if (e->error == -ENOMEM || |
---|
| 128 | + e->error == -ENONET) |
---|
| 129 | + return; |
---|
| 130 | + fallthrough; |
---|
| 131 | + case -ENOMEM: |
---|
| 132 | + case -ENONET: |
---|
| 133 | + if (e->error == -ERFKILL) |
---|
| 134 | + return; |
---|
| 135 | + fallthrough; |
---|
| 136 | + case -ERFKILL: |
---|
| 137 | + if (e->error == -EADDRNOTAVAIL) |
---|
| 138 | + return; |
---|
| 139 | + fallthrough; |
---|
| 140 | + case -EADDRNOTAVAIL: |
---|
| 141 | + if (e->error == -ENETUNREACH) |
---|
| 142 | + return; |
---|
| 143 | + fallthrough; |
---|
| 144 | + case -ENETUNREACH: |
---|
| 145 | + if (e->error == -EHOSTUNREACH) |
---|
| 146 | + return; |
---|
| 147 | + fallthrough; |
---|
| 148 | + case -EHOSTUNREACH: |
---|
| 149 | + if (e->error == -EHOSTDOWN) |
---|
| 150 | + return; |
---|
| 151 | + fallthrough; |
---|
| 152 | + case -EHOSTDOWN: |
---|
| 153 | + if (e->error == -ECONNREFUSED) |
---|
| 154 | + return; |
---|
| 155 | + fallthrough; |
---|
| 156 | + case -ECONNREFUSED: |
---|
| 157 | + if (e->error == -ECONNRESET) |
---|
| 158 | + return; |
---|
| 159 | + fallthrough; |
---|
| 160 | + case -ECONNRESET: /* Responded, but call expired. */ |
---|
| 161 | + if (e->responded) |
---|
| 162 | + return; |
---|
| 163 | + e->error = error; |
---|
| 164 | + return; |
---|
| 165 | + |
---|
| 166 | + case -ECONNABORTED: |
---|
| 167 | + e->responded = true; |
---|
| 168 | + e->error = afs_abort_to_error(abort_code); |
---|
| 169 | + return; |
---|
| 170 | + } |
---|
| 171 | +} |
---|