few edits
[Samba.git] / source / lib / error.c
blobf97a0e51ae589433a78b7e0baae124ca94faa605
1 /*
2 * Unix SMB/Netbios implementation.
3 * Version 1.9
4 * Unix/DOS/NT error code conversions
5 * Copyright (C) Tim Potter 2000
6 *
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.
22 #include "includes.h"
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_OBJECT_NAME_NOT_FOUND },
30 { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND },
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_OBJECT_NAME_COLLISION},
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 },
38 #ifdef EDQUOT
39 { EDQUOT, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL },
40 #endif
41 #ifdef ENOTEMPTY
42 { ENOTEMPTY, ERRDOS, ERRnoaccess, NT_STATUS_DIRECTORY_NOT_EMPTY },
43 #endif
44 #ifdef EXDEV
45 { EXDEV, ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE },
46 #endif
47 #ifdef EROFS
48 { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED },
49 #endif
50 #ifdef ENAMETOOLONG
51 { ENAMETOOLONG, ERRDOS, 206, NT_STATUS_OBJECT_NAME_INVALID },
52 #endif
53 { 0, 0, 0, NT_STATUS_OK }
56 /*********************************************************************
57 Map an NT error code from a Unix error code.
58 *********************************************************************/
60 NTSTATUS map_nt_error_from_unix(int unix_error)
62 int i = 0;
64 if (unix_error == 0)
65 return NT_STATUS_OK;
67 /* Look through list */
68 while(unix_dos_nt_errmap[i].unix_error != 0) {
69 if (unix_dos_nt_errmap[i].unix_error == unix_error)
70 return unix_dos_nt_errmap[i].nt_error;
71 i++;
74 /* Default return */
75 return NT_STATUS_ACCESS_DENIED;