1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=4:tabstop=4:
4 * Copyright (c) 2004 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or modify it under
9 * the terms of version 2 of the GNU General Public License as published by
10 * the Free Software Foundation. Lustre is distributed in the hope that it
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. You should have received a
14 * copy of the GNU General Public License along with Lustre; if not, write
15 * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
21 * miscellaneous libcfs stuff
23 #define DEBUG_SUBSYSTEM S_LNET
24 #include <lnet/types.h>
27 * Convert server error code to client format. Error codes are from
28 * Linux errno.h, so for Linux client---identity.
30 int convert_server_error(__u64 ecode)
32 return cfs_error_code((NTSTATUS)ecode);
36 * convert <fcntl.h> flag from client to server.
38 * nt kernel uses several members to describe the open flags
39 * such as DesiredAccess/ShareAccess/CreateDisposition/CreateOptions
40 * so it's better to convert when using, not here.
43 int convert_client_oflag(int cflag, int *result)
50 int cfs_error_code(NTSTATUS Status)
54 case STATUS_ACCESS_DENIED:
57 case STATUS_ACCESS_VIOLATION:
60 case STATUS_BUFFER_TOO_SMALL:
63 case STATUS_INVALID_PARAMETER:
66 case STATUS_NOT_IMPLEMENTED:
67 case STATUS_NOT_SUPPORTED:
70 case STATUS_INVALID_ADDRESS:
71 case STATUS_INVALID_ADDRESS_COMPONENT:
72 return (-EADDRNOTAVAIL);
74 case STATUS_NO_SUCH_DEVICE:
75 case STATUS_NO_SUCH_FILE:
76 case STATUS_OBJECT_NAME_NOT_FOUND:
77 case STATUS_OBJECT_PATH_NOT_FOUND:
78 case STATUS_NETWORK_BUSY:
79 case STATUS_INVALID_NETWORK_RESPONSE:
80 case STATUS_UNEXPECTED_NETWORK_ERROR:
83 case STATUS_BAD_NETWORK_PATH:
84 case STATUS_NETWORK_UNREACHABLE:
85 case STATUS_PROTOCOL_UNREACHABLE:
86 return (-ENETUNREACH);
88 case STATUS_LOCAL_DISCONNECT:
89 case STATUS_TRANSACTION_ABORTED:
90 case STATUS_CONNECTION_ABORTED:
91 return (-ECONNABORTED);
93 case STATUS_REMOTE_DISCONNECT:
94 case STATUS_LINK_FAILED:
95 case STATUS_CONNECTION_DISCONNECTED:
96 case STATUS_CONNECTION_RESET:
97 case STATUS_PORT_UNREACHABLE:
100 case STATUS_PAGEFILE_QUOTA:
101 case STATUS_NO_MEMORY:
102 case STATUS_CONFLICTING_ADDRESSES:
103 case STATUS_QUOTA_EXCEEDED:
104 case STATUS_TOO_MANY_PAGING_FILES:
105 case STATUS_INSUFFICIENT_RESOURCES:
106 case STATUS_WORKING_SET_QUOTA:
107 case STATUS_COMMITMENT_LIMIT:
108 case STATUS_TOO_MANY_ADDRESSES:
109 case STATUS_REMOTE_RESOURCES:
112 case STATUS_INVALID_CONNECTION:
115 case STATUS_PIPE_DISCONNECTED:
119 case STATUS_IO_TIMEOUT:
120 case STATUS_LINK_TIMEOUT:
123 case STATUS_REMOTE_NOT_LISTENING:
124 case STATUS_CONNECTION_REFUSED:
125 return (-ECONNREFUSED);
127 case STATUS_HOST_UNREACHABLE:
128 return (-EHOSTUNREACH);
131 case STATUS_DEVICE_NOT_READY:
134 case STATUS_CANCELLED:
135 case STATUS_REQUEST_ABORTED:
138 case STATUS_BUFFER_OVERFLOW:
139 case STATUS_INVALID_BUFFER_SIZE:
144 if (NT_SUCCESS(Status))
151 void cfs_stack_trace_fill(struct cfs_stack_trace *trace)
155 void *cfs_stack_trace_frame(struct cfs_stack_trace *trace, int frame_no)