2 Unix SMB/CIFS implementation.
3 Copyright (C) Andrew Tridgell 1998-2003
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.
23 error code stuff - put together by Merik Karman
24 merik@blackadder.dsh.oz.au
27 struct err_code_struct {
33 /* Dos Error Messages */
34 static const struct err_code_struct dos_msgs[] = {
35 {"ERRbadfunc",ERRbadfunc,"Invalid function."},
36 {"ERRbadfile",ERRbadfile,"File not found."},
37 {"ERRbadpath",ERRbadpath,"Directory invalid."},
38 {"ERRnofids",ERRnofids,"No file descriptors available"},
39 {"ERRnoaccess",ERRnoaccess,"Access denied."},
40 {"ERRbadfid",ERRbadfid,"Invalid file handle."},
41 {"ERRbadmcb",ERRbadmcb,"Memory control blocks destroyed."},
42 {"ERRnomem",ERRnomem,"Insufficient server memory to perform the requested function."},
43 {"ERRbadmem",ERRbadmem,"Invalid memory block address."},
44 {"ERRbadenv",ERRbadenv,"Invalid environment."},
45 {"ERRbadformat",11,"Invalid format."},
46 {"ERRbadaccess",ERRbadaccess,"Invalid open mode."},
47 {"ERRbaddata",ERRbaddata,"Invalid data."},
48 {"ERRres",ERRres,"reserved."},
49 {"ERRbaddrive",ERRbaddrive,"Invalid drive specified."},
50 {"ERRremcd",ERRremcd,"A Delete Directory request attempted to remove the server's current directory."},
51 {"ERRdiffdevice",ERRdiffdevice,"Not same device."},
52 {"ERRnofiles",ERRnofiles,"A File Search command can find no more files matching the specified criteria."},
53 {"ERRbadshare",ERRbadshare,"The sharing mode specified for an Open conflicts with existing FIDs on the file."},
54 {"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."},
55 {"ERRunsup", ERRunsup, "The operation is unsupported"},
56 {"ERRnosuchshare", ERRnosuchshare, "You specified an invalid share name"},
57 {"ERRfilexists",ERRfilexists,"The file named in a Create Directory, Make New File or Link request already exists."},
58 {"ERRinvalidname",ERRinvalidname, "Invalid name"},
59 {"ERRbadpipe",ERRbadpipe,"Pipe invalid."},
60 {"ERRpipebusy",ERRpipebusy,"All instances of the requested pipe are busy."},
61 {"ERRpipeclosing",ERRpipeclosing,"Pipe close in progress."},
62 {"ERRnotconnected",ERRnotconnected,"No process on other end of pipe."},
63 {"ERRmoredata",ERRmoredata,"There is more data to be returned."},
64 {"ERRinvgroup",ERRinvgroup,"Invalid workgroup (try the -W option)"},
65 {"ERRlogonfailure",ERRlogonfailure,"Logon failure"},
66 {"ERRdiskfull",ERRdiskfull,"Disk full"},
67 {"ERRgeneral",ERRgeneral, "General failure"},
68 {"ERRunknownlevel",ERRunknownlevel, "Unknown info level"},
71 /* Server Error Messages */
72 static const struct err_code_struct server_msgs[] = {
73 {"ERRerror",1,"Non-specific error code."},
74 {"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
75 {"ERRbadtype",3,"reserved."},
76 {"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."},
77 {"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."},
78 {"ERRinvnetname",6,"Invalid network name in tree connect."},
79 {"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."},
80 {"ERRqfull",49,"Print queue full (files) -- returned by open print file."},
81 {"ERRqtoobig",50,"Print queue full -- no space."},
82 {"ERRqeof",51,"EOF on print queue dump."},
83 {"ERRinvpfid",52,"Invalid print file FID."},
84 {"ERRsmbcmd",64,"The server did not recognize the command received."},
85 {"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."},
86 {"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."},
87 {"ERRreserved",68,"reserved."},
88 {"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."},
89 {"ERRreserved",70,"reserved."},
90 {"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."},
91 {"ERRpaused",81,"Server is paused."},
92 {"ERRmsgoff",82,"Not receiving messages."},
93 {"ERRnoroom",83,"No room to buffer message."},
94 {"ERRrmuns",87,"Too many remote user names."},
95 {"ERRtimeout",88,"Operation timed out."},
96 {"ERRnoresource",89,"No resources currently available for request."},
97 {"ERRtoomanyuids",90,"Too many UIDs active on this session."},
98 {"ERRbaduid",91,"The UID is not known as a valid ID on this session."},
99 {"ERRusempx",250,"Temp unable to support Raw, use MPX mode."},
100 {"ERRusestd",251,"Temp unable to support Raw, use standard read/write."},
101 {"ERRcontmpx",252,"Continue in MPX mode."},
102 {"ERRreserved",253,"reserved."},
103 {"ERRreserved",254,"reserved."},
104 {"ERRnosupport",0xFFFF,"Function not supported."},
107 /* Hard Error Messages */
108 static const struct err_code_struct hard_msgs[] = {
109 {"ERRnowrite",19,"Attempt to write on write-protected diskette."},
110 {"ERRbadunit",20,"Unknown unit."},
111 {"ERRnotready",21,"Drive not ready."},
112 {"ERRbadcmd",22,"Unknown command."},
113 {"ERRdata",23,"Data error (CRC)."},
114 {"ERRbadreq",24,"Bad request structure length."},
115 {"ERRseek",25 ,"Seek error."},
116 {"ERRbadmedia",26,"Unknown media type."},
117 {"ERRbadsector",27,"Sector not found."},
118 {"ERRnopaper",28,"Printer out of paper."},
119 {"ERRwrite",29,"Write fault."},
120 {"ERRread",30,"Read fault."},
121 {"ERRgeneral",31,"General failure."},
122 {"ERRbadshare",32,"An open conflicts with an existing open."},
123 {"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."},
124 {"ERRwrongdisk",34,"The wrong disk was found in a drive."},
125 {"ERRFCBUnavail",35,"No FCBs are available to process request."},
126 {"ERRsharebufexc",36,"A sharing buffer has been exceeded."},
130 static const struct {
132 const char *class_name;
133 const struct err_code_struct *err_msgs;
136 {0x01,"ERRDOS",dos_msgs},
137 {0x02,"ERRSRV",server_msgs},
138 {0x03,"ERRHRD",hard_msgs},
139 {0x04,"ERRXOS",NULL},
140 {0xE1,"ERRRMX1",NULL},
141 {0xE2,"ERRRMX2",NULL},
142 {0xE3,"ERRRMX3",NULL},
143 {0xFF,"ERRCMD",NULL},
147 /* return a dos error string given a error class and error code */
148 const char *dos_errstr(uint8 class, uint16_t code)
152 const struct err_code_struct *err_msgs;
159 for (i=0;err_classes[i].class_name;i++) {
160 if (class == err_classes[i].class) break;
162 if (!err_classes[i].class_name) {
163 asprintf(&msg, "Unknown DOS error %d:%d\n", class, code);
167 err_msgs = err_classes[i].err_msgs;
169 for (j=0;err_msgs && err_msgs[j].name;j++) {
170 if (err_msgs[j].code == code) {
171 asprintf(&msg, "%s:%s (%s)\n",
172 err_classes[i].class_name,
174 err_msgs[j].message);
179 asprintf(&msg, "Unknown DOS error %s:%d\n", err_classes[i].class_name, code);