/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Translate Unix errno values to NT status, and NT status to
* DOS-style error class+code (for SMB1)
*/
#include <smbsrv/smb_kproto.h>
#include <smbsrv/smb_kstat.h>
#include "smbclnt/smb_status2winerr.h"
/*
* Map Unix errno values to NT status values.
*/
struct errno2status {
int errnum;
};
static const struct errno2status
smb_errno2status_map[] = {
{ EPERM, NT_STATUS_ACCESS_DENIED },
{ ENOENT, NT_STATUS_NO_SUCH_FILE },
/* NB: ESRCH is used to represent stream lookup failures. */
{ EINTR, NT_STATUS_CANCELLED },
{ EIO, NT_STATUS_IO_DEVICE_ERROR },
/* E2BIG, ENOEXEC */
/* ECHILD, EAGAIN */
{ ENOMEM, NT_STATUS_NO_MEMORY },
/* EFAULT, ENOTBLK, EBUSY */
/* ENOTDIR should be: NT_STATUS_NOT_A_DIRECTORY, but not yet */
/* ENOTTY, ETXTBSY, EFBIG */
{ ENOSPC, NT_STATUS_DISK_FULL },
/* ESPIPE */
{ EROFS, NT_STATUS_ACCESS_DENIED },
{ EPIPE, NT_STATUS_PIPE_BROKEN },
/* EDOM */
/* NB: ERANGE is used to represent lock range I/O conflicts. */
/* ENOMSG, EIDRM, ... */
{ EDQUOT, NT_STATUS_DISK_FULL },
{ 0, 0 }
};
{
if (errnum == 0)
return (0);
return (NT_STATUS_INTERNAL_ERROR);
}
/*
* Map NT Status codes to Win32 API error numbers.
* But note: we only want the ones below 0xFFFF,
* which can be returned in SMB with class=DOSERR.
*/
{
if (status == 0)
return (0);
return (ERROR_GEN_FAILURE);
}