r3780: final release notes
[Samba.git] / source / libsmb / smberr.c
blob82efbdb6898ac2d9b4fc66b1e0a4e51bac6f49e1
1 /*
2 Unix SMB/CIFS implementation.
3 Copyright (C) Andrew Tridgell 1998
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #define NO_SYSLOG
22 #include "includes.h"
24 /* error code stuff - put together by Merik Karman
25 merik@blackadder.dsh.oz.au */
28 /* There is a big list of error codes and their meanings at:
30 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/errlist_7oz7.asp
32 and if you don't like MSDN try:
34 http://www.siris.gr/computers/library/error.htm
38 typedef const struct
40 const char *name;
41 int code;
42 const char *message;
43 } err_code_struct;
45 /* Dos Error Messages */
46 err_code_struct dos_msgs[] = {
47 {"ERRbadfunc",ERRbadfunc,"Invalid function."},
48 {"ERRbadfile",ERRbadfile,"File not found."},
49 {"ERRbadpath",ERRbadpath,"Directory invalid."},
50 {"ERRnofids",ERRnofids,"No file descriptors available"},
51 {"ERRnoaccess",ERRnoaccess,"Access denied."},
52 {"ERRbadfid",ERRbadfid,"Invalid file handle."},
53 {"ERRbadmcb",ERRbadmcb,"Memory control blocks destroyed."},
54 {"ERRnomem",ERRnomem,"Insufficient server memory to perform the requested function."},
55 {"ERRbadmem",ERRbadmem,"Invalid memory block address."},
56 {"ERRbadenv",ERRbadenv,"Invalid environment."},
57 {"ERRbadformat",11,"Invalid format."},
58 {"ERRbadaccess",ERRbadaccess,"Invalid open mode."},
59 {"ERRbaddata",ERRbaddata,"Invalid data."},
60 {"ERRres",ERRres,"reserved."},
61 {"ERRbaddrive",ERRbaddrive,"Invalid drive specified."},
62 {"ERRremcd",ERRremcd,"A Delete Directory request attempted to remove the server's current directory."},
63 {"ERRdiffdevice",ERRdiffdevice,"Not same device."},
64 {"ERRnofiles",ERRnofiles,"A File Search command can find no more files matching the specified criteria."},
65 {"ERRbadshare",ERRbadshare,"The sharing mode specified for an Open conflicts with existing FIDs on the file."},
66 {"ERRlock",ERRlock,"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."},
67 {"ERRunsup", ERRunsup, "The operation is unsupported"},
68 {"ERRnosuchshare", ERRnosuchshare, "You specified an invalid share name"},
69 {"ERRfilexists",ERRfilexists,"The file named in a Create Directory, Make New File or Link request already exists."},
70 {"ERRinvalidname",ERRinvalidname, "Invalid name"},
71 {"ERRbadpipe",ERRbadpipe,"Pipe invalid."},
72 {"ERRpipebusy",ERRpipebusy,"All instances of the requested pipe are busy."},
73 {"ERRpipeclosing",ERRpipeclosing,"Pipe close in progress."},
74 {"ERRnotconnected",ERRnotconnected,"No process on other end of pipe."},
75 {"ERRmoredata",ERRmoredata,"There is more data to be returned."},
76 {"ERRinvgroup",ERRinvgroup,"Invalid workgroup (try the -W option)"},
77 {"ERRlogonfailure",ERRlogonfailure,"Logon failure"},
78 {"ERRdiskfull",ERRdiskfull,"Disk full"},
79 {"ERRgeneral",ERRgeneral, "General failure"},
80 {"ERRunknownlevel",ERRunknownlevel, "Unknown info level"},
81 {NULL,-1,NULL}};
83 /* Server Error Messages */
84 err_code_struct server_msgs[] = {
85 {"ERRerror",1,"Non-specific error code."},
86 {"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
87 {"ERRbadtype",3,"reserved."},
88 {"ERRaccess",4,"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."},
91 {"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."},
92 {"ERRqfull",49,"Print queue full (files) -- returned by open print file."},
93 {"ERRqtoobig",50,"Print queue full -- no space."},
94 {"ERRqeof",51,"EOF on print queue dump."},
95 {"ERRinvpfid",52,"Invalid print file FID."},
96 {"ERRsmbcmd",64,"The server did not recognize the command received."},
97 {"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."},
98 {"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."},
99 {"ERRreserved",68,"reserved."},
100 {"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."},
101 {"ERRreserved",70,"reserved."},
102 {"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."},
103 {"ERRpaused",81,"Server is paused."},
104 {"ERRmsgoff",82,"Not receiving messages."},
105 {"ERRnoroom",83,"No room to buffer message."},
106 {"ERRrmuns",87,"Too many remote user names."},
107 {"ERRtimeout",88,"Operation timed out."},
108 {"ERRnoresource",89,"No resources currently available for request."},
109 {"ERRtoomanyuids",90,"Too many UIDs active on this session."},
110 {"ERRbaduid",91,"The UID is not known as a valid ID on this session."},
111 {"ERRusempx",250,"Temp unable to support Raw, use MPX mode."},
112 {"ERRusestd",251,"Temp unable to support Raw, use standard read/write."},
113 {"ERRcontmpx",252,"Continue in MPX mode."},
114 {"ERRreserved",253,"reserved."},
115 {"ERRreserved",254,"reserved."},
116 {"ERRnosupport",0xFFFF,"Function not supported."},
117 {NULL,-1,NULL}};
119 /* Hard Error Messages */
120 err_code_struct hard_msgs[] = {
121 {"ERRnowrite",19,"Attempt to write on write-protected diskette."},
122 {"ERRbadunit",20,"Unknown unit."},
123 {"ERRnotready",21,"Drive not ready."},
124 {"ERRbadcmd",22,"Unknown command."},
125 {"ERRdata",23,"Data error (CRC)."},
126 {"ERRbadreq",24,"Bad request structure length."},
127 {"ERRseek",25 ,"Seek error."},
128 {"ERRbadmedia",26,"Unknown media type."},
129 {"ERRbadsector",27,"Sector not found."},
130 {"ERRnopaper",28,"Printer out of paper."},
131 {"ERRwrite",29,"Write fault."},
132 {"ERRread",30,"Read fault."},
133 {"ERRgeneral",31,"General failure."},
134 {"ERRbadshare",32,"An open conflicts with an existing open."},
135 {"ERRlock",33,"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."},
136 {"ERRwrongdisk",34,"The wrong disk was found in a drive."},
137 {"ERRFCBUnavail",35,"No FCBs are available to process request."},
138 {"ERRsharebufexc",36,"A sharing buffer has been exceeded."},
139 {NULL,-1,NULL}};
142 const struct
144 int code;
145 const char *class;
146 err_code_struct *err_msgs;
147 } err_classes[] = {
148 {0,"SUCCESS",NULL},
149 {0x01,"ERRDOS",dos_msgs},
150 {0x02,"ERRSRV",server_msgs},
151 {0x03,"ERRHRD",hard_msgs},
152 {0x04,"ERRXOS",NULL},
153 {0xE1,"ERRRMX1",NULL},
154 {0xE2,"ERRRMX2",NULL},
155 {0xE3,"ERRRMX3",NULL},
156 {0xFF,"ERRCMD",NULL},
157 {-1,NULL,NULL}};
160 /****************************************************************************
161 return a SMB error name from a class and code
162 ****************************************************************************/
163 const char *smb_dos_err_name(uint8 class, uint16 num)
165 static pstring ret;
166 int i,j;
168 for (i=0;err_classes[i].class;i++)
169 if (err_classes[i].code == class) {
170 if (err_classes[i].err_msgs) {
171 err_code_struct *err = err_classes[i].err_msgs;
172 for (j=0;err[j].name;j++)
173 if (num == err[j].code) {
174 return err[j].name;
177 slprintf(ret, sizeof(ret) - 1, "%d",num);
178 return ret;
181 slprintf(ret, sizeof(ret) - 1, "Error: Unknown error class (%d,%d)",class,num);
182 return(ret);
185 /* Return a string for a DOS error */
187 const char *get_dos_error_msg(WERROR result)
189 uint16 errnum;
191 errnum = W_ERROR_V(result);
193 return smb_dos_err_name(ERRDOS, errnum);
196 /****************************************************************************
197 return a SMB error class name as a string.
198 ****************************************************************************/
199 const char *smb_dos_err_class(uint8 class)
201 static pstring ret;
202 int i;
204 for (i=0;err_classes[i].class;i++) {
205 if (err_classes[i].code == class) {
206 return err_classes[i].class;
210 slprintf(ret, sizeof(ret) - 1, "Error: Unknown class (%d)",class);
211 return(ret);
214 /****************************************************************************
215 return a SMB string from an SMB buffer
216 ****************************************************************************/
217 char *smb_dos_errstr(char *inbuf)
219 static pstring ret;
220 int class = CVAL(inbuf,smb_rcls);
221 int num = SVAL(inbuf,smb_err);
222 int i,j;
224 for (i=0;err_classes[i].class;i++)
225 if (err_classes[i].code == class) {
226 if (err_classes[i].err_msgs) {
227 err_code_struct *err = err_classes[i].err_msgs;
228 for (j=0;err[j].name;j++)
229 if (num == err[j].code) {
230 if (DEBUGLEVEL > 0)
231 slprintf(ret, sizeof(ret) - 1, "%s - %s (%s)",
232 err_classes[i].class,
233 err[j].name,err[j].message);
234 else
235 slprintf(ret, sizeof(ret) - 1, "%s - %s",
236 err_classes[i].class,err[j].name);
237 return ret;
241 slprintf(ret, sizeof(ret) - 1, "%s - %d",err_classes[i].class,num);
242 return ret;
245 slprintf(ret, sizeof(ret) - 1, "Error: Unknown error (%d,%d)",class,num);
246 return(ret);
249 /*****************************************************************************
250 map a unix errno to a win32 error
251 *****************************************************************************/
252 WERROR map_werror_from_unix(int error)
254 NTSTATUS status = map_nt_error_from_unix(error);
255 return ntstatus_to_werror(status);