⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netmisc.c

📁 Linux Kernel 2.6.9 for OMAP1710
💻 C
📖 第 1 页 / 共 3 页
字号:
/* *   fs/cifs/netmisc.c * *   Copyright (c) International Business Machines  Corp., 2002 *   Author(s): Steve French (sfrench@us.ibm.com) *  *   Error mapping routines from Samba libsmb/errormap.c *   Copyright (C) Andrew Tridgell 2001 * * *   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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */#include <linux/net.h>#include <linux/string.h>#include <linux/in.h>#include <linux/ctype.h>#include <linux/fs.h>#include <asm/div64.h>#include <asm/byteorder.h>#include "cifsfs.h"#include "cifspdu.h"#include "cifsglob.h"#include "cifsproto.h"#include "smberr.h"#include "cifs_debug.h"#include "nterr.h"struct smb_to_posix_error {	__u16 smb_err;	int posix_code;};const struct smb_to_posix_error mapping_table_ERRDOS[] = {	{ERRbadfunc, -EINVAL},	{ERRbadfile, -ENOENT},	{ERRbadpath, -ENOTDIR},	{ERRnofids, -EMFILE},	{ERRnoaccess, -EACCES},	{ERRbadfid, -EBADF},	{ERRbadmcb, -EIO},	{ERRnomem, -ENOMEM},	{ERRbadmem, -EFAULT},	{ERRbadenv, -EFAULT},	{ERRbadformat, -EINVAL},	{ERRbadaccess, -EACCES},	{ERRbaddata, -EIO},	{ERRbaddrive, -ENXIO},	{ERRremcd, -EACCES},	{ERRdiffdevice, -EXDEV},	{ERRnofiles, -ENOENT},	{ERRbadshare, -ETXTBSY},	{ERRlock, -EACCES},	{ERRunsup, -EINVAL},	{ERRnosuchshare,-ENXIO},	{ERRfilexists, -EEXIST},	{ERRinvparm, -EINVAL},	{ERRdiskfull, -ENOSPC},	{ERRinvname, -ENOENT},	{ERRdirnotempty, -ENOTEMPTY},	{ERRnotlocked, -ENOLCK},	{ERRalreadyexists, -EEXIST},	{ERRmoredata, -EOVERFLOW},	{ErrQuota, -EDQUOT},	{ErrNotALink, -ENOLINK},	{ERRnetlogonNotStarted,-ENOPROTOOPT},	{0, 0}};const struct smb_to_posix_error mapping_table_ERRSRV[] = {	{ERRerror, -EIO},	{ERRbadpw, -EPERM},	{ERRbadtype, -EREMOTE},	{ERRaccess, -EACCES},	{ERRinvtid, -ENXIO},	{ERRinvnetname, -ENODEV},	{ERRinvdevice, -ENXIO},	{ERRqfull, -ENOSPC},	{ERRqtoobig, -ENOSPC},	{ERRqeof, -EIO},	{ERRinvpfid, -EBADF},	{ERRsmbcmd, -EBADRQC},	{ERRsrverror, -EIO},	{ERRbadBID, -EIO},	{ERRfilespecs, -EINVAL},	{ERRbadLink, -EIO},	{ERRbadpermits, -EINVAL},	{ERRbadPID, -ESRCH},	{ERRsetattrmode, -EINVAL},	{ERRpaused, -EHOSTDOWN},	{ERRmsgoff, -EHOSTDOWN},	{ERRnoroom, -ENOSPC},	{ERRrmuns, -EUSERS},	{ERRtimeout, -ETIME},	{ERRnoresource, -ENOBUFS},	{ERRtoomanyuids, -EUSERS},	{ERRbaduid, -EACCES},	{ERRusempx, -EIO},	{ERRusestd, -EIO},	{ERR_NOTIFY_ENUM_DIR, -ENOBUFS},	{ERRaccountexpired, -EACCES},	{ERRbadclient, -EACCES},	{ERRbadLogonTime, -EACCES},	{ERRpasswordExpired, -EACCES},	{ERRnosupport, -EINVAL},	{0, 0}};const struct smb_to_posix_error mapping_table_ERRHRD[] = {	{0, 0}};/* Convert string containing dotted ip address to binary form *//* returns 0 if invalid address *//* BB add address family, change rc to status flag and return union or for ipv6 *//*  will need parent to call something like inet_pton to convert ipv6 address  BB */intcifs_inet_pton(int address_family, char *cp,void *dst){	struct in_addr address;	int value;	int digit;	int i;	char temp;	char bytes[4];	char *end = bytes;	static const int addr_class_max[4] =	    { 0xffffffff, 0xffffff, 0xffff, 0xff };	if(address_family != AF_INET)		return -EAFNOSUPPORT;	for (i = 0; i < 4; i++) {		bytes[i] = 0;	}	temp = *cp;	while (TRUE) {		if (!isdigit(temp))			return 0;		value = 0;		digit = 0;		for (;;) {			if (isascii(temp) && isdigit(temp)) {				value = (value * 10) + temp - '0';				temp = *++cp;				digit = 1;			} else				break;		}		if (temp == '.') {			if ((end > bytes + 2) || (value > 255))				return 0;			*end++ = value;			temp = *++cp;		} else if (temp == ':') {			cFYI(1,("IPv6 addresses not supported for CIFS mounts yet"));			return -1;		} else			break;	}	/* check for last characters */	if (temp != '\0' && (!isascii(temp) || !isspace(temp)))		if (temp != '\\') {			if (temp != '/')				return 0;			else				(*cp = '\\');	/* switch the slash the expected way */		}	if (value > addr_class_max[end - bytes])		return 0;	address.s_addr = *((__be32 *) bytes) | htonl(value);	*((__be32 *)dst) = address.s_addr;	return 1; /* success */}/*****************************************************************************convert a NT status code to a dos class/code *****************************************************************************//* NT status -> dos error map */static const struct {	__u8 dos_class;	__u16 dos_code;	__u32 ntstatus;} ntstatus_to_dos_map[] = {	{	ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, {	ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, {	ERRDOS, 87, NT_STATUS_INVALID_INFO_CLASS}, {	ERRDOS, 24, NT_STATUS_INFO_LENGTH_MISMATCH}, {	ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION}, {	ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR}, {	ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA}, {	ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, {	ERRHRD, ERRgeneral, NT_STATUS_BAD_INITIAL_STACK}, {	ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC}, {	ERRDOS, 87, NT_STATUS_INVALID_CID}, {	ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED}, {	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER}, {	ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE}, {	ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, {	ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST}, {	ERRDOS, 38, NT_STATUS_END_OF_FILE}, {	ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, {	ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE}, {	ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA}, {	ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR},/*	{ This NT error code was 'sqashed'	 from NT_STATUS_MORE_PROCESSING_REQUIRED to NT_STATUS_OK 	 during the session setup } */	{	ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY}, {	ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES}, {	ERRDOS, 487, NT_STATUS_NOT_MAPPED_VIEW}, {	ERRDOS, 87, NT_STATUS_UNABLE_TO_FREE_VM}, {	ERRDOS, 87, NT_STATUS_UNABLE_TO_DELETE_SECTION}, {	ERRDOS, 2142, NT_STATUS_INVALID_SYSTEM_SERVICE}, {	ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_INSTRUCTION}, {	ERRDOS, ERRnoaccess, NT_STATUS_INVALID_LOCK_SEQUENCE}, {	ERRDOS, ERRnoaccess, NT_STATUS_INVALID_VIEW_SIZE}, {	ERRDOS, 193, NT_STATUS_INVALID_FILE_FOR_SECTION}, {	ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED},/*	{ This NT error code was 'sqashed'	 from NT_STATUS_ACCESS_DENIED to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE 	 during the session setup }   */	{	ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED}, {	ERRDOS, 111, NT_STATUS_BUFFER_TOO_SMALL}, {	ERRDOS, ERRbadfid, NT_STATUS_OBJECT_TYPE_MISMATCH}, {	ERRHRD, ERRgeneral, NT_STATUS_NONCONTINUABLE_EXCEPTION}, {	ERRHRD, ERRgeneral, NT_STATUS_INVALID_DISPOSITION}, {	ERRHRD, ERRgeneral, NT_STATUS_UNWIND}, {	ERRHRD, ERRgeneral, NT_STATUS_BAD_STACK}, {	ERRHRD, ERRgeneral, NT_STATUS_INVALID_UNWIND_TARGET}, {	ERRDOS, 158, NT_STATUS_NOT_LOCKED}, {	ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR}, {	ERRDOS, 487, NT_STATUS_UNABLE_TO_DECOMMIT_VM}, {	ERRDOS, 487, NT_STATUS_NOT_COMMITTED}, {	ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES}, {	ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG}, {	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_MIX}, {	ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER}, {	ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, {	ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_INVALID}, {	/* mapping changed since shell does lookup on * and expects file not found */	ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, {	ERRDOS, ERRalreadyexists, NT_STATUS_OBJECT_NAME_COLLISION}, {	ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, {	ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED}, {	ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED}, {	ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID}, {	ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, {	ERRDOS, 161, NT_STATUS_OBJECT_PATH_SYNTAX_BAD}, {	ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN}, {	ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR}, {	ERRDOS, 23, NT_STATUS_DATA_ERROR}, {	ERRDOS, 23, NT_STATUS_CRC_ERROR}, {	ERRDOS, ERRnomem, NT_STATUS_SECTION_TOO_BIG}, {	ERRDOS, ERRnoaccess, NT_STATUS_PORT_CONNECTION_REFUSED}, {	ERRDOS, ERRbadfid, NT_STATUS_INVALID_PORT_HANDLE}, {	ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, {	ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED}, {	ERRDOS, 87, NT_STATUS_INVALID_PAGE_PROTECTION}, {	ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED}, {	ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, {	ERRDOS, 87, NT_STATUS_PORT_ALREADY_SET}, {	ERRDOS, 87, NT_STATUS_SECTION_NOT_IMAGE}, {	ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, {	ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING}, {	ERRDOS, 87, NT_STATUS_BAD_WORKING_SET_LIMIT}, {	ERRDOS, 87, NT_STATUS_INCOMPATIBLE_FILE_MAP}, {	ERRDOS, 87, NT_STATUS_SECTION_PROTECTION}, {	ERRDOS, 282, NT_STATUS_EAS_NOT_SUPPORTED}, {	ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, {	ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY}, {	ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE}, {	ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR}, {	ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, {	ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED}, {	ERRDOS, ERRbadfile, NT_STATUS_DELETE_PENDING}, {	ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, {	ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION}, {	ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH}, {	ERRHRD, ERRgeneral, NT_STATUS_INVALID_OWNER}, {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -