2 * Unix SMB/Netbios implementation.
4 * Unix/DOS/NT error code conversions
5 * Copyright (C) Tim Potter 2000
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /* Mapping between Unix, DOS and NT error numbers */
26 struct unix_error_map unix_dos_nt_errmap[] = {
27 { EPERM, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED },
28 { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED },
29 { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE },
30 { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_NOT_A_DIRECTORY },
31 { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR },
32 { EBADF, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE },
33 { EINVAL, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE },
34 { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_ACCESS_DENIED},
35 { ENFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES },
36 { EMFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES },
37 { ENOSPC, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL },
39 { EDQUOT, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL },
42 { ENOTEMPTY, ERRDOS, ERRnoaccess, NT_STATUS_DIRECTORY_NOT_EMPTY },
45 { EXDEV, ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE },
48 { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED },
50 { 0, 0, 0, NT_STATUS_OK }
53 /*********************************************************************
54 Map an NT error code from a Unix error code.
55 *********************************************************************/
57 NTSTATUS map_nt_error_from_unix(int unix_error)
64 /* Look through list */
65 while(unix_dos_nt_errmap[i].unix_error != 0) {
66 if (unix_dos_nt_errmap[i].unix_error == unix_error)
67 return unix_dos_nt_errmap[i].nt_error;
72 return NT_STATUS_ACCESS_DENIED;