doserrstr.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #include <u.h>
  2. #include <libc.h>
  3. /*
  4. * This file is derrived from nterr.h in the samba distribution
  5. */
  6. /*
  7. Unix SMB/CIFS implementation.
  8. DOS error code constants
  9. Copyright (C) Andrew Tridgell 1992-2000
  10. Copyright (C) John H Terpstra 1996-2000
  11. Copyright (C) Luke Kenneth Casson Leighton 1996-2000
  12. Copyright (C) Paul Ashton 1998-2000
  13. This program is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2 of the License, or
  16. (at your option) any later version.
  17. This program 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.
  21. You should have received a copy of the GNU General Public License
  22. along with this program; if not, write to the Free Software
  23. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. static struct {
  26. int err;
  27. char *msg;
  28. } DOSerrs[] = {
  29. /* smb x/open error codes for the errdos error class */
  30. { (0<<16)|1, "no error" },
  31. { (1<<16)|1, "invalid function" },
  32. { (2<<16)|1, "file not found" },
  33. { (3<<16)|1, "directory not found" },
  34. { (4<<16)|1, "too many open files" },
  35. { (5<<16)|1, "access denied" },
  36. { (6<<16)|1, "invalid fid" },
  37. { (7<<16)|1, "memory control blocks destroyed." },
  38. { (8<<16)|1, "out of memory" },
  39. { (9<<16)|1, "invalid memory block address" },
  40. { (10<<16)|1, "invalid environment" },
  41. { (12<<16)|1, "invalid open mode" },
  42. { (13<<16)|1, "invalid data (only from ioctl call)" },
  43. { (14<<16)|1, "reserved" },
  44. { (15<<16)|1, "invalid drive" },
  45. { (16<<16)|1, "attempt to delete current directory" },
  46. { (17<<16)|1, "rename/move across filesystems" },
  47. { (18<<16)|1, "no more files found" },
  48. { (31<<16)|1, "general failure" },
  49. { (32<<16)|1, "share mode conflict with open mode" },
  50. { (33<<16)|1, "lock conflicts" },
  51. { (50<<16)|1, "request unsupported" },
  52. { (64<<16)|1, "network name not available" },
  53. { (66<<16)|1, "ipc unsupported (guess)" },
  54. { (67<<16)|1, "invalid share name" },
  55. { (80<<16)|1, "file already exists" },
  56. { (87<<16)|1, "invalid paramater" },
  57. { (110<<16)|1, "cannot open" },
  58. { (122<<16)|1, "insufficent buffer" },
  59. { (123<<16)|1, "invalid name" },
  60. { (124<<16)|1, "unknown level" },
  61. { (158<<16)|1, "this region already locked" },
  62. { (183<<16)|1, "rename failed" },
  63. { (230<<16)|1, "named pipe invalid" },
  64. { (231<<16)|1, "pipe busy" },
  65. { (232<<16)|1, "close in progress" },
  66. { (233<<16)|1, "no reader of named pipe" },
  67. { (234<<16)|1, "more data to be returned" },
  68. { (259<<16)|1, "no more items" },
  69. { (267<<16)|1, "invalid directory name in a path" },
  70. { (282<<16)|1, "extended attributes" },
  71. { (1326<<16)|1, "authentication failed" },
  72. { (2123<<16)|1, "buffer too small" },
  73. { (2142<<16)|1, "unknown ipc" },
  74. { (2151<<16)|1, "no such print job" },
  75. { (2455<<16)|1, "invalid group" },
  76. /* Error codes for the ERRSRV class */
  77. { (1<<16)|2, "non specific error" },
  78. { (2<<16)|2, "bad password" },
  79. { (3<<16)|2, "reserved" },
  80. { (4<<16)|2, "permission denied" },
  81. { (5<<16)|2, "tid invalid" },
  82. { (6<<16)|2, "invalid server name" },
  83. { (7<<16)|2, "invalid device" },
  84. { (22<<16)|2, "unknown smb" },
  85. { (49<<16)|2, "print queue full" },
  86. { (50<<16)|2, "queued item too big" },
  87. { (52<<16)|2, "fid invalid in print file" },
  88. { (64<<16)|2, "unrecognised command" },
  89. { (65<<16)|2, "smb server internal error" },
  90. { (67<<16)|2, "fid/pathname invalid" },
  91. { (68<<16)|2, "reserved 68" },
  92. { (69<<16)|2, "access is invalid" },
  93. { (70<<16)|2, "reserved 70" },
  94. { (71<<16)|2, "attribute mode invalid" },
  95. { (81<<16)|2, "message server paused" },
  96. { (82<<16)|2, "not receiving messages" },
  97. { (83<<16)|2, "no room for message" },
  98. { (87<<16)|2, "too many remote usernames" },
  99. { (88<<16)|2, "operation timed out" },
  100. { (89<<16)|2, "no resources" },
  101. { (90<<16)|2, "too many userids" },
  102. { (91<<16)|2, "bad userid" },
  103. { (250<<16)|2, "retry with mpx mode" },
  104. { (251<<16)|2, "retry with standard mode" },
  105. { (252<<16)|2, "resume mpx mode" },
  106. { (0xffff<<16)|2, "function not supported" },
  107. /* Error codes for the ERRHRD class */
  108. { (19<<16)|3, "read only media" },
  109. { (20<<16)|3, "unknown device" },
  110. { (21<<16)|3, "drive not ready" },
  111. { (22<<16)|3, "unknown command" },
  112. { (23<<16)|3, "data (CRC) error" },
  113. { (24<<16)|3, "bad request length" },
  114. { (25<<16)|3, "seek failed" },
  115. { (26<<16)|3, "bad media" },
  116. { (27<<16)|3, "bad sector" },
  117. { (28<<16)|3, "no paper" },
  118. { (29<<16)|3, "write fault" },
  119. { (30<<16)|3, "read fault" },
  120. { (31<<16)|3, "general hardware failure" },
  121. { (34<<16)|3, "wrong disk" },
  122. { (35<<16)|3, "FCB unavailable" },
  123. { (36<<16)|3, "share buffer exceeded" },
  124. { (39<<16)|3, "disk full" },
  125. };
  126. char *
  127. doserrstr(uint err)
  128. {
  129. int i, match;
  130. char *class;
  131. static char buf[0xff];
  132. switch(err & 0xff){
  133. case 1:
  134. class = "dos";
  135. break;
  136. case 2:
  137. class = "network";
  138. break;
  139. case 3:
  140. class = "hardware";
  141. break;
  142. case 4:
  143. class = "Xos";
  144. break;
  145. case 0xe1:
  146. class = "mx1";
  147. break;
  148. case 0xe2:
  149. class = "mx2";
  150. break;
  151. case 0xe3:
  152. class = "mx3";
  153. break;
  154. case 0xff:
  155. class = "packet";
  156. break;
  157. default:
  158. class = "unknown";
  159. break;
  160. }
  161. match = -1;
  162. for(i = 0; i < nelem(DOSerrs); i++)
  163. if(DOSerrs[i].err == err)
  164. match = i;
  165. if(match != -1)
  166. snprint(buf, sizeof(buf), "%s, %s", class, DOSerrs[match].msg);
  167. else
  168. snprint(buf, sizeof(buf), "%s, %ud/0x%ux - unknown error",
  169. class, err >> 16, err >> 16);
  170. return buf;
  171. }