2 Unix SMB/Netbios implementation.
5 Copyright (C) Andrew Tridgell 1998
8 The Free Software Foundation, Inc.
10 This file is part of the Midnight Commander.
12 The Midnight Commander is free software: you can redistribute it
13 and/or modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation, either version 3 of the License,
15 or (at your option) any later version.
17 The Midnight Commander is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
30 extern int DEBUGLEVEL
;
32 /* error code stuff - put together by Merik Karman
33 merik@blackadder.dsh.oz.au */
42 /* Dos Error Messages */
43 static err_code_struct
const dos_msgs
[] = {
44 {"ERRbadfunc", 1, "Invalid function."},
45 {"ERRbadfile", 2, "File not found."},
46 {"ERRbadpath", 3, "Directory invalid."},
47 {"ERRnofids", 4, "No file descriptors available"},
48 {"ERRnoaccess", 5, "Access denied."},
49 {"ERRbadfid", 6, "Invalid file handle."},
50 {"ERRbadmcb", 7, "Memory control blocks destroyed."},
51 {"ERRnomem", 8, "Insufficient server memory to perform the requested function."},
52 {"ERRbadmem", 9, "Invalid memory block address."},
53 {"ERRbadenv", 10, "Invalid environment."},
54 {"ERRbadformat", 11, "Invalid format."},
55 {"ERRbadaccess", 12, "Invalid open mode."},
56 {"ERRbaddata", 13, "Invalid data."},
57 {"ERR", 14, "reserved."},
58 {"ERRbaddrive", 15, "Invalid drive specified."},
60 "A Delete Directory request attempted to remove the server's current directory."},
61 {"ERRdiffdevice", 17, "Not same device."},
63 "A File Search command can find no more files matching the specified criteria."},
65 "The sharing mode specified for an Open conflicts with existing FIDs on the file."},
67 "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
68 {"ERRunsup", 50, "The operation is unsupported"},
69 {"ERRnosuchshare", 67, "You specified an invalid share name"},
71 "The file named in a Create Directory, Make New File or Link request already exists."},
72 {"ERRbadpipe", 230, "Pipe invalid."},
73 {"ERRpipebusy", 231, "All instances of the requested pipe are busy."},
74 {"ERRpipeclosing", 232, "Pipe close in progress."},
75 {"ERRnotconnected", 233, "No process on other end of pipe."},
76 {"ERRmoredata", 234, "There is more data to be returned."},
77 {"ERRinvgroup", 2455, "Invalid workgroup (try the -W option)"},
81 /* Server Error Messages */
82 static err_code_struct
const server_msgs
[] = {
83 {"ERRerror", 1, "Non-specific error code."},
85 "Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
86 {"ERRbadtype", 3, "reserved."},
88 "The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID."},
89 {"ERRinvnid", 5, "The tree ID (TID) specified in a command was invalid."},
90 {"ERRinvnetname", 6, "Invalid network name in tree connect."},
92 "Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."},
93 {"ERRqfull", 49, "Print queue full (files) -- returned by open print file."},
94 {"ERRqtoobig", 50, "Print queue full -- no space."},
95 {"ERRqeof", 51, "EOF on print queue dump."},
96 {"ERRinvpfid", 52, "Invalid print file FID."},
97 {"ERRsmbcmd", 64, "The server did not recognize the command received."},
98 {"ERRsrverror", 65, "The server encountered an internal error, e.g., system file unavailable."},
100 "The file handle (FID) and pathname parameters contained an invalid combination of values."},
101 {"ERRreserved", 68, "reserved."},
102 {"ERRbadpermits", 69,
103 "The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."},
104 {"ERRreserved", 70, "reserved."},
105 {"ERRsetattrmode", 71, "The attribute mode in the Set File Attribute request is invalid."},
106 {"ERRpaused", 81, "Server is paused."},
107 {"ERRmsgoff", 82, "Not receiving messages."},
108 {"ERRnoroom", 83, "No room to buffer message."},
109 {"ERRrmuns", 87, "Too many remote user names."},
110 {"ERRtimeout", 88, "Operation timed out."},
111 {"ERRnoresource", 89, "No resources currently available for request."},
112 {"ERRtoomanyuids", 90, "Too many UIDs active on this session."},
113 {"ERRbaduid", 91, "The UID is not known as a valid ID on this session."},
114 {"ERRusempx", 250, "Temp unable to support Raw, use MPX mode."},
115 {"ERRusestd", 251, "Temp unable to support Raw, use standard read/write."},
116 {"ERRcontmpx", 252, "Continue in MPX mode."},
117 {"ERRreserved", 253, "reserved."},
118 {"ERRreserved", 254, "reserved."},
119 {"ERRnosupport", 0xFFFF, "Function not supported."},
123 /* Hard Error Messages */
124 static err_code_struct
const hard_msgs
[] = {
125 {"ERRnowrite", 19, "Attempt to write on write-protected diskette."},
126 {"ERRbadunit", 20, "Unknown unit."},
127 {"ERRnotready", 21, "Drive not ready."},
128 {"ERRbadcmd", 22, "Unknown command."},
129 {"ERRdata", 23, "Data error (CRC)."},
130 {"ERRbadreq", 24, "Bad request structure length."},
131 {"ERRseek", 25, "Seek error."},
132 {"ERRbadmedia", 26, "Unknown media type."},
133 {"ERRbadsector", 27, "Sector not found."},
134 {"ERRnopaper", 28, "Printer out of paper."},
135 {"ERRwrite", 29, "Write fault."},
136 {"ERRread", 30, "Read fault."},
137 {"ERRgeneral", 31, "General failure."},
138 {"ERRbadshare", 32, "An open conflicts with an existing open."},
140 "A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
141 {"ERRwrongdisk", 34, "The wrong disk was found in a drive."},
142 {"ERRFCBUnavail", 35, "No FCBs are available to process request."},
143 {"ERRsharebufexc", 36, "A sharing buffer has been exceeded."},
152 err_code_struct
const *err_msgs
;
153 } const err_classes
[] = {
154 {0, "SUCCESS", NULL
},
155 {0x01, "ERRDOS", dos_msgs
},
156 {0x02, "ERRSRV", server_msgs
},
157 {0x03, "ERRHRD", hard_msgs
},
158 {0x04, "ERRXOS", NULL
},
159 {0xE1, "ERRRMX1", NULL
},
160 {0xE2, "ERRRMX2", NULL
},
161 {0xE3, "ERRRMX3", NULL
},
162 {0xFF, "ERRCMD", NULL
},
167 /****************************************************************************
168 return a SMB error string from a SMB buffer
169 ****************************************************************************/
171 smb_errstr (char *inbuf
)
174 int class = CVAL (inbuf
, smb_rcls
);
175 int num
= SVAL (inbuf
, smb_err
);
178 for (i
= 0; err_classes
[i
].class; i
++)
179 if (err_classes
[i
].code
== class)
181 if (err_classes
[i
].err_msgs
)
183 const err_code_struct
*err
= err_classes
[i
].err_msgs
;
184 for (j
= 0; err
[j
].name
; j
++)
185 if (num
== err
[j
].code
)
188 slprintf (ret
, sizeof (ret
) - 1, "%s - %s (%s)", err_classes
[i
].class,
189 err
[j
].name
, err
[j
].message
);
191 slprintf (ret
, sizeof (ret
) - 1, "%s - %s", err_classes
[i
].class,
197 slprintf (ret
, sizeof (ret
) - 1, "%s - %d", err_classes
[i
].class, num
);
201 slprintf (ret
, sizeof (ret
) - 1, "Error: Unknown error (%d,%d)", class, num
);