netmisc.c 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. /*
  2. * fs/cifs/netmisc.c
  3. *
  4. * Copyright (c) International Business Machines Corp., 2002,2008
  5. * Author(s): Steve French ([email protected])
  6. *
  7. * Error mapping routines from Samba libsmb/errormap.c
  8. * Copyright (C) Andrew Tridgell 2001
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  18. * the GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. #include <linux/net.h>
  25. #include <linux/string.h>
  26. #include <linux/in.h>
  27. #include <linux/ctype.h>
  28. #include <linux/fs.h>
  29. #include <asm/div64.h>
  30. #include <asm/byteorder.h>
  31. #include <linux/inet.h>
  32. #include "cifsfs.h"
  33. #include "cifspdu.h"
  34. #include "cifsglob.h"
  35. #include "cifsproto.h"
  36. #include "smberr.h"
  37. #include "cifs_debug.h"
  38. #include "nterr.h"
  39. struct smb_to_posix_error {
  40. __u16 smb_err;
  41. int posix_code;
  42. };
  43. static const struct smb_to_posix_error mapping_table_ERRDOS[] = {
  44. {ERRbadfunc, -EINVAL},
  45. {ERRbadfile, -ENOENT},
  46. {ERRbadpath, -ENOTDIR},
  47. {ERRnofids, -EMFILE},
  48. {ERRnoaccess, -EACCES},
  49. {ERRbadfid, -EBADF},
  50. {ERRbadmcb, -EIO},
  51. {ERRnomem, -EREMOTEIO},
  52. {ERRbadmem, -EFAULT},
  53. {ERRbadenv, -EFAULT},
  54. {ERRbadformat, -EINVAL},
  55. {ERRbadaccess, -EACCES},
  56. {ERRbaddata, -EIO},
  57. {ERRbaddrive, -ENXIO},
  58. {ERRremcd, -EACCES},
  59. {ERRdiffdevice, -EXDEV},
  60. {ERRnofiles, -ENOENT},
  61. {ERRwriteprot, -EROFS},
  62. {ERRbadshare, -EBUSY},
  63. {ERRlock, -EACCES},
  64. {ERRunsup, -EINVAL},
  65. {ERRnosuchshare, -ENXIO},
  66. {ERRfilexists, -EEXIST},
  67. {ERRinvparm, -EINVAL},
  68. {ERRdiskfull, -ENOSPC},
  69. {ERRinvname, -ENOENT},
  70. {ERRinvlevel, -EOPNOTSUPP},
  71. {ERRdirnotempty, -ENOTEMPTY},
  72. {ERRnotlocked, -ENOLCK},
  73. {ERRcancelviolation, -ENOLCK},
  74. {ERRalreadyexists, -EEXIST},
  75. {ERRmoredata, -EOVERFLOW},
  76. {ERReasnotsupported, -EOPNOTSUPP},
  77. {ErrQuota, -EDQUOT},
  78. {ErrNotALink, -ENOLINK},
  79. {ERRnetlogonNotStarted, -ENOPROTOOPT},
  80. {ERRsymlink, -EOPNOTSUPP},
  81. {ErrTooManyLinks, -EMLINK},
  82. {0, 0}
  83. };
  84. static const struct smb_to_posix_error mapping_table_ERRSRV[] = {
  85. {ERRerror, -EIO},
  86. {ERRbadpw, -EACCES}, /* was EPERM */
  87. {ERRbadtype, -EREMOTE},
  88. {ERRaccess, -EACCES},
  89. {ERRinvtid, -ENXIO},
  90. {ERRinvnetname, -ENXIO},
  91. {ERRinvdevice, -ENXIO},
  92. {ERRqfull, -ENOSPC},
  93. {ERRqtoobig, -ENOSPC},
  94. {ERRqeof, -EIO},
  95. {ERRinvpfid, -EBADF},
  96. {ERRsmbcmd, -EBADRQC},
  97. {ERRsrverror, -EIO},
  98. {ERRbadBID, -EIO},
  99. {ERRfilespecs, -EINVAL},
  100. {ERRbadLink, -EIO},
  101. {ERRbadpermits, -EINVAL},
  102. {ERRbadPID, -ESRCH},
  103. {ERRsetattrmode, -EINVAL},
  104. {ERRpaused, -EHOSTDOWN},
  105. {ERRmsgoff, -EHOSTDOWN},
  106. {ERRnoroom, -ENOSPC},
  107. {ERRrmuns, -EUSERS},
  108. {ERRtimeout, -ETIME},
  109. {ERRnoresource, -EREMOTEIO},
  110. {ERRtoomanyuids, -EUSERS},
  111. {ERRbaduid, -EACCES},
  112. {ERRusempx, -EIO},
  113. {ERRusestd, -EIO},
  114. {ERR_NOTIFY_ENUM_DIR, -ENOBUFS},
  115. {ERRnoSuchUser, -EACCES},
  116. /* {ERRaccountexpired, -EACCES},
  117. {ERRbadclient, -EACCES},
  118. {ERRbadLogonTime, -EACCES},
  119. {ERRpasswordExpired, -EACCES},*/
  120. {ERRaccountexpired, -EKEYEXPIRED},
  121. {ERRbadclient, -EACCES},
  122. {ERRbadLogonTime, -EACCES},
  123. {ERRpasswordExpired, -EKEYEXPIRED},
  124. {ERRnosupport, -EINVAL},
  125. {0, 0}
  126. };
  127. /*
  128. * Convert a string containing text IPv4 or IPv6 address to binary form.
  129. *
  130. * Returns 0 on failure.
  131. */
  132. static int
  133. cifs_inet_pton(const int address_family, const char *cp, int len, void *dst)
  134. {
  135. int ret = 0;
  136. /* calculate length by finding first slash or NULL */
  137. if (address_family == AF_INET)
  138. ret = in4_pton(cp, len, dst, '\\', NULL);
  139. else if (address_family == AF_INET6)
  140. ret = in6_pton(cp, len, dst , '\\', NULL);
  141. cifs_dbg(NOISY, "address conversion returned %d for %*.*s\n",
  142. ret, len, len, cp);
  143. if (ret > 0)
  144. ret = 1;
  145. return ret;
  146. }
  147. /*
  148. * Try to convert a string to an IPv4 address and then attempt to convert
  149. * it to an IPv6 address if that fails. Set the family field if either
  150. * succeeds. If it's an IPv6 address and it has a '%' sign in it, try to
  151. * treat the part following it as a numeric sin6_scope_id.
  152. *
  153. * Returns 0 on failure.
  154. */
  155. int
  156. cifs_convert_address(struct sockaddr *dst, const char *src, int len)
  157. {
  158. int rc, alen, slen;
  159. const char *pct;
  160. char scope_id[13];
  161. struct sockaddr_in *s4 = (struct sockaddr_in *) dst;
  162. struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) dst;
  163. /* IPv4 address */
  164. if (cifs_inet_pton(AF_INET, src, len, &s4->sin_addr.s_addr)) {
  165. s4->sin_family = AF_INET;
  166. return 1;
  167. }
  168. /* attempt to exclude the scope ID from the address part */
  169. pct = memchr(src, '%', len);
  170. alen = pct ? pct - src : len;
  171. rc = cifs_inet_pton(AF_INET6, src, alen, &s6->sin6_addr.s6_addr);
  172. if (!rc)
  173. return rc;
  174. s6->sin6_family = AF_INET6;
  175. if (pct) {
  176. /* grab the scope ID */
  177. slen = len - (alen + 1);
  178. if (slen <= 0 || slen > 12)
  179. return 0;
  180. memcpy(scope_id, pct + 1, slen);
  181. scope_id[slen] = '\0';
  182. rc = kstrtouint(scope_id, 0, &s6->sin6_scope_id);
  183. rc = (rc == 0) ? 1 : 0;
  184. }
  185. return rc;
  186. }
  187. void
  188. cifs_set_port(struct sockaddr *addr, const unsigned short int port)
  189. {
  190. switch (addr->sa_family) {
  191. case AF_INET:
  192. ((struct sockaddr_in *)addr)->sin_port = htons(port);
  193. break;
  194. case AF_INET6:
  195. ((struct sockaddr_in6 *)addr)->sin6_port = htons(port);
  196. break;
  197. }
  198. }
  199. /*****************************************************************************
  200. convert a NT status code to a dos class/code
  201. *****************************************************************************/
  202. /* NT status -> dos error map */
  203. static const struct {
  204. __u8 dos_class;
  205. __u16 dos_code;
  206. __u32 ntstatus;
  207. } ntstatus_to_dos_map[] = {
  208. {
  209. ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, {
  210. ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, {
  211. ERRDOS, ERRinvlevel, NT_STATUS_INVALID_INFO_CLASS}, {
  212. ERRDOS, 24, NT_STATUS_INFO_LENGTH_MISMATCH}, {
  213. ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION}, {
  214. ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR}, {
  215. ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA}, {
  216. ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, {
  217. ERRHRD, ERRgeneral, NT_STATUS_BAD_INITIAL_STACK}, {
  218. ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC}, {
  219. ERRDOS, 87, NT_STATUS_INVALID_CID}, {
  220. ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED}, {
  221. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER}, {
  222. ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE}, {
  223. ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, {
  224. ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST}, {
  225. ERRDOS, 38, NT_STATUS_END_OF_FILE}, {
  226. ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, {
  227. ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE}, {
  228. ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA}, {
  229. ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR},
  230. /* { This NT error code was 'sqashed'
  231. from NT_STATUS_MORE_PROCESSING_REQUIRED to NT_STATUS_OK
  232. during the session setup } */
  233. {
  234. ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY}, {
  235. ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES}, {
  236. ERRDOS, 487, NT_STATUS_NOT_MAPPED_VIEW}, {
  237. ERRDOS, 87, NT_STATUS_UNABLE_TO_FREE_VM}, {
  238. ERRDOS, 87, NT_STATUS_UNABLE_TO_DELETE_SECTION}, {
  239. ERRDOS, 2142, NT_STATUS_INVALID_SYSTEM_SERVICE}, {
  240. ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_INSTRUCTION}, {
  241. ERRDOS, ERRnoaccess, NT_STATUS_INVALID_LOCK_SEQUENCE}, {
  242. ERRDOS, ERRnoaccess, NT_STATUS_INVALID_VIEW_SIZE}, {
  243. ERRDOS, 193, NT_STATUS_INVALID_FILE_FOR_SECTION}, {
  244. ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED},
  245. /* { This NT error code was 'sqashed'
  246. from NT_STATUS_ACCESS_DENIED to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE
  247. during the session setup } */
  248. {
  249. ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED}, {
  250. ERRDOS, 111, NT_STATUS_BUFFER_TOO_SMALL}, {
  251. ERRDOS, ERRbadfid, NT_STATUS_OBJECT_TYPE_MISMATCH}, {
  252. ERRHRD, ERRgeneral, NT_STATUS_NONCONTINUABLE_EXCEPTION}, {
  253. ERRHRD, ERRgeneral, NT_STATUS_INVALID_DISPOSITION}, {
  254. ERRHRD, ERRgeneral, NT_STATUS_UNWIND}, {
  255. ERRHRD, ERRgeneral, NT_STATUS_BAD_STACK}, {
  256. ERRHRD, ERRgeneral, NT_STATUS_INVALID_UNWIND_TARGET}, {
  257. ERRDOS, 158, NT_STATUS_NOT_LOCKED}, {
  258. ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR}, {
  259. ERRDOS, 487, NT_STATUS_UNABLE_TO_DECOMMIT_VM}, {
  260. ERRDOS, 487, NT_STATUS_NOT_COMMITTED}, {
  261. ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES}, {
  262. ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG}, {
  263. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_MIX}, {
  264. ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER}, {
  265. ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, {
  266. /* mapping changed since shell does lookup on * expects FileNotFound */
  267. ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_INVALID}, {
  268. ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, {
  269. ERRDOS, ERRalreadyexists, NT_STATUS_OBJECT_NAME_COLLISION}, {
  270. ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, {
  271. ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED}, {
  272. ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED}, {
  273. ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID}, {
  274. ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, {
  275. ERRDOS, 161, NT_STATUS_OBJECT_PATH_SYNTAX_BAD}, {
  276. ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN}, {
  277. ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR}, {
  278. ERRDOS, 23, NT_STATUS_DATA_ERROR}, {
  279. ERRDOS, 23, NT_STATUS_CRC_ERROR}, {
  280. ERRDOS, ERRnomem, NT_STATUS_SECTION_TOO_BIG}, {
  281. ERRDOS, ERRnoaccess, NT_STATUS_PORT_CONNECTION_REFUSED}, {
  282. ERRDOS, ERRbadfid, NT_STATUS_INVALID_PORT_HANDLE}, {
  283. ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, {
  284. ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED}, {
  285. ERRDOS, 87, NT_STATUS_INVALID_PAGE_PROTECTION}, {
  286. ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED}, {
  287. ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, {
  288. ERRDOS, 87, NT_STATUS_PORT_ALREADY_SET}, {
  289. ERRDOS, 87, NT_STATUS_SECTION_NOT_IMAGE}, {
  290. ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, {
  291. ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING}, {
  292. ERRDOS, 87, NT_STATUS_BAD_WORKING_SET_LIMIT}, {
  293. ERRDOS, 87, NT_STATUS_INCOMPATIBLE_FILE_MAP}, {
  294. ERRDOS, 87, NT_STATUS_SECTION_PROTECTION}, {
  295. ERRDOS, ERReasnotsupported, NT_STATUS_EAS_NOT_SUPPORTED}, {
  296. ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, {
  297. ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY}, {
  298. ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE}, {
  299. ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR}, {
  300. ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, {
  301. ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED}, {
  302. ERRDOS, ERRbadfile, NT_STATUS_DELETE_PENDING}, {
  303. ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, {
  304. ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION}, {
  305. ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH}, {
  306. ERRHRD, ERRgeneral, NT_STATUS_INVALID_OWNER}, {
  307. ERRHRD, ERRgeneral, NT_STATUS_INVALID_PRIMARY_GROUP}, {
  308. ERRHRD, ERRgeneral, NT_STATUS_NO_IMPERSONATION_TOKEN}, {
  309. ERRHRD, ERRgeneral, NT_STATUS_CANT_DISABLE_MANDATORY}, {
  310. ERRDOS, 2215, NT_STATUS_NO_LOGON_SERVERS}, {
  311. ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_LOGON_SESSION}, {
  312. ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PRIVILEGE}, {
  313. ERRDOS, ERRnoaccess, NT_STATUS_PRIVILEGE_NOT_HELD}, {
  314. ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACCOUNT_NAME}, {
  315. ERRHRD, ERRgeneral, NT_STATUS_USER_EXISTS},
  316. /* { This NT error code was 'sqashed'
  317. from NT_STATUS_NO_SUCH_USER to NT_STATUS_LOGON_FAILURE
  318. during the session setup } */
  319. {
  320. ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, { /* could map to 2238 */
  321. ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS}, {
  322. ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP}, {
  323. ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP}, {
  324. ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_GROUP}, {
  325. ERRHRD, ERRgeneral, NT_STATUS_LAST_ADMIN},
  326. /* { This NT error code was 'sqashed'
  327. from NT_STATUS_WRONG_PASSWORD to NT_STATUS_LOGON_FAILURE
  328. during the session setup } */
  329. {
  330. ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD}, {
  331. ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD}, {
  332. ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, {
  333. ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE}, {
  334. ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION}, {
  335. ERRSRV, ERRbadLogonTime, NT_STATUS_INVALID_LOGON_HOURS}, {
  336. ERRSRV, ERRbadclient, NT_STATUS_INVALID_WORKSTATION}, {
  337. ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_EXPIRED}, {
  338. ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_DISABLED}, {
  339. ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED}, {
  340. ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, {
  341. ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED}, {
  342. ERRHRD, ERRgeneral, NT_STATUS_INVALID_SUB_AUTHORITY}, {
  343. ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACL}, {
  344. ERRHRD, ERRgeneral, NT_STATUS_INVALID_SID}, {
  345. ERRHRD, ERRgeneral, NT_STATUS_INVALID_SECURITY_DESCR}, {
  346. ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, {
  347. ERRDOS, 193, NT_STATUS_INVALID_IMAGE_FORMAT}, {
  348. ERRHRD, ERRgeneral, NT_STATUS_NO_TOKEN}, {
  349. ERRHRD, ERRgeneral, NT_STATUS_BAD_INHERITANCE_ACL}, {
  350. ERRDOS, 158, NT_STATUS_RANGE_NOT_LOCKED}, {
  351. ERRDOS, 112, NT_STATUS_DISK_FULL}, {
  352. ERRHRD, ERRgeneral, NT_STATUS_SERVER_DISABLED}, {
  353. ERRHRD, ERRgeneral, NT_STATUS_SERVER_NOT_DISABLED}, {
  354. ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, {
  355. ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED}, {
  356. ERRHRD, ERRgeneral, NT_STATUS_INVALID_ID_AUTHORITY}, {
  357. ERRDOS, 259, NT_STATUS_AGENTS_EXHAUSTED}, {
  358. ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL}, {
  359. ERRDOS, 14, NT_STATUS_SECTION_NOT_EXTENDED}, {
  360. ERRDOS, 487, NT_STATUS_NOT_MAPPED_DATA}, {
  361. ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_DATA_NOT_FOUND}, {
  362. ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_TYPE_NOT_FOUND}, {
  363. ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_NAME_NOT_FOUND}, {
  364. ERRHRD, ERRgeneral, NT_STATUS_ARRAY_BOUNDS_EXCEEDED}, {
  365. ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DENORMAL_OPERAND}, {
  366. ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DIVIDE_BY_ZERO}, {
  367. ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INEXACT_RESULT}, {
  368. ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INVALID_OPERATION}, {
  369. ERRHRD, ERRgeneral, NT_STATUS_FLOAT_OVERFLOW}, {
  370. ERRHRD, ERRgeneral, NT_STATUS_FLOAT_STACK_CHECK}, {
  371. ERRHRD, ERRgeneral, NT_STATUS_FLOAT_UNDERFLOW}, {
  372. ERRHRD, ERRgeneral, NT_STATUS_INTEGER_DIVIDE_BY_ZERO}, {
  373. ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW}, {
  374. ERRHRD, ERRgeneral, NT_STATUS_PRIVILEGED_INSTRUCTION}, {
  375. ERRDOS, ERRnomem, NT_STATUS_TOO_MANY_PAGING_FILES}, {
  376. ERRHRD, ERRgeneral, NT_STATUS_FILE_INVALID}, {
  377. ERRHRD, ERRgeneral, NT_STATUS_ALLOTTED_SPACE_EXCEEDED},
  378. /* { This NT error code was 'sqashed'
  379. from NT_STATUS_INSUFFICIENT_RESOURCES to
  380. NT_STATUS_INSUFF_SERVER_RESOURCES during the session setup } */
  381. {
  382. ERRDOS, ERRnoresource, NT_STATUS_INSUFFICIENT_RESOURCES}, {
  383. ERRDOS, ERRbadpath, NT_STATUS_DFS_EXIT_PATH_FOUND}, {
  384. ERRDOS, 23, NT_STATUS_DEVICE_DATA_ERROR}, {
  385. ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_CONNECTED}, {
  386. ERRDOS, 21, NT_STATUS_DEVICE_POWER_FAILURE}, {
  387. ERRDOS, 487, NT_STATUS_FREE_VM_NOT_AT_BASE}, {
  388. ERRDOS, 487, NT_STATUS_MEMORY_NOT_ALLOCATED}, {
  389. ERRHRD, ERRgeneral, NT_STATUS_WORKING_SET_QUOTA}, {
  390. ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED}, {
  391. ERRDOS, 21, NT_STATUS_DEVICE_NOT_READY}, {
  392. ERRHRD, ERRgeneral, NT_STATUS_INVALID_GROUP_ATTRIBUTES}, {
  393. ERRHRD, ERRgeneral, NT_STATUS_BAD_IMPERSONATION_LEVEL}, {
  394. ERRHRD, ERRgeneral, NT_STATUS_CANT_OPEN_ANONYMOUS}, {
  395. ERRHRD, ERRgeneral, NT_STATUS_BAD_VALIDATION_CLASS}, {
  396. ERRHRD, ERRgeneral, NT_STATUS_BAD_TOKEN_TYPE}, {
  397. ERRDOS, 87, NT_STATUS_BAD_MASTER_BOOT_RECORD}, {
  398. ERRHRD, ERRgeneral, NT_STATUS_INSTRUCTION_MISALIGNMENT}, {
  399. ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE}, {
  400. ERRDOS, ERRpipebusy, NT_STATUS_PIPE_NOT_AVAILABLE}, {
  401. ERRDOS, ERRbadpipe, NT_STATUS_INVALID_PIPE_STATE}, {
  402. ERRDOS, ERRpipebusy, NT_STATUS_PIPE_BUSY}, {
  403. ERRDOS, ERRbadfunc, NT_STATUS_ILLEGAL_FUNCTION}, {
  404. ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED}, {
  405. ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING}, {
  406. ERRHRD, ERRgeneral, NT_STATUS_PIPE_CONNECTED}, {
  407. ERRHRD, ERRgeneral, NT_STATUS_PIPE_LISTENING}, {
  408. ERRDOS, ERRbadpipe, NT_STATUS_INVALID_READ_MODE}, {
  409. ERRDOS, 121, NT_STATUS_IO_TIMEOUT}, {
  410. ERRDOS, 38, NT_STATUS_FILE_FORCED_CLOSED}, {
  411. ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STARTED}, {
  412. ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STOPPED}, {
  413. ERRHRD, ERRgeneral, NT_STATUS_COULD_NOT_INTERPRET}, {
  414. ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY}, {
  415. ERRDOS, ERRunsup, NT_STATUS_NOT_SUPPORTED}, {
  416. ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING}, {
  417. ERRDOS, 52, NT_STATUS_DUPLICATE_NAME}, {
  418. ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH}, {
  419. ERRDOS, 54, NT_STATUS_NETWORK_BUSY}, {
  420. ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, {
  421. ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS}, {
  422. ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, {
  423. ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, {
  424. ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, {
  425. ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, {
  426. ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL}, {
  427. ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE}, {
  428. ERRDOS, 63, NT_STATUS_PRINT_CANCELLED}, {
  429. ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED}, {
  430. ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, {
  431. ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE}, {
  432. ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME}, {
  433. ERRDOS, 68, NT_STATUS_TOO_MANY_NAMES}, {
  434. ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS}, {
  435. ERRDOS, 70, NT_STATUS_SHARING_PAUSED}, {
  436. ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, {
  437. ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED}, {
  438. ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT}, {
  439. ERRHRD, ERRgeneral, NT_STATUS_PROFILING_AT_LIMIT}, {
  440. ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE}, {
  441. ERRDOS, ERRnoaccess, NT_STATUS_FILE_RENAMED}, {
  442. ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, {
  443. ERRHRD, ERRgeneral, NT_STATUS_NO_SECURITY_ON_OBJECT}, {
  444. ERRHRD, ERRgeneral, NT_STATUS_CANT_WAIT}, {
  445. ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_EMPTY}, {
  446. ERRHRD, ERRgeneral, NT_STATUS_CANT_ACCESS_DOMAIN_INFO}, {
  447. ERRHRD, ERRgeneral, NT_STATUS_CANT_TERMINATE_SELF}, {
  448. ERRHRD, ERRgeneral, NT_STATUS_INVALID_SERVER_STATE}, {
  449. ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_STATE}, {
  450. ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_ROLE}, {
  451. ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_DOMAIN}, {
  452. ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_EXISTS}, {
  453. ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_LIMIT_EXCEEDED}, {
  454. ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, {
  455. ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, {
  456. ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_CORRUPTION}, {
  457. ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_ERROR}, {
  458. ERRHRD, ERRgeneral, NT_STATUS_GENERIC_NOT_MAPPED}, {
  459. ERRHRD, ERRgeneral, NT_STATUS_BAD_DESCRIPTOR_FORMAT}, {
  460. ERRHRD, ERRgeneral, NT_STATUS_INVALID_USER_BUFFER}, {
  461. ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_IO_ERROR}, {
  462. ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_CREATE_ERR}, {
  463. ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_MAP_ERROR}, {
  464. ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_EXTEND_ERR}, {
  465. ERRHRD, ERRgeneral, NT_STATUS_NOT_LOGON_PROCESS}, {
  466. ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_EXISTS}, {
  467. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_1}, {
  468. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_2}, {
  469. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_3}, {
  470. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_4}, {
  471. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_5}, {
  472. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_6}, {
  473. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_7}, {
  474. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_8}, {
  475. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_9}, {
  476. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_10}, {
  477. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_11}, {
  478. ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_12}, {
  479. ERRDOS, ERRbadpath, NT_STATUS_REDIRECTOR_NOT_STARTED}, {
  480. ERRHRD, ERRgeneral, NT_STATUS_REDIRECTOR_STARTED}, {
  481. ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW}, {
  482. ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PACKAGE}, {
  483. ERRHRD, ERRgeneral, NT_STATUS_BAD_FUNCTION_TABLE}, {
  484. ERRDOS, 203, 0xc0000100}, {
  485. ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, {
  486. ERRHRD, ERRgeneral, NT_STATUS_FILE_CORRUPT_ERROR}, {
  487. ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY}, {
  488. ERRHRD, ERRgeneral, NT_STATUS_BAD_LOGON_SESSION_STATE}, {
  489. ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_COLLISION}, {
  490. ERRDOS, 206, NT_STATUS_NAME_TOO_LONG}, {
  491. ERRDOS, 2401, NT_STATUS_FILES_OPEN}, {
  492. ERRDOS, 2404, NT_STATUS_CONNECTION_IN_USE}, {
  493. ERRHRD, ERRgeneral, NT_STATUS_MESSAGE_NOT_FOUND}, {
  494. ERRDOS, ERRnoaccess, NT_STATUS_PROCESS_IS_TERMINATING}, {
  495. ERRHRD, ERRgeneral, NT_STATUS_INVALID_LOGON_TYPE}, {
  496. ERRHRD, ERRgeneral, NT_STATUS_NO_GUID_TRANSLATION}, {
  497. ERRHRD, ERRgeneral, NT_STATUS_CANNOT_IMPERSONATE}, {
  498. ERRHRD, ERRgeneral, NT_STATUS_IMAGE_ALREADY_LOADED}, {
  499. ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_PRESENT}, {
  500. ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_NOT_EXIST}, {
  501. ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_ALREADY_OWNED}, {
  502. ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_LID_OWNER}, {
  503. ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_COMMAND}, {
  504. ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_LID}, {
  505. ERRHRD, ERRgeneral, NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE}, {
  506. ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_SELECTOR}, {
  507. ERRHRD, ERRgeneral, NT_STATUS_NO_LDT}, {
  508. ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_SIZE}, {
  509. ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_OFFSET}, {
  510. ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_DESCRIPTOR}, {
  511. ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NE_FORMAT}, {
  512. ERRHRD, ERRgeneral, NT_STATUS_RXACT_INVALID_STATE}, {
  513. ERRHRD, ERRgeneral, NT_STATUS_RXACT_COMMIT_FAILURE}, {
  514. ERRHRD, ERRgeneral, NT_STATUS_MAPPED_FILE_SIZE_ZERO}, {
  515. ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES}, {
  516. ERRHRD, ERRgeneral, NT_STATUS_CANCELLED}, {
  517. ERRDOS, ERRnoaccess, NT_STATUS_CANNOT_DELETE}, {
  518. ERRHRD, ERRgeneral, NT_STATUS_INVALID_COMPUTER_NAME}, {
  519. ERRDOS, ERRnoaccess, NT_STATUS_FILE_DELETED}, {
  520. ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_ACCOUNT}, {
  521. ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_GROUP}, {
  522. ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_USER}, {
  523. ERRHRD, ERRgeneral, NT_STATUS_MEMBERS_PRIMARY_GROUP}, {
  524. ERRDOS, ERRbadfid, NT_STATUS_FILE_CLOSED}, {
  525. ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_THREADS}, {
  526. ERRHRD, ERRgeneral, NT_STATUS_THREAD_NOT_IN_PROCESS}, {
  527. ERRHRD, ERRgeneral, NT_STATUS_TOKEN_ALREADY_IN_USE}, {
  528. ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA_EXCEEDED}, {
  529. ERRHRD, ERRgeneral, NT_STATUS_COMMITMENT_LIMIT}, {
  530. ERRDOS, 193, NT_STATUS_INVALID_IMAGE_LE_FORMAT}, {
  531. ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NOT_MZ}, {
  532. ERRDOS, 193, NT_STATUS_INVALID_IMAGE_PROTECT}, {
  533. ERRDOS, 193, NT_STATUS_INVALID_IMAGE_WIN_16}, {
  534. ERRHRD, ERRgeneral, NT_STATUS_LOGON_SERVER_CONFLICT}, {
  535. ERRHRD, ERRgeneral, NT_STATUS_TIME_DIFFERENCE_AT_DC}, {
  536. ERRHRD, ERRgeneral, NT_STATUS_SYNCHRONIZATION_REQUIRED}, {
  537. ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND}, {
  538. ERRHRD, ERRgeneral, NT_STATUS_OPEN_FAILED}, {
  539. ERRHRD, ERRgeneral, NT_STATUS_IO_PRIVILEGE_FAILED}, {
  540. ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND}, {
  541. ERRDOS, 127, NT_STATUS_ENTRYPOINT_NOT_FOUND}, {
  542. ERRHRD, ERRgeneral, NT_STATUS_CONTROL_C_EXIT}, {
  543. ERRDOS, 64, NT_STATUS_LOCAL_DISCONNECT}, {
  544. ERRDOS, 64, NT_STATUS_REMOTE_DISCONNECT}, {
  545. ERRDOS, 51, NT_STATUS_REMOTE_RESOURCES}, {
  546. ERRDOS, 59, NT_STATUS_LINK_FAILED}, {
  547. ERRDOS, 59, NT_STATUS_LINK_TIMEOUT}, {
  548. ERRDOS, 59, NT_STATUS_INVALID_CONNECTION}, {
  549. ERRDOS, 59, NT_STATUS_INVALID_ADDRESS}, {
  550. ERRHRD, ERRgeneral, NT_STATUS_DLL_INIT_FAILED}, {
  551. ERRHRD, ERRgeneral, NT_STATUS_MISSING_SYSTEMFILE}, {
  552. ERRHRD, ERRgeneral, NT_STATUS_UNHANDLED_EXCEPTION}, {
  553. ERRHRD, ERRgeneral, NT_STATUS_APP_INIT_FAILURE}, {
  554. ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_CREATE_FAILED}, {
  555. ERRHRD, ERRgeneral, NT_STATUS_NO_PAGEFILE}, {
  556. ERRDOS, 124, NT_STATUS_INVALID_LEVEL}, {
  557. ERRDOS, 86, NT_STATUS_WRONG_PASSWORD_CORE}, {
  558. ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_FLOAT_CONTEXT}, {
  559. ERRDOS, 109, NT_STATUS_PIPE_BROKEN}, {
  560. ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_CORRUPT}, {
  561. ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_IO_FAILED}, {
  562. ERRHRD, ERRgeneral, NT_STATUS_NO_EVENT_PAIR}, {
  563. ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_VOLUME}, {
  564. ERRHRD, ERRgeneral, NT_STATUS_SERIAL_NO_DEVICE_INITED}, {
  565. ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_ALIAS}, {
  566. ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_ALIAS}, {
  567. ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_ALIAS}, {
  568. ERRHRD, ERRgeneral, NT_STATUS_ALIAS_EXISTS}, {
  569. ERRHRD, ERRgeneral, NT_STATUS_LOGON_NOT_GRANTED}, {
  570. ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SECRETS}, {
  571. ERRHRD, ERRgeneral, NT_STATUS_SECRET_TOO_LONG}, {
  572. ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_ERROR}, {
  573. ERRHRD, ERRgeneral, NT_STATUS_FULLSCREEN_MODE}, {
  574. ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_CONTEXT_IDS}, {
  575. ERRDOS, ERRnoaccess, NT_STATUS_LOGON_TYPE_NOT_GRANTED}, {
  576. ERRHRD, ERRgeneral, NT_STATUS_NOT_REGISTRY_FILE}, {
  577. ERRHRD, ERRgeneral, NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED}, {
  578. ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR}, {
  579. ERRHRD, ERRgeneral, NT_STATUS_FT_MISSING_MEMBER}, {
  580. ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_SERVICE_ENTRY}, {
  581. ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_CHARACTER}, {
  582. ERRHRD, ERRgeneral, NT_STATUS_UNMAPPABLE_CHARACTER}, {
  583. ERRHRD, ERRgeneral, NT_STATUS_UNDEFINED_CHARACTER}, {
  584. ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_VOLUME}, {
  585. ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND}, {
  586. ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_WRONG_CYLINDER}, {
  587. ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_UNKNOWN_ERROR}, {
  588. ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_BAD_REGISTERS}, {
  589. ERRHRD, ERRgeneral, NT_STATUS_DISK_RECALIBRATE_FAILED}, {
  590. ERRHRD, ERRgeneral, NT_STATUS_DISK_OPERATION_FAILED}, {
  591. ERRHRD, ERRgeneral, NT_STATUS_DISK_RESET_FAILED}, {
  592. ERRHRD, ERRgeneral, NT_STATUS_SHARED_IRQ_BUSY}, {
  593. ERRHRD, ERRgeneral, NT_STATUS_FT_ORPHANING}, {
  594. ERRHRD, ERRgeneral, 0xc000016e}, {
  595. ERRHRD, ERRgeneral, 0xc000016f}, {
  596. ERRHRD, ERRgeneral, 0xc0000170}, {
  597. ERRHRD, ERRgeneral, 0xc0000171}, {
  598. ERRHRD, ERRgeneral, NT_STATUS_PARTITION_FAILURE}, {
  599. ERRHRD, ERRgeneral, NT_STATUS_INVALID_BLOCK_LENGTH}, {
  600. ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_PARTITIONED}, {
  601. ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_LOCK_MEDIA}, {
  602. ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_UNLOAD_MEDIA}, {
  603. ERRHRD, ERRgeneral, NT_STATUS_EOM_OVERFLOW}, {
  604. ERRHRD, ERRgeneral, NT_STATUS_NO_MEDIA}, {
  605. ERRHRD, ERRgeneral, 0xc0000179}, {
  606. ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_MEMBER}, {
  607. ERRHRD, ERRgeneral, NT_STATUS_INVALID_MEMBER}, {
  608. ERRHRD, ERRgeneral, NT_STATUS_KEY_DELETED}, {
  609. ERRHRD, ERRgeneral, NT_STATUS_NO_LOG_SPACE}, {
  610. ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SIDS}, {
  611. ERRHRD, ERRgeneral, NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED}, {
  612. ERRHRD, ERRgeneral, NT_STATUS_KEY_HAS_CHILDREN}, {
  613. ERRHRD, ERRgeneral, NT_STATUS_CHILD_MUST_BE_VOLATILE}, {
  614. ERRDOS, 87, NT_STATUS_DEVICE_CONFIGURATION_ERROR}, {
  615. ERRHRD, ERRgeneral, NT_STATUS_DRIVER_INTERNAL_ERROR}, {
  616. ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE}, {
  617. ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR}, {
  618. ERRHRD, ERRgeneral, NT_STATUS_DEVICE_PROTOCOL_ERROR}, {
  619. ERRHRD, ERRgeneral, NT_STATUS_BACKUP_CONTROLLER}, {
  620. ERRHRD, ERRgeneral, NT_STATUS_LOG_FILE_FULL}, {
  621. ERRDOS, 19, NT_STATUS_TOO_LATE}, {
  622. ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_LSA_SECRET},
  623. /* { This NT error code was 'sqashed'
  624. from NT_STATUS_NO_TRUST_SAM_ACCOUNT to
  625. NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE during the session setup } */
  626. {
  627. ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_SAM_ACCOUNT}, {
  628. ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_DOMAIN_FAILURE}, {
  629. ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE}, {
  630. ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CORRUPT}, {
  631. ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_CANT_START}, {
  632. ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE}, {
  633. ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED}, {
  634. ERRDOS, ERRnetlogonNotStarted, NT_STATUS_NETLOGON_NOT_STARTED}, {
  635. ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_EXPIRED}, {
  636. ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK}, {
  637. ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, {
  638. ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT}, {
  639. ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CHANGED}, {
  640. ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT}, {
  641. ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT}, {
  642. ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT},
  643. /* { This NT error code was 'sqashed'
  644. from NT_STATUS_DOMAIN_TRUST_INCONSISTENT to NT_STATUS_LOGON_FAILURE
  645. during the session setup } */
  646. {
  647. ERRDOS, ERRnoaccess, NT_STATUS_DOMAIN_TRUST_INCONSISTENT}, {
  648. ERRHRD, ERRgeneral, NT_STATUS_FS_DRIVER_REQUIRED}, {
  649. ERRHRD, ERRgeneral, NT_STATUS_NO_USER_SESSION_KEY}, {
  650. ERRDOS, 59, NT_STATUS_USER_SESSION_DELETED}, {
  651. ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_LANG_NOT_FOUND}, {
  652. ERRDOS, ERRnoresource, NT_STATUS_INSUFF_SERVER_RESOURCES}, {
  653. ERRHRD, ERRgeneral, NT_STATUS_INVALID_BUFFER_SIZE}, {
  654. ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_COMPONENT}, {
  655. ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_WILDCARD}, {
  656. ERRDOS, 68, NT_STATUS_TOO_MANY_ADDRESSES}, {
  657. ERRDOS, 52, NT_STATUS_ADDRESS_ALREADY_EXISTS}, {
  658. ERRDOS, 64, NT_STATUS_ADDRESS_CLOSED}, {
  659. ERRDOS, 64, NT_STATUS_CONNECTION_DISCONNECTED}, {
  660. ERRDOS, 64, NT_STATUS_CONNECTION_RESET}, {
  661. ERRDOS, 68, NT_STATUS_TOO_MANY_NODES}, {
  662. ERRDOS, 59, NT_STATUS_TRANSACTION_ABORTED}, {
  663. ERRDOS, 59, NT_STATUS_TRANSACTION_TIMED_OUT}, {
  664. ERRDOS, 59, NT_STATUS_TRANSACTION_NO_RELEASE}, {
  665. ERRDOS, 59, NT_STATUS_TRANSACTION_NO_MATCH}, {
  666. ERRDOS, 59, NT_STATUS_TRANSACTION_RESPONDED}, {
  667. ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_ID}, {
  668. ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_TYPE}, {
  669. ERRDOS, ERRunsup, NT_STATUS_NOT_SERVER_SESSION}, {
  670. ERRDOS, ERRunsup, NT_STATUS_NOT_CLIENT_SESSION}, {
  671. ERRHRD, ERRgeneral, NT_STATUS_CANNOT_LOAD_REGISTRY_FILE}, {
  672. ERRHRD, ERRgeneral, NT_STATUS_DEBUG_ATTACH_FAILED}, {
  673. ERRHRD, ERRgeneral, NT_STATUS_SYSTEM_PROCESS_TERMINATED}, {
  674. ERRHRD, ERRgeneral, NT_STATUS_DATA_NOT_ACCEPTED}, {
  675. ERRHRD, ERRgeneral, NT_STATUS_NO_BROWSER_SERVERS_FOUND}, {
  676. ERRHRD, ERRgeneral, NT_STATUS_VDM_HARD_ERROR}, {
  677. ERRHRD, ERRgeneral, NT_STATUS_DRIVER_CANCEL_TIMEOUT}, {
  678. ERRHRD, ERRgeneral, NT_STATUS_REPLY_MESSAGE_MISMATCH}, {
  679. ERRHRD, ERRgeneral, NT_STATUS_MAPPED_ALIGNMENT}, {
  680. ERRDOS, 193, NT_STATUS_IMAGE_CHECKSUM_MISMATCH}, {
  681. ERRHRD, ERRgeneral, NT_STATUS_LOST_WRITEBEHIND_DATA}, {
  682. ERRHRD, ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID}, {
  683. ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_MUST_CHANGE}, {
  684. ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND}, {
  685. ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM}, {
  686. ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE}, {
  687. ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW_READ}, {
  688. ERRHRD, ERRgeneral, NT_STATUS_FAIL_CHECK}, {
  689. ERRHRD, ERRgeneral, NT_STATUS_DUPLICATE_OBJECTID}, {
  690. ERRHRD, ERRgeneral, NT_STATUS_OBJECTID_EXISTS}, {
  691. ERRHRD, ERRgeneral, NT_STATUS_CONVERT_TO_LARGE}, {
  692. ERRHRD, ERRgeneral, NT_STATUS_RETRY}, {
  693. ERRHRD, ERRgeneral, NT_STATUS_FOUND_OUT_OF_SCOPE}, {
  694. ERRHRD, ERRgeneral, NT_STATUS_ALLOCATE_BUCKET}, {
  695. ERRHRD, ERRgeneral, NT_STATUS_PROPSET_NOT_FOUND}, {
  696. ERRHRD, ERRgeneral, NT_STATUS_MARSHALL_OVERFLOW}, {
  697. ERRHRD, ERRgeneral, NT_STATUS_INVALID_VARIANT}, {
  698. ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND}, {
  699. ERRDOS, ERRnoaccess, NT_STATUS_ACCOUNT_LOCKED_OUT}, {
  700. ERRDOS, ERRbadfid, NT_STATUS_HANDLE_NOT_CLOSABLE}, {
  701. ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED}, {
  702. ERRHRD, ERRgeneral, NT_STATUS_GRACEFUL_DISCONNECT}, {
  703. ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED}, {
  704. ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_NOT_ASSOCIATED}, {
  705. ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_INVALID}, {
  706. ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ACTIVE}, {
  707. ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE}, {
  708. ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE}, {
  709. ERRHRD, ERRgeneral, NT_STATUS_PROTOCOL_UNREACHABLE}, {
  710. ERRHRD, ERRgeneral, NT_STATUS_PORT_UNREACHABLE}, {
  711. ERRHRD, ERRgeneral, NT_STATUS_REQUEST_ABORTED}, {
  712. ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED}, {
  713. ERRHRD, ERRgeneral, NT_STATUS_BAD_COMPRESSION_BUFFER}, {
  714. ERRHRD, ERRgeneral, NT_STATUS_USER_MAPPED_FILE}, {
  715. ERRHRD, ERRgeneral, NT_STATUS_AUDIT_FAILED}, {
  716. ERRHRD, ERRgeneral, NT_STATUS_TIMER_RESOLUTION_NOT_SET}, {
  717. ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_COUNT_LIMIT}, {
  718. ERRHRD, ERRgeneral, NT_STATUS_LOGIN_TIME_RESTRICTION}, {
  719. ERRHRD, ERRgeneral, NT_STATUS_LOGIN_WKSTA_RESTRICTION}, {
  720. ERRDOS, 193, NT_STATUS_IMAGE_MP_UP_MISMATCH}, {
  721. ERRHRD, ERRgeneral, 0xc000024a}, {
  722. ERRHRD, ERRgeneral, 0xc000024b}, {
  723. ERRHRD, ERRgeneral, 0xc000024c}, {
  724. ERRHRD, ERRgeneral, 0xc000024d}, {
  725. ERRHRD, ERRgeneral, 0xc000024e}, {
  726. ERRHRD, ERRgeneral, 0xc000024f}, {
  727. ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO}, {
  728. ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT}, {
  729. ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT}, {
  730. ERRHRD, ERRgeneral, NT_STATUS_LPC_REPLY_LOST}, {
  731. ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT1}, {
  732. ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT2}, {
  733. ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_QUOTA_LIMIT}, {
  734. ERRSRV, 3, NT_STATUS_PATH_NOT_COVERED}, {
  735. ERRHRD, ERRgeneral, NT_STATUS_NO_CALLBACK_ACTIVE}, {
  736. ERRHRD, ERRgeneral, NT_STATUS_LICENSE_QUOTA_EXCEEDED}, {
  737. ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT}, {
  738. ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT}, {
  739. ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT}, {
  740. ERRHRD, ERRgeneral, 0xc000025d}, {
  741. ERRHRD, ERRgeneral, NT_STATUS_PLUGPLAY_NO_DEVICE}, {
  742. ERRHRD, ERRgeneral, NT_STATUS_UNSUPPORTED_COMPRESSION}, {
  743. ERRHRD, ERRgeneral, NT_STATUS_INVALID_HW_PROFILE}, {
  744. ERRHRD, ERRgeneral, NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH}, {
  745. ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, {
  746. ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, {
  747. ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED}, {
  748. ERRDOS, ErrTooManyLinks, NT_STATUS_TOO_MANY_LINKS}, {
  749. ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT}, {
  750. ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE}, {
  751. ERRDOS, 21, 0xc000026e}, {
  752. ERRDOS, 161, 0xc0000281}, {
  753. ERRDOS, ERRnoaccess, 0xc000028a}, {
  754. ERRDOS, ERRnoaccess, 0xc000028b}, {
  755. ERRHRD, ERRgeneral, 0xc000028c}, {
  756. ERRDOS, ERRnoaccess, 0xc000028d}, {
  757. ERRDOS, ERRnoaccess, 0xc000028e}, {
  758. ERRDOS, ERRnoaccess, 0xc000028f}, {
  759. ERRDOS, ERRnoaccess, 0xc0000290}, {
  760. ERRDOS, ERRbadfunc, 0xc000029c}, {
  761. ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
  762. ERRDOS, ERRinvlevel, 0x007c0001}, {
  763. 0, 0, 0 }
  764. };
  765. /*****************************************************************************
  766. Print an error message from the status code
  767. *****************************************************************************/
  768. static void
  769. cifs_print_status(__u32 status_code)
  770. {
  771. int idx = 0;
  772. while (nt_errs[idx].nt_errstr != NULL) {
  773. if (((nt_errs[idx].nt_errcode) & 0xFFFFFF) ==
  774. (status_code & 0xFFFFFF)) {
  775. pr_notice("Status code returned 0x%08x %s\n",
  776. status_code, nt_errs[idx].nt_errstr);
  777. }
  778. idx++;
  779. }
  780. return;
  781. }
  782. static void
  783. ntstatus_to_dos(__u32 ntstatus, __u8 *eclass, __u16 *ecode)
  784. {
  785. int i;
  786. if (ntstatus == 0) {
  787. *eclass = 0;
  788. *ecode = 0;
  789. return;
  790. }
  791. for (i = 0; ntstatus_to_dos_map[i].ntstatus; i++) {
  792. if (ntstatus == ntstatus_to_dos_map[i].ntstatus) {
  793. *eclass = ntstatus_to_dos_map[i].dos_class;
  794. *ecode = ntstatus_to_dos_map[i].dos_code;
  795. return;
  796. }
  797. }
  798. *eclass = ERRHRD;
  799. *ecode = ERRgeneral;
  800. }
  801. int
  802. map_smb_to_linux_error(char *buf, bool logErr)
  803. {
  804. struct smb_hdr *smb = (struct smb_hdr *)buf;
  805. unsigned int i;
  806. int rc = -EIO; /* if transport error smb error may not be set */
  807. __u8 smberrclass;
  808. __u16 smberrcode;
  809. /* BB if NT Status codes - map NT BB */
  810. /* old style smb error codes */
  811. if (smb->Status.CifsError == 0)
  812. return 0;
  813. if (smb->Flags2 & SMBFLG2_ERR_STATUS) {
  814. /* translate the newer STATUS codes to old style SMB errors
  815. * and then to POSIX errors */
  816. __u32 err = le32_to_cpu(smb->Status.CifsError);
  817. if (logErr && (err != (NT_STATUS_MORE_PROCESSING_REQUIRED)))
  818. cifs_print_status(err);
  819. else if (cifsFYI & CIFS_RC)
  820. cifs_print_status(err);
  821. ntstatus_to_dos(err, &smberrclass, &smberrcode);
  822. } else {
  823. smberrclass = smb->Status.DosError.ErrorClass;
  824. smberrcode = le16_to_cpu(smb->Status.DosError.Error);
  825. }
  826. /* old style errors */
  827. /* DOS class smb error codes - map DOS */
  828. if (smberrclass == ERRDOS) {
  829. /* 1 byte field no need to byte reverse */
  830. for (i = 0;
  831. i <
  832. sizeof(mapping_table_ERRDOS) /
  833. sizeof(struct smb_to_posix_error); i++) {
  834. if (mapping_table_ERRDOS[i].smb_err == 0)
  835. break;
  836. else if (mapping_table_ERRDOS[i].smb_err ==
  837. smberrcode) {
  838. rc = mapping_table_ERRDOS[i].posix_code;
  839. break;
  840. }
  841. /* else try next error mapping one to see if match */
  842. }
  843. } else if (smberrclass == ERRSRV) {
  844. /* server class of error codes */
  845. for (i = 0;
  846. i <
  847. sizeof(mapping_table_ERRSRV) /
  848. sizeof(struct smb_to_posix_error); i++) {
  849. if (mapping_table_ERRSRV[i].smb_err == 0)
  850. break;
  851. else if (mapping_table_ERRSRV[i].smb_err ==
  852. smberrcode) {
  853. rc = mapping_table_ERRSRV[i].posix_code;
  854. break;
  855. }
  856. /* else try next error mapping to see if match */
  857. }
  858. }
  859. /* else ERRHRD class errors or junk - return EIO */
  860. cifs_dbg(FYI, "Mapping smb error code 0x%x to POSIX err %d\n",
  861. le32_to_cpu(smb->Status.CifsError), rc);
  862. /* generic corrective action e.g. reconnect SMB session on
  863. * ERRbaduid could be added */
  864. return rc;
  865. }
  866. /*
  867. * calculate the size of the SMB message based on the fixed header
  868. * portion, the number of word parameters and the data portion of the message
  869. */
  870. unsigned int
  871. smbCalcSize(void *buf)
  872. {
  873. struct smb_hdr *ptr = (struct smb_hdr *)buf;
  874. return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +
  875. 2 /* size of the bcc field */ + get_bcc(ptr));
  876. }
  877. /* The following are taken from fs/ntfs/util.c */
  878. #define NTFS_TIME_OFFSET ((u64)(369*365 + 89) * 24 * 3600 * 10000000)
  879. /*
  880. * Convert the NT UTC (based 1601-01-01, in hundred nanosecond units)
  881. * into Unix UTC (based 1970-01-01, in seconds).
  882. */
  883. struct timespec
  884. cifs_NTtimeToUnix(__le64 ntutc)
  885. {
  886. struct timespec ts;
  887. /* BB what about the timezone? BB */
  888. /* Subtract the NTFS time offset, then convert to 1s intervals. */
  889. s64 t = le64_to_cpu(ntutc) - NTFS_TIME_OFFSET;
  890. u64 abs_t;
  891. /*
  892. * Unfortunately can not use normal 64 bit division on 32 bit arch, but
  893. * the alternative, do_div, does not work with negative numbers so have
  894. * to special case them
  895. */
  896. if (t < 0) {
  897. abs_t = -t;
  898. ts.tv_nsec = (long)(do_div(abs_t, 10000000) * 100);
  899. ts.tv_nsec = -ts.tv_nsec;
  900. ts.tv_sec = -abs_t;
  901. } else {
  902. abs_t = t;
  903. ts.tv_nsec = (long)do_div(abs_t, 10000000) * 100;
  904. ts.tv_sec = abs_t;
  905. }
  906. return ts;
  907. }
  908. /* Convert the Unix UTC into NT UTC. */
  909. u64
  910. cifs_UnixTimeToNT(struct timespec t)
  911. {
  912. /* Convert to 100ns intervals and then add the NTFS time offset. */
  913. return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET;
  914. }
  915. static const int total_days_of_prev_months[] = {
  916. 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
  917. };
  918. struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset)
  919. {
  920. struct timespec ts;
  921. int sec, min, days, month, year;
  922. u16 date = le16_to_cpu(le_date);
  923. u16 time = le16_to_cpu(le_time);
  924. SMB_TIME *st = (SMB_TIME *)&time;
  925. SMB_DATE *sd = (SMB_DATE *)&date;
  926. cifs_dbg(FYI, "date %d time %d\n", date, time);
  927. sec = 2 * st->TwoSeconds;
  928. min = st->Minutes;
  929. if ((sec > 59) || (min > 59))
  930. cifs_dbg(VFS, "illegal time min %d sec %d\n", min, sec);
  931. sec += (min * 60);
  932. sec += 60 * 60 * st->Hours;
  933. if (st->Hours > 24)
  934. cifs_dbg(VFS, "illegal hours %d\n", st->Hours);
  935. days = sd->Day;
  936. month = sd->Month;
  937. if (days < 1 || days > 31 || month < 1 || month > 12) {
  938. cifs_dbg(VFS, "illegal date, month %d day: %d\n", month, days);
  939. days = clamp(days, 1, 31);
  940. month = clamp(month, 1, 12);
  941. }
  942. month -= 1;
  943. days += total_days_of_prev_months[month];
  944. days += 3652; /* account for difference in days between 1980 and 1970 */
  945. year = sd->Year;
  946. days += year * 365;
  947. days += (year/4); /* leap year */
  948. /* generalized leap year calculation is more complex, ie no leap year
  949. for years/100 except for years/400, but since the maximum number for DOS
  950. year is 2**7, the last year is 1980+127, which means we need only
  951. consider 2 special case years, ie the years 2000 and 2100, and only
  952. adjust for the lack of leap year for the year 2100, as 2000 was a
  953. leap year (divisable by 400) */
  954. if (year >= 120) /* the year 2100 */
  955. days = days - 1; /* do not count leap year for the year 2100 */
  956. /* adjust for leap year where we are still before leap day */
  957. if (year != 120)
  958. days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
  959. sec += 24 * 60 * 60 * days;
  960. ts.tv_sec = sec + offset;
  961. /* cifs_dbg(FYI, "sec after cnvrt dos to unix time %d\n",sec); */
  962. ts.tv_nsec = 0;
  963. return ts;
  964. }