doserrstr.c 5.9 KB

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