1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see [sun.com URL with a
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
39 * miscellaneous libcfs stuff
41 #define DEBUG_SUBSYSTEM S_LNET
42 #include <lnet/types.h>
45 * Convert server error code to client format. Error codes are from
46 * Linux errno.h, so for Linux client---identity.
48 int convert_server_error(__u64 ecode)
50 return cfs_error_code((NTSTATUS)ecode);
54 * convert <fcntl.h> flag from client to server.
56 * nt kernel uses several members to describe the open flags
57 * such as DesiredAccess/ShareAccess/CreateDisposition/CreateOptions
58 * so it's better to convert when using, not here.
61 int convert_client_oflag(int cflag, int *result)
68 int cfs_error_code(NTSTATUS Status)
72 case STATUS_ACCESS_DENIED:
75 case STATUS_ACCESS_VIOLATION:
78 case STATUS_BUFFER_TOO_SMALL:
81 case STATUS_INVALID_PARAMETER:
84 case STATUS_NOT_IMPLEMENTED:
85 case STATUS_NOT_SUPPORTED:
88 case STATUS_INVALID_ADDRESS:
89 case STATUS_INVALID_ADDRESS_COMPONENT:
90 return (-EADDRNOTAVAIL);
92 case STATUS_NO_SUCH_DEVICE:
93 case STATUS_NO_SUCH_FILE:
94 case STATUS_OBJECT_NAME_NOT_FOUND:
95 case STATUS_OBJECT_PATH_NOT_FOUND:
96 case STATUS_NETWORK_BUSY:
97 case STATUS_INVALID_NETWORK_RESPONSE:
98 case STATUS_UNEXPECTED_NETWORK_ERROR:
101 case STATUS_BAD_NETWORK_PATH:
102 case STATUS_NETWORK_UNREACHABLE:
103 case STATUS_PROTOCOL_UNREACHABLE:
104 return (-ENETUNREACH);
106 case STATUS_LOCAL_DISCONNECT:
107 case STATUS_TRANSACTION_ABORTED:
108 case STATUS_CONNECTION_ABORTED:
109 return (-ECONNABORTED);
111 case STATUS_REMOTE_DISCONNECT:
112 case STATUS_LINK_FAILED:
113 case STATUS_CONNECTION_DISCONNECTED:
114 case STATUS_CONNECTION_RESET:
115 case STATUS_PORT_UNREACHABLE:
116 return (-ECONNRESET);
118 case STATUS_PAGEFILE_QUOTA:
119 case STATUS_NO_MEMORY:
120 case STATUS_CONFLICTING_ADDRESSES:
121 case STATUS_QUOTA_EXCEEDED:
122 case STATUS_TOO_MANY_PAGING_FILES:
123 case STATUS_INSUFFICIENT_RESOURCES:
124 case STATUS_WORKING_SET_QUOTA:
125 case STATUS_COMMITMENT_LIMIT:
126 case STATUS_TOO_MANY_ADDRESSES:
127 case STATUS_REMOTE_RESOURCES:
130 case STATUS_INVALID_CONNECTION:
133 case STATUS_PIPE_DISCONNECTED:
137 case STATUS_IO_TIMEOUT:
138 case STATUS_LINK_TIMEOUT:
141 case STATUS_REMOTE_NOT_LISTENING:
142 case STATUS_CONNECTION_REFUSED:
143 return (-ECONNREFUSED);
145 case STATUS_HOST_UNREACHABLE:
146 return (-EHOSTUNREACH);
149 case STATUS_DEVICE_NOT_READY:
152 case STATUS_CANCELLED:
153 case STATUS_REQUEST_ABORTED:
156 case STATUS_BUFFER_OVERFLOW:
157 case STATUS_INVALID_BUFFER_SIZE:
162 if (NT_SUCCESS(Status))
169 void cfs_stack_trace_fill(struct cfs_stack_trace *trace)
173 void *cfs_stack_trace_frame(struct cfs_stack_trace *trace, int frame_no)