Whamcloud - gitweb
LU-6142 tests: Fix style issues for chownmany.c
[fs/lustre-release.git] / lustre / ptlrpc / errno.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.gnu.org/licenses/gpl-2.0.txt
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (C) 2011 FUJITSU LIMITED.  All rights reserved.
24  *
25  * Copyright (c) 2013, Intel Corporation.
26  */
27
28 #include <libcfs/libcfs.h>
29 #include <lustre_errno.h>
30
31 #ifdef LUSTRE_TRANSLATE_ERRNOS
32 #include <lustre_dlm.h>
33
34 /*
35  * The two translation tables below must define a one-to-one mapping between
36  * host and network errnos.
37  *
38  * EWOULDBLOCK is equal to EAGAIN on all architectures except for parisc, which
39  * appears irrelevant.  Thus, existing references to EWOULDBLOCK are fine.
40  *
41  * EDEADLOCK is equal to EDEADLK on x86 but not on sparc, at least.  A sparc
42  * host has no context-free way to determine if a LUSTRE_EDEADLK represents an
43  * EDEADLK or an EDEADLOCK.  Therefore, all existing references to EDEADLOCK
44  * that need to be transferred on wire have been replaced with EDEADLK.
45  */
46 static int lustre_errno_hton_mapping[] = {
47         [EPERM]                 = LUSTRE_EPERM,
48         [ENOENT]                = LUSTRE_ENOENT,
49         [ESRCH]                 = LUSTRE_ESRCH,
50         [EINTR]                 = LUSTRE_EINTR,
51         [EIO]                   = LUSTRE_EIO,
52         [ENXIO]                 = LUSTRE_ENXIO,
53         [E2BIG]                 = LUSTRE_E2BIG,
54         [ENOEXEC]               = LUSTRE_ENOEXEC,
55         [EBADF]                 = LUSTRE_EBADF,
56         [ECHILD]                = LUSTRE_ECHILD,
57         [EAGAIN]                = LUSTRE_EAGAIN,
58         [ENOMEM]                = LUSTRE_ENOMEM,
59         [EACCES]                = LUSTRE_EACCES,
60         [EFAULT]                = LUSTRE_EFAULT,
61         [ENOTBLK]               = LUSTRE_ENOTBLK,
62         [EBUSY]                 = LUSTRE_EBUSY,
63         [EEXIST]                = LUSTRE_EEXIST,
64         [EXDEV]                 = LUSTRE_EXDEV,
65         [ENODEV]                = LUSTRE_ENODEV,
66         [ENOTDIR]               = LUSTRE_ENOTDIR,
67         [EISDIR]                = LUSTRE_EISDIR,
68         [EINVAL]                = LUSTRE_EINVAL,
69         [ENFILE]                = LUSTRE_ENFILE,
70         [EMFILE]                = LUSTRE_EMFILE,
71         [ENOTTY]                = LUSTRE_ENOTTY,
72         [ETXTBSY]               = LUSTRE_ETXTBSY,
73         [EFBIG]                 = LUSTRE_EFBIG,
74         [ENOSPC]                = LUSTRE_ENOSPC,
75         [ESPIPE]                = LUSTRE_ESPIPE,
76         [EROFS]                 = LUSTRE_EROFS,
77         [EMLINK]                = LUSTRE_EMLINK,
78         [EPIPE]                 = LUSTRE_EPIPE,
79         [EDOM]                  = LUSTRE_EDOM,
80         [ERANGE]                = LUSTRE_ERANGE,
81         [EDEADLK]               = LUSTRE_EDEADLK,
82         [ENAMETOOLONG]          = LUSTRE_ENAMETOOLONG,
83         [ENOLCK]                = LUSTRE_ENOLCK,
84         [ENOSYS]                = LUSTRE_ENOSYS,
85         [ENOTEMPTY]             = LUSTRE_ENOTEMPTY,
86         [ELOOP]                 = LUSTRE_ELOOP,
87         [ENOMSG]                = LUSTRE_ENOMSG,
88         [EIDRM]                 = LUSTRE_EIDRM,
89         [ECHRNG]                = LUSTRE_ECHRNG,
90         [EL2NSYNC]              = LUSTRE_EL2NSYNC,
91         [EL3HLT]                = LUSTRE_EL3HLT,
92         [EL3RST]                = LUSTRE_EL3RST,
93         [ELNRNG]                = LUSTRE_ELNRNG,
94         [EUNATCH]               = LUSTRE_EUNATCH,
95         [ENOCSI]                = LUSTRE_ENOCSI,
96         [EL2HLT]                = LUSTRE_EL2HLT,
97         [EBADE]                 = LUSTRE_EBADE,
98         [EBADR]                 = LUSTRE_EBADR,
99         [EXFULL]                = LUSTRE_EXFULL,
100         [ENOANO]                = LUSTRE_ENOANO,
101         [EBADRQC]               = LUSTRE_EBADRQC,
102         [EBADSLT]               = LUSTRE_EBADSLT,
103         [EBFONT]                = LUSTRE_EBFONT,
104         [ENOSTR]                = LUSTRE_ENOSTR,
105         [ENODATA]               = LUSTRE_ENODATA,
106         [ETIME]                 = LUSTRE_ETIME,
107         [ENOSR]                 = LUSTRE_ENOSR,
108         [ENONET]                = LUSTRE_ENONET,
109         [ENOPKG]                = LUSTRE_ENOPKG,
110         [EREMOTE]               = LUSTRE_EREMOTE,
111         [ENOLINK]               = LUSTRE_ENOLINK,
112         [EADV]                  = LUSTRE_EADV,
113         [ESRMNT]                = LUSTRE_ESRMNT,
114         [ECOMM]                 = LUSTRE_ECOMM,
115         [EPROTO]                = LUSTRE_EPROTO,
116         [EMULTIHOP]             = LUSTRE_EMULTIHOP,
117         [EDOTDOT]               = LUSTRE_EDOTDOT,
118         [EBADMSG]               = LUSTRE_EBADMSG,
119         [EOVERFLOW]             = LUSTRE_EOVERFLOW,
120         [ENOTUNIQ]              = LUSTRE_ENOTUNIQ,
121         [EBADFD]                = LUSTRE_EBADFD,
122         [EREMCHG]               = LUSTRE_EREMCHG,
123         [ELIBACC]               = LUSTRE_ELIBACC,
124         [ELIBBAD]               = LUSTRE_ELIBBAD,
125         [ELIBSCN]               = LUSTRE_ELIBSCN,
126         [ELIBMAX]               = LUSTRE_ELIBMAX,
127         [ELIBEXEC]              = LUSTRE_ELIBEXEC,
128         [EILSEQ]                = LUSTRE_EILSEQ,
129         [ERESTART]              = LUSTRE_ERESTART,
130         [ESTRPIPE]              = LUSTRE_ESTRPIPE,
131         [EUSERS]                = LUSTRE_EUSERS,
132         [ENOTSOCK]              = LUSTRE_ENOTSOCK,
133         [EDESTADDRREQ]          = LUSTRE_EDESTADDRREQ,
134         [EMSGSIZE]              = LUSTRE_EMSGSIZE,
135         [EPROTOTYPE]            = LUSTRE_EPROTOTYPE,
136         [ENOPROTOOPT]           = LUSTRE_ENOPROTOOPT,
137         [EPROTONOSUPPORT]       = LUSTRE_EPROTONOSUPPORT,
138         [ESOCKTNOSUPPORT]       = LUSTRE_ESOCKTNOSUPPORT,
139         [EOPNOTSUPP]            = LUSTRE_EOPNOTSUPP,
140         [EPFNOSUPPORT]          = LUSTRE_EPFNOSUPPORT,
141         [EAFNOSUPPORT]          = LUSTRE_EAFNOSUPPORT,
142         [EADDRINUSE]            = LUSTRE_EADDRINUSE,
143         [EADDRNOTAVAIL]         = LUSTRE_EADDRNOTAVAIL,
144         [ENETDOWN]              = LUSTRE_ENETDOWN,
145         [ENETUNREACH]           = LUSTRE_ENETUNREACH,
146         [ENETRESET]             = LUSTRE_ENETRESET,
147         [ECONNABORTED]          = LUSTRE_ECONNABORTED,
148         [ECONNRESET]            = LUSTRE_ECONNRESET,
149         [ENOBUFS]               = LUSTRE_ENOBUFS,
150         [EISCONN]               = LUSTRE_EISCONN,
151         [ENOTCONN]              = LUSTRE_ENOTCONN,
152         [ESHUTDOWN]             = LUSTRE_ESHUTDOWN,
153         [ETOOMANYREFS]          = LUSTRE_ETOOMANYREFS,
154         [ETIMEDOUT]             = LUSTRE_ETIMEDOUT,
155         [ECONNREFUSED]          = LUSTRE_ECONNREFUSED,
156         [EHOSTDOWN]             = LUSTRE_EHOSTDOWN,
157         [EHOSTUNREACH]          = LUSTRE_EHOSTUNREACH,
158         [EALREADY]              = LUSTRE_EALREADY,
159         [EINPROGRESS]           = LUSTRE_EINPROGRESS,
160         [ESTALE]                = LUSTRE_ESTALE,
161         [EUCLEAN]               = LUSTRE_EUCLEAN,
162         [ENOTNAM]               = LUSTRE_ENOTNAM,
163         [ENAVAIL]               = LUSTRE_ENAVAIL,
164         [EISNAM]                = LUSTRE_EISNAM,
165         [EREMOTEIO]             = LUSTRE_EREMOTEIO,
166         [EDQUOT]                = LUSTRE_EDQUOT,
167         [ENOMEDIUM]             = LUSTRE_ENOMEDIUM,
168         [EMEDIUMTYPE]           = LUSTRE_EMEDIUMTYPE,
169         [ECANCELED]             = LUSTRE_ECANCELED,
170         [ENOKEY]                = LUSTRE_ENOKEY,
171         [EKEYEXPIRED]           = LUSTRE_EKEYEXPIRED,
172         [EKEYREVOKED]           = LUSTRE_EKEYREVOKED,
173         [EKEYREJECTED]          = LUSTRE_EKEYREJECTED,
174         [EOWNERDEAD]            = LUSTRE_EOWNERDEAD,
175         [ENOTRECOVERABLE]       = LUSTRE_ENOTRECOVERABLE,
176         [ERESTARTSYS]           = LUSTRE_ERESTARTSYS,
177         [ERESTARTNOINTR]        = LUSTRE_ERESTARTNOINTR,
178         [ERESTARTNOHAND]        = LUSTRE_ERESTARTNOHAND,
179         [ENOIOCTLCMD]           = LUSTRE_ENOIOCTLCMD,
180         [ERESTART_RESTARTBLOCK] = LUSTRE_ERESTART_RESTARTBLOCK,
181         [EBADHANDLE]            = LUSTRE_EBADHANDLE,
182         [ENOTSYNC]              = LUSTRE_ENOTSYNC,
183         [EBADCOOKIE]            = LUSTRE_EBADCOOKIE,
184         [ENOTSUPP]              = LUSTRE_ENOTSUPP,
185         [ETOOSMALL]             = LUSTRE_ETOOSMALL,
186         [ESERVERFAULT]          = LUSTRE_ESERVERFAULT,
187         [EBADTYPE]              = LUSTRE_EBADTYPE,
188         [EJUKEBOX]              = LUSTRE_EJUKEBOX,
189         [EIOCBQUEUED]           = LUSTRE_EIOCBQUEUED,
190
191         /*
192          * The ELDLM errors are Lustre specific errors whose ranges
193          * lie in the middle of the above system errors. The ELDLM
194          * numbers must be preserved to avoid LU-9793.
195          */
196         [ELDLM_LOCK_CHANGED]    = ELDLM_LOCK_CHANGED,
197         [ELDLM_LOCK_ABORTED]    = ELDLM_LOCK_ABORTED,
198         [ELDLM_LOCK_REPLACED]   = ELDLM_LOCK_REPLACED,
199         [ELDLM_NO_LOCK_DATA]    = ELDLM_NO_LOCK_DATA,
200         [ELDLM_LOCK_WOULDBLOCK] = ELDLM_LOCK_WOULDBLOCK,
201         [ELDLM_NAMESPACE_EXISTS]= ELDLM_NAMESPACE_EXISTS,
202         [ELDLM_BAD_NAMESPACE]   = ELDLM_BAD_NAMESPACE
203 };
204
205 static int lustre_errno_ntoh_mapping[] = {
206         [LUSTRE_EPERM]                  = EPERM,
207         [LUSTRE_ENOENT]                 = ENOENT,
208         [LUSTRE_ESRCH]                  = ESRCH,
209         [LUSTRE_EINTR]                  = EINTR,
210         [LUSTRE_EIO]                    = EIO,
211         [LUSTRE_ENXIO]                  = ENXIO,
212         [LUSTRE_E2BIG]                  = E2BIG,
213         [LUSTRE_ENOEXEC]                = ENOEXEC,
214         [LUSTRE_EBADF]                  = EBADF,
215         [LUSTRE_ECHILD]                 = ECHILD,
216         [LUSTRE_EAGAIN]                 = EAGAIN,
217         [LUSTRE_ENOMEM]                 = ENOMEM,
218         [LUSTRE_EACCES]                 = EACCES,
219         [LUSTRE_EFAULT]                 = EFAULT,
220         [LUSTRE_ENOTBLK]                = ENOTBLK,
221         [LUSTRE_EBUSY]                  = EBUSY,
222         [LUSTRE_EEXIST]                 = EEXIST,
223         [LUSTRE_EXDEV]                  = EXDEV,
224         [LUSTRE_ENODEV]                 = ENODEV,
225         [LUSTRE_ENOTDIR]                = ENOTDIR,
226         [LUSTRE_EISDIR]                 = EISDIR,
227         [LUSTRE_EINVAL]                 = EINVAL,
228         [LUSTRE_ENFILE]                 = ENFILE,
229         [LUSTRE_EMFILE]                 = EMFILE,
230         [LUSTRE_ENOTTY]                 = ENOTTY,
231         [LUSTRE_ETXTBSY]                = ETXTBSY,
232         [LUSTRE_EFBIG]                  = EFBIG,
233         [LUSTRE_ENOSPC]                 = ENOSPC,
234         [LUSTRE_ESPIPE]                 = ESPIPE,
235         [LUSTRE_EROFS]                  = EROFS,
236         [LUSTRE_EMLINK]                 = EMLINK,
237         [LUSTRE_EPIPE]                  = EPIPE,
238         [LUSTRE_EDOM]                   = EDOM,
239         [LUSTRE_ERANGE]                 = ERANGE,
240         [LUSTRE_EDEADLK]                = EDEADLK,
241         [LUSTRE_ENAMETOOLONG]           = ENAMETOOLONG,
242         [LUSTRE_ENOLCK]                 = ENOLCK,
243         [LUSTRE_ENOSYS]                 = ENOSYS,
244         [LUSTRE_ENOTEMPTY]              = ENOTEMPTY,
245         [LUSTRE_ELOOP]                  = ELOOP,
246         [LUSTRE_ENOMSG]                 = ENOMSG,
247         [LUSTRE_EIDRM]                  = EIDRM,
248         [LUSTRE_ECHRNG]                 = ECHRNG,
249         [LUSTRE_EL2NSYNC]               = EL2NSYNC,
250         [LUSTRE_EL3HLT]                 = EL3HLT,
251         [LUSTRE_EL3RST]                 = EL3RST,
252         [LUSTRE_ELNRNG]                 = ELNRNG,
253         [LUSTRE_EUNATCH]                = EUNATCH,
254         [LUSTRE_ENOCSI]                 = ENOCSI,
255         [LUSTRE_EL2HLT]                 = EL2HLT,
256         [LUSTRE_EBADE]                  = EBADE,
257         [LUSTRE_EBADR]                  = EBADR,
258         [LUSTRE_EXFULL]                 = EXFULL,
259         [LUSTRE_ENOANO]                 = ENOANO,
260         [LUSTRE_EBADRQC]                = EBADRQC,
261         [LUSTRE_EBADSLT]                = EBADSLT,
262         [LUSTRE_EBFONT]                 = EBFONT,
263         [LUSTRE_ENOSTR]                 = ENOSTR,
264         [LUSTRE_ENODATA]                = ENODATA,
265         [LUSTRE_ETIME]                  = ETIME,
266         [LUSTRE_ENOSR]                  = ENOSR,
267         [LUSTRE_ENONET]                 = ENONET,
268         [LUSTRE_ENOPKG]                 = ENOPKG,
269         [LUSTRE_EREMOTE]                = EREMOTE,
270         [LUSTRE_ENOLINK]                = ENOLINK,
271         [LUSTRE_EADV]                   = EADV,
272         [LUSTRE_ESRMNT]                 = ESRMNT,
273         [LUSTRE_ECOMM]                  = ECOMM,
274         [LUSTRE_EPROTO]                 = EPROTO,
275         [LUSTRE_EMULTIHOP]              = EMULTIHOP,
276         [LUSTRE_EDOTDOT]                = EDOTDOT,
277         [LUSTRE_EBADMSG]                = EBADMSG,
278         [LUSTRE_EOVERFLOW]              = EOVERFLOW,
279         [LUSTRE_ENOTUNIQ]               = ENOTUNIQ,
280         [LUSTRE_EBADFD]                 = EBADFD,
281         [LUSTRE_EREMCHG]                = EREMCHG,
282         [LUSTRE_ELIBACC]                = ELIBACC,
283         [LUSTRE_ELIBBAD]                = ELIBBAD,
284         [LUSTRE_ELIBSCN]                = ELIBSCN,
285         [LUSTRE_ELIBMAX]                = ELIBMAX,
286         [LUSTRE_ELIBEXEC]               = ELIBEXEC,
287         [LUSTRE_EILSEQ]                 = EILSEQ,
288         [LUSTRE_ERESTART]               = ERESTART,
289         [LUSTRE_ESTRPIPE]               = ESTRPIPE,
290         [LUSTRE_EUSERS]                 = EUSERS,
291         [LUSTRE_ENOTSOCK]               = ENOTSOCK,
292         [LUSTRE_EDESTADDRREQ]           = EDESTADDRREQ,
293         [LUSTRE_EMSGSIZE]               = EMSGSIZE,
294         [LUSTRE_EPROTOTYPE]             = EPROTOTYPE,
295         [LUSTRE_ENOPROTOOPT]            = ENOPROTOOPT,
296         [LUSTRE_EPROTONOSUPPORT]        = EPROTONOSUPPORT,
297         [LUSTRE_ESOCKTNOSUPPORT]        = ESOCKTNOSUPPORT,
298         [LUSTRE_EOPNOTSUPP]             = EOPNOTSUPP,
299         [LUSTRE_EPFNOSUPPORT]           = EPFNOSUPPORT,
300         [LUSTRE_EAFNOSUPPORT]           = EAFNOSUPPORT,
301         [LUSTRE_EADDRINUSE]             = EADDRINUSE,
302         [LUSTRE_EADDRNOTAVAIL]          = EADDRNOTAVAIL,
303         [LUSTRE_ENETDOWN]               = ENETDOWN,
304         [LUSTRE_ENETUNREACH]            = ENETUNREACH,
305         [LUSTRE_ENETRESET]              = ENETRESET,
306         [LUSTRE_ECONNABORTED]           = ECONNABORTED,
307         [LUSTRE_ECONNRESET]             = ECONNRESET,
308         [LUSTRE_ENOBUFS]                = ENOBUFS,
309         [LUSTRE_EISCONN]                = EISCONN,
310         [LUSTRE_ENOTCONN]               = ENOTCONN,
311         [LUSTRE_ESHUTDOWN]              = ESHUTDOWN,
312         [LUSTRE_ETOOMANYREFS]           = ETOOMANYREFS,
313         [LUSTRE_ETIMEDOUT]              = ETIMEDOUT,
314         [LUSTRE_ECONNREFUSED]           = ECONNREFUSED,
315         [LUSTRE_EHOSTDOWN]              = EHOSTDOWN,
316         [LUSTRE_EHOSTUNREACH]           = EHOSTUNREACH,
317         [LUSTRE_EALREADY]               = EALREADY,
318         [LUSTRE_EINPROGRESS]            = EINPROGRESS,
319         [LUSTRE_ESTALE]                 = ESTALE,
320         [LUSTRE_EUCLEAN]                = EUCLEAN,
321         [LUSTRE_ENOTNAM]                = ENOTNAM,
322         [LUSTRE_ENAVAIL]                = ENAVAIL,
323         [LUSTRE_EISNAM]                 = EISNAM,
324         [LUSTRE_EREMOTEIO]              = EREMOTEIO,
325         [LUSTRE_EDQUOT]                 = EDQUOT,
326         [LUSTRE_ENOMEDIUM]              = ENOMEDIUM,
327         [LUSTRE_EMEDIUMTYPE]            = EMEDIUMTYPE,
328         [LUSTRE_ECANCELED]              = ECANCELED,
329         [LUSTRE_ENOKEY]                 = ENOKEY,
330         [LUSTRE_EKEYEXPIRED]            = EKEYEXPIRED,
331         [LUSTRE_EKEYREVOKED]            = EKEYREVOKED,
332         [LUSTRE_EKEYREJECTED]           = EKEYREJECTED,
333         [LUSTRE_EOWNERDEAD]             = EOWNERDEAD,
334         [LUSTRE_ENOTRECOVERABLE]        = ENOTRECOVERABLE,
335         [LUSTRE_ERESTARTSYS]            = ERESTARTSYS,
336         [LUSTRE_ERESTARTNOINTR]         = ERESTARTNOINTR,
337         [LUSTRE_ERESTARTNOHAND]         = ERESTARTNOHAND,
338         [LUSTRE_ENOIOCTLCMD]            = ENOIOCTLCMD,
339         [LUSTRE_ERESTART_RESTARTBLOCK]  = ERESTART_RESTARTBLOCK,
340         [LUSTRE_EBADHANDLE]             = EBADHANDLE,
341         [LUSTRE_ENOTSYNC]               = ENOTSYNC,
342         [LUSTRE_EBADCOOKIE]             = EBADCOOKIE,
343         [LUSTRE_ENOTSUPP]               = ENOTSUPP,
344         [LUSTRE_ETOOSMALL]              = ETOOSMALL,
345         [LUSTRE_ESERVERFAULT]           = ESERVERFAULT,
346         [LUSTRE_EBADTYPE]               = EBADTYPE,
347         [LUSTRE_EJUKEBOX]               = EJUKEBOX,
348         [LUSTRE_EIOCBQUEUED]            = EIOCBQUEUED,
349
350         /*
351          * The ELDLM errors are Lustre specific errors whose ranges
352          * lie in the middle of the above system errors. The ELDLM
353          * numbers must be preserved to avoid LU-9793.
354          */
355         [ELDLM_LOCK_CHANGED]            = ELDLM_LOCK_CHANGED,
356         [ELDLM_LOCK_ABORTED]            = ELDLM_LOCK_ABORTED,
357         [ELDLM_LOCK_REPLACED]           = ELDLM_LOCK_REPLACED,
358         [ELDLM_NO_LOCK_DATA]            = ELDLM_NO_LOCK_DATA,
359         [ELDLM_LOCK_WOULDBLOCK]         = ELDLM_LOCK_WOULDBLOCK,
360         [ELDLM_NAMESPACE_EXISTS]        = ELDLM_NAMESPACE_EXISTS,
361         [ELDLM_BAD_NAMESPACE]           = ELDLM_BAD_NAMESPACE
362 };
363
364 unsigned int lustre_errno_hton(unsigned int h)
365 {
366         unsigned int n;
367
368         if (h == 0) {
369                 n = 0;
370         } else if (h < ARRAY_SIZE(lustre_errno_hton_mapping)) {
371                 n = lustre_errno_hton_mapping[h];
372                 if (n == 0)
373                         goto generic;
374         } else {
375 generic:
376                 /*
377                  * A generic errno is better than the unknown one that could
378                  * mean anything to a different host.
379                  */
380                 n = LUSTRE_EIO;
381         }
382
383         return n;
384 }
385 EXPORT_SYMBOL(lustre_errno_hton);
386
387 unsigned int lustre_errno_ntoh(unsigned int n)
388 {
389         unsigned int h;
390
391         if (n == 0) {
392                 h = 0;
393         } else if (n < ARRAY_SIZE(lustre_errno_ntoh_mapping)) {
394                 h = lustre_errno_ntoh_mapping[n];
395                 if (h == 0)
396                         goto generic;
397         } else {
398 generic:
399                 /*
400                  * Similar to the situation in lustre_errno_hton(), an unknown
401                  * network errno could coincide with anything.  Hence, it is
402                  * better to return a generic errno.
403                  */
404                 h = EIO;
405         }
406
407         return h;
408 }
409 EXPORT_SYMBOL(lustre_errno_ntoh);
410
411 #endif /* LUSTRE_TRANSLATE_ERRNOS */