2000-09-01 18:49:26 +00:00
/*
2002-01-30 06:08:46 +00:00
* Unix SMB / CIFS implementation .
2000-09-01 18:49:26 +00:00
* Unix / DOS / NT error code conversions
* Copyright ( C ) Tim Potter 2000
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
/* Mapping between Unix, DOS and NT error numbers */
2002-01-16 21:27:57 +00:00
struct unix_error_map unix_dos_nt_errmap [ ] = {
{ EPERM , ERRDOS , ERRnoaccess , NT_STATUS_ACCESS_DENIED } ,
{ EACCES , ERRDOS , ERRnoaccess , NT_STATUS_ACCESS_DENIED } ,
{ ENOENT , ERRDOS , ERRbadfile , NT_STATUS_NO_SUCH_FILE } ,
{ ENOTDIR , ERRDOS , ERRbadpath , NT_STATUS_NOT_A_DIRECTORY } ,
{ EIO , ERRHRD , ERRgeneral , NT_STATUS_IO_DEVICE_ERROR } ,
{ EBADF , ERRSRV , ERRsrverror , NT_STATUS_INVALID_HANDLE } ,
{ EINVAL , ERRSRV , ERRsrverror , NT_STATUS_INVALID_HANDLE } ,
2002-02-05 02:40:16 +00:00
{ EEXIST , ERRDOS , ERRfilexists , NT_STATUS_OBJECT_NAME_COLLISION } ,
2002-01-16 21:27:57 +00:00
{ ENFILE , ERRDOS , ERRnofids , NT_STATUS_TOO_MANY_OPENED_FILES } ,
{ EMFILE , ERRDOS , ERRnofids , NT_STATUS_TOO_MANY_OPENED_FILES } ,
{ ENOSPC , ERRHRD , ERRdiskfull , NT_STATUS_DISK_FULL } ,
2000-09-01 18:49:26 +00:00
# ifdef EDQUOT
2002-01-16 21:27:57 +00:00
{ EDQUOT , ERRHRD , ERRdiskfull , NT_STATUS_DISK_FULL } ,
2000-09-01 18:49:26 +00:00
# endif
# ifdef ENOTEMPTY
2002-01-16 21:27:57 +00:00
{ ENOTEMPTY , ERRDOS , ERRnoaccess , NT_STATUS_DIRECTORY_NOT_EMPTY } ,
2000-09-01 18:49:26 +00:00
# endif
# ifdef EXDEV
2002-01-16 21:27:57 +00:00
{ EXDEV , ERRDOS , ERRdiffdevice , NT_STATUS_NOT_SAME_DEVICE } ,
2000-09-01 18:49:26 +00:00
# endif
2002-01-16 21:27:57 +00:00
# ifdef EROFS
{ EROFS , ERRHRD , ERRnowrite , NT_STATUS_ACCESS_DENIED } ,
# endif
{ 0 , 0 , 0 , NT_STATUS_OK }
2000-09-01 18:49:26 +00:00
} ;
2002-01-16 21:27:57 +00:00
/*********************************************************************
Map an NT error code from a Unix error code .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-09-03 10:38:13 +00:00
NTSTATUS map_nt_error_from_unix ( int unix_error )
2000-09-01 18:49:26 +00:00
{
int i = 0 ;
2002-01-16 21:27:57 +00:00
if ( unix_error = = 0 )
return NT_STATUS_OK ;
2000-09-01 18:49:26 +00:00
2001-09-03 10:38:13 +00:00
/* Look through list */
2000-09-01 18:49:26 +00:00
while ( unix_dos_nt_errmap [ i ] . unix_error ! = 0 ) {
2002-01-16 21:27:57 +00:00
if ( unix_dos_nt_errmap [ i ] . unix_error = = unix_error )
2000-09-01 18:49:26 +00:00
return unix_dos_nt_errmap [ i ] . nt_error ;
i + + ;
}
/* Default return */
return NT_STATUS_ACCESS_DENIED ;
}