LCOV - code coverage report
Current view: top level - source3/libsmb - smberr.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 0 32 0.0 %
Date: 2024-04-21 15:09:00 Functions: 0 4 0.0 %

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

Generated by: LCOV version 1.14