00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "includes.h"
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 typedef const struct
00037 {
00038 const char *name;
00039 int code;
00040 const char *message;
00041 } err_code_struct;
00042
00043
00044 err_code_struct dos_msgs[] = {
00045 {"ERRbadfunc",ERRbadfunc,"Invalid function."},
00046 {"ERRbadfile",ERRbadfile,"File not found."},
00047 {"ERRbadpath",ERRbadpath,"Directory invalid."},
00048 {"ERRnofids",ERRnofids,"No file descriptors available"},
00049 {"ERRnoaccess",ERRnoaccess,"Access denied."},
00050 {"ERRbadfid",ERRbadfid,"Invalid file handle."},
00051 {"ERRbadmcb",ERRbadmcb,"Memory control blocks destroyed."},
00052 {"ERRnomem",ERRnomem,"Insufficient server memory to perform the requested function."},
00053 {"ERRbadmem",ERRbadmem,"Invalid memory block address."},
00054 {"ERRbadenv",ERRbadenv,"Invalid environment."},
00055 {"ERRbadformat",11,"Invalid format."},
00056 {"ERRbadaccess",ERRbadaccess,"Invalid open mode."},
00057 {"ERRbaddata",ERRbaddata,"Invalid data."},
00058 {"ERRres",ERRres,"reserved."},
00059 {"ERRbaddrive",ERRbaddrive,"Invalid drive specified."},
00060 {"ERRremcd",ERRremcd,"A Delete Directory request attempted to remove the server's current directory."},
00061 {"ERRdiffdevice",ERRdiffdevice,"Not same device."},
00062 {"ERRnofiles",ERRnofiles,"A File Search command can find no more files matching the specified criteria."},
00063 {"ERRbadshare",ERRbadshare,"The sharing mode specified for an Open conflicts with existing FIDs on the file."},
00064 {"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."},
00065 {"ERRunsup", ERRunsup, "The operation is unsupported"},
00066 {"ERRnosuchshare", ERRnosuchshare, "You specified an invalid share name"},
00067 {"ERRfilexists",ERRfilexists,"The file named in a Create Directory, Make New File or Link request already exists."},
00068 {"ERRinvalidname",ERRinvalidname, "Invalid name"},
00069 {"ERRbadpipe",ERRbadpipe,"Pipe invalid."},
00070 {"ERRpipebusy",ERRpipebusy,"All instances of the requested pipe are busy."},
00071 {"ERRpipeclosing",ERRpipeclosing,"Pipe close in progress."},
00072 {"ERRnotconnected",ERRnotconnected,"No process on other end of pipe."},
00073 {"ERRmoredata",ERRmoredata,"There is more data to be returned."},
00074 {"ERRinvgroup",ERRinvgroup,"Invalid workgroup (try the -W option)"},
00075 {"ERRlogonfailure",ERRlogonfailure,"Logon failure"},
00076 {"ERRdiskfull",ERRdiskfull,"Disk full"},
00077 {"ERRgeneral",ERRgeneral, "General failure"},
00078 {"ERRbaddirectory", ERRbaddirectory, "Bad directory name"},
00079 {"ERRunknownlevel",ERRunknownlevel, "Unknown info level"},
00080 {NULL,-1,NULL}};
00081
00082
00083 err_code_struct server_msgs[] = {
00084 {"ERRerror",1,"Non-specific error code."},
00085 {"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
00086 {"ERRbadtype",3,"reserved."},
00087 {"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."},
00088 {"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."},
00089 {"ERRinvnetname",6,"Invalid network name in tree connect."},
00090 {"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."},
00091 {"ERRqfull",49,"Print queue full (files) -- returned by open print file."},
00092 {"ERRqtoobig",50,"Print queue full -- no space."},
00093 {"ERRqeof",51,"EOF on print queue dump."},
00094 {"ERRinvpfid",52,"Invalid print file FID."},
00095 {"ERRsmbcmd",64,"The server did not recognize the command received."},
00096 {"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."},
00097 {"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."},
00098 {"ERRreserved",68,"reserved."},
00099 {"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."},
00100 {"ERRreserved",70,"reserved."},
00101 {"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."},
00102 {"ERRpaused",81,"Server is paused."},
00103 {"ERRmsgoff",82,"Not receiving messages."},
00104 {"ERRnoroom",83,"No room to buffer message."},
00105 {"ERRrmuns",87,"Too many remote user names."},
00106 {"ERRtimeout",88,"Operation timed out."},
00107 {"ERRnoresource",89,"No resources currently available for request."},
00108 {"ERRtoomanyuids",90,"Too many UIDs active on this session."},
00109 {"ERRbaduid",91,"The UID is not known as a valid ID on this session."},
00110 {"ERRusempx",250,"Temp unable to support Raw, use MPX mode."},
00111 {"ERRusestd",251,"Temp unable to support Raw, use standard read/write."},
00112 {"ERRcontmpx",252,"Continue in MPX mode."},
00113 {"ERRreserved",253,"reserved."},
00114 {"ERRreserved",254,"reserved."},
00115 {"ERRnosupport",0xFFFF,"Function not supported."},
00116 {NULL,-1,NULL}};
00117
00118
00119 err_code_struct hard_msgs[] = {
00120 {"ERRnowrite",19,"Attempt to write on write-protected diskette."},
00121 {"ERRbadunit",20,"Unknown unit."},
00122 {"ERRnotready",21,"Drive not ready."},
00123 {"ERRbadcmd",22,"Unknown command."},
00124 {"ERRdata",23,"Data error (CRC)."},
00125 {"ERRbadreq",24,"Bad request structure length."},
00126 {"ERRseek",25 ,"Seek error."},
00127 {"ERRbadmedia",26,"Unknown media type."},
00128 {"ERRbadsector",27,"Sector not found."},
00129 {"ERRnopaper",28,"Printer out of paper."},
00130 {"ERRwrite",29,"Write fault."},
00131 {"ERRread",30,"Read fault."},
00132 {"ERRgeneral",31,"General failure."},
00133 {"ERRbadshare",32,"An open conflicts with an existing open."},
00134 {"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."},
00135 {"ERRwrongdisk",34,"The wrong disk was found in a drive."},
00136 {"ERRFCBUnavail",35,"No FCBs are available to process request."},
00137 {"ERRsharebufexc",36,"A sharing buffer has been exceeded."},
00138 {NULL,-1,NULL}};
00139
00140
00141 const struct
00142 {
00143 int code;
00144 const char *e_class;
00145 err_code_struct *err_msgs;
00146 } err_classes[] = {
00147 {0,"SUCCESS",NULL},
00148 {0x01,"ERRDOS",dos_msgs},
00149 {0x02,"ERRSRV",server_msgs},
00150 {0x03,"ERRHRD",hard_msgs},
00151 {0x04,"ERRXOS",NULL},
00152 {0xE1,"ERRRMX1",NULL},
00153 {0xE2,"ERRRMX2",NULL},
00154 {0xE3,"ERRRMX3",NULL},
00155 {0xFF,"ERRCMD",NULL},
00156 {-1,NULL,NULL}};
00157
00158
00159
00160
00161
00162 const char *smb_dos_err_name(uint8 e_class, uint16 num)
00163 {
00164 static pstring ret;
00165 int i,j;
00166
00167 for (i=0;err_classes[i].e_class;i++)
00168 if (err_classes[i].code == e_class) {
00169 if (err_classes[i].err_msgs) {
00170 err_code_struct *err = err_classes[i].err_msgs;
00171 for (j=0;err[j].name;j++)
00172 if (num == err[j].code) {
00173 return err[j].name;
00174 }
00175 }
00176 slprintf(ret, sizeof(ret) - 1, "%d",num);
00177 return ret;
00178 }
00179
00180 slprintf(ret, sizeof(ret) - 1, "Error: Unknown error class (%d,%d)",e_class,num);
00181 return(ret);
00182 }
00183
00184
00185
00186 const char *get_dos_error_msg(WERROR result)
00187 {
00188 uint16 errnum;
00189
00190 errnum = W_ERROR_V(result);
00191
00192 return smb_dos_err_name(ERRDOS, errnum);
00193 }
00194
00195
00196
00197
00198 const char *smb_dos_err_class(uint8 e_class)
00199 {
00200 static pstring ret;
00201 int i;
00202
00203 for (i=0;err_classes[i].e_class;i++) {
00204 if (err_classes[i].code == e_class) {
00205 return err_classes[i].e_class;
00206 }
00207 }
00208
00209 slprintf(ret, sizeof(ret) - 1, "Error: Unknown class (%d)",e_class);
00210 return(ret);
00211 }
00212
00213
00214
00215
00216 char *smb_dos_errstr(char *inbuf)
00217 {
00218 static pstring ret;
00219 int e_class = CVAL(inbuf,smb_rcls);
00220 int num = SVAL(inbuf,smb_err);
00221 int i,j;
00222
00223 for (i=0;err_classes[i].e_class;i++)
00224 if (err_classes[i].code == e_class) {
00225 if (err_classes[i].err_msgs) {
00226 err_code_struct *err = err_classes[i].err_msgs;
00227 for (j=0;err[j].name;j++)
00228 if (num == err[j].code) {
00229 if (DEBUGLEVEL > 0)
00230 slprintf(ret, sizeof(ret) - 1, "%s - %s (%s)",
00231 err_classes[i].e_class,
00232 err[j].name,err[j].message);
00233 else
00234 slprintf(ret, sizeof(ret) - 1, "%s - %s",
00235 err_classes[i].e_class,err[j].name);
00236 return ret;
00237 }
00238 }
00239
00240 slprintf(ret, sizeof(ret) - 1, "%s - %d",err_classes[i].e_class,num);
00241 return ret;
00242 }
00243
00244 slprintf(ret, sizeof(ret) - 1, "Error: Unknown error (%d,%d)",e_class,num);
00245 return(ret);
00246 }
00247
00248
00249
00250
00251 WERROR map_werror_from_unix(int error)
00252 {
00253 NTSTATUS status = map_nt_error_from_unix(error);
00254 return ntstatus_to_werror(status);
00255 }