netmisc.c 39 KB

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