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