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

📄 netmisc.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	ERRDOS, 64, NT_STATUS_CONNECTION_RESET}, {	ERRDOS, 68, NT_STATUS_TOO_MANY_NODES}, {	ERRDOS, 59, NT_STATUS_TRANSACTION_ABORTED}, {	ERRDOS, 59, NT_STATUS_TRANSACTION_TIMED_OUT}, {	ERRDOS, 59, NT_STATUS_TRANSACTION_NO_RELEASE}, {	ERRDOS, 59, NT_STATUS_TRANSACTION_NO_MATCH}, {	ERRDOS, 59, NT_STATUS_TRANSACTION_RESPONDED}, {	ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_ID}, {	ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_TYPE}, {	ERRDOS, ERRunsup, NT_STATUS_NOT_SERVER_SESSION}, {	ERRDOS, ERRunsup, NT_STATUS_NOT_CLIENT_SESSION}, {	ERRHRD, ERRgeneral, NT_STATUS_CANNOT_LOAD_REGISTRY_FILE}, {	ERRHRD, ERRgeneral, NT_STATUS_DEBUG_ATTACH_FAILED}, {	ERRHRD, ERRgeneral, NT_STATUS_SYSTEM_PROCESS_TERMINATED}, {	ERRHRD, ERRgeneral, NT_STATUS_DATA_NOT_ACCEPTED}, {	ERRHRD, ERRgeneral, NT_STATUS_NO_BROWSER_SERVERS_FOUND}, {	ERRHRD, ERRgeneral, NT_STATUS_VDM_HARD_ERROR}, {	ERRHRD, ERRgeneral, NT_STATUS_DRIVER_CANCEL_TIMEOUT}, {	ERRHRD, ERRgeneral, NT_STATUS_REPLY_MESSAGE_MISMATCH}, {	ERRHRD, ERRgeneral, NT_STATUS_MAPPED_ALIGNMENT}, {	ERRDOS, 193, NT_STATUS_IMAGE_CHECKSUM_MISMATCH}, {	ERRHRD, ERRgeneral, NT_STATUS_LOST_WRITEBEHIND_DATA}, {	ERRHRD, ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID}, {	ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_MUST_CHANGE}, {	ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND}, {	ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM}, {	ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE}, {	ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW_READ}, {	ERRHRD, ERRgeneral, NT_STATUS_FAIL_CHECK}, {	ERRHRD, ERRgeneral, NT_STATUS_DUPLICATE_OBJECTID}, {	ERRHRD, ERRgeneral, NT_STATUS_OBJECTID_EXISTS}, {	ERRHRD, ERRgeneral, NT_STATUS_CONVERT_TO_LARGE}, {	ERRHRD, ERRgeneral, NT_STATUS_RETRY}, {	ERRHRD, ERRgeneral, NT_STATUS_FOUND_OUT_OF_SCOPE}, {	ERRHRD, ERRgeneral, NT_STATUS_ALLOCATE_BUCKET}, {	ERRHRD, ERRgeneral, NT_STATUS_PROPSET_NOT_FOUND}, {	ERRHRD, ERRgeneral, NT_STATUS_MARSHALL_OVERFLOW}, {	ERRHRD, ERRgeneral, NT_STATUS_INVALID_VARIANT}, {	ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND}, {	ERRDOS, ERRnoaccess, NT_STATUS_ACCOUNT_LOCKED_OUT}, {	ERRDOS, ERRbadfid, NT_STATUS_HANDLE_NOT_CLOSABLE}, {	ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED}, {	ERRHRD, ERRgeneral, NT_STATUS_GRACEFUL_DISCONNECT}, {	ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED}, {	ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_NOT_ASSOCIATED}, {	ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_INVALID}, {	ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ACTIVE}, {	ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE}, {	ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE}, {	ERRHRD, ERRgeneral, NT_STATUS_PROTOCOL_UNREACHABLE}, {	ERRHRD, ERRgeneral, NT_STATUS_PORT_UNREACHABLE}, {	ERRHRD, ERRgeneral, NT_STATUS_REQUEST_ABORTED}, {	ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED}, {	ERRHRD, ERRgeneral, NT_STATUS_BAD_COMPRESSION_BUFFER}, {	ERRHRD, ERRgeneral, NT_STATUS_USER_MAPPED_FILE}, {	ERRHRD, ERRgeneral, NT_STATUS_AUDIT_FAILED}, {	ERRHRD, ERRgeneral, NT_STATUS_TIMER_RESOLUTION_NOT_SET}, {	ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_COUNT_LIMIT}, {	ERRHRD, ERRgeneral, NT_STATUS_LOGIN_TIME_RESTRICTION}, {	ERRHRD, ERRgeneral, NT_STATUS_LOGIN_WKSTA_RESTRICTION}, {	ERRDOS, 193, NT_STATUS_IMAGE_MP_UP_MISMATCH}, {	ERRHRD, ERRgeneral, 0xc000024a}, {	ERRHRD, ERRgeneral, 0xc000024b}, {	ERRHRD, ERRgeneral, 0xc000024c}, {	ERRHRD, ERRgeneral, 0xc000024d}, {	ERRHRD, ERRgeneral, 0xc000024e}, {	ERRHRD, ERRgeneral, 0xc000024f}, {	ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO}, {	ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT}, {	ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT}, {	ERRHRD, ERRgeneral, NT_STATUS_LPC_REPLY_LOST}, {	ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT1}, {	ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT2}, {	ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_QUOTA_LIMIT}, {	ERRSRV, 3, NT_STATUS_PATH_NOT_COVERED}, {	ERRHRD, ERRgeneral, NT_STATUS_NO_CALLBACK_ACTIVE}, {	ERRHRD, ERRgeneral, NT_STATUS_LICENSE_QUOTA_EXCEEDED}, {	ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT}, {	ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT}, {	ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT}, {	ERRHRD, ERRgeneral, 0xc000025d}, {	ERRHRD, ERRgeneral, NT_STATUS_PLUGPLAY_NO_DEVICE}, {	ERRHRD, ERRgeneral, NT_STATUS_UNSUPPORTED_COMPRESSION}, {	ERRHRD, ERRgeneral, NT_STATUS_INVALID_HW_PROFILE}, {	ERRHRD, ERRgeneral, NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH}, {	ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, {	ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, {	ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED}, {	ERRDOS, ErrTooManyLinks, NT_STATUS_TOO_MANY_LINKS}, {	ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT}, {	ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE}, {	ERRDOS, 21, 0xc000026e}, {	ERRDOS, 161, 0xc0000281}, {	ERRDOS, ERRnoaccess, 0xc000028a}, {	ERRDOS, ERRnoaccess, 0xc000028b}, {	ERRHRD, ERRgeneral, 0xc000028c}, {	ERRDOS, ERRnoaccess, 0xc000028d}, {	ERRDOS, ERRnoaccess, 0xc000028e}, {	ERRDOS, ERRnoaccess, 0xc000028f}, {	ERRDOS, ERRnoaccess, 0xc0000290}, {	ERRDOS, ERRbadfunc, 0xc000029c}, {	ERRDOS, ERRinvlevel, 0x007c0001}, };/***************************************************************************** Print an error message from the status code *****************************************************************************/static voidcifs_print_status(__u32 status_code){	int idx = 0;	while (nt_errs[idx].nt_errstr != NULL) {		if (((nt_errs[idx].nt_errcode) & 0xFFFFFF) ==		    (status_code & 0xFFFFFF)) {			printk(KERN_NOTICE "Status code returned 0x%08x %s\n",				   status_code, nt_errs[idx].nt_errstr);		}		idx++;	}	return;}static voidntstatus_to_dos(__u32 ntstatus, __u8 *eclass, __u16 *ecode){	int i;	if (ntstatus == 0) {		*eclass = 0;		*ecode = 0;		return;	}	for (i = 0; ntstatus_to_dos_map[i].ntstatus; i++) {		if (ntstatus == ntstatus_to_dos_map[i].ntstatus) {			*eclass = ntstatus_to_dos_map[i].dos_class;			*ecode = ntstatus_to_dos_map[i].dos_code;			return;		}	}	*eclass = ERRHRD;	*ecode = ERRgeneral;}intmap_smb_to_linux_error(struct smb_hdr *smb, int logErr){	unsigned int i;	int rc = -EIO;	/* if transport error smb error may not be set */	__u8 smberrclass;	__u16 smberrcode;	/* BB if NT Status codes - map NT BB */	/* old style smb error codes */	if (smb->Status.CifsError == 0)		return 0;	if (smb->Flags2 & SMBFLG2_ERR_STATUS) {		/* translate the newer STATUS codes to old style SMB errors		 * and then to POSIX errors */		__u32 err = le32_to_cpu(smb->Status.CifsError);		if (logErr && (err != (NT_STATUS_MORE_PROCESSING_REQUIRED)))			cifs_print_status(err);		else if (cifsFYI & CIFS_RC)			cifs_print_status(err);		ntstatus_to_dos(err, &smberrclass, &smberrcode);	} else {		smberrclass = smb->Status.DosError.ErrorClass;		smberrcode = le16_to_cpu(smb->Status.DosError.Error);	}	/* old style errors */	/* DOS class smb error codes - map DOS */	if (smberrclass == ERRDOS) {  /* 1 byte field no need to byte reverse */		for (i = 0;		     i <		     sizeof(mapping_table_ERRDOS) /		     sizeof(struct smb_to_posix_error); i++) {			if (mapping_table_ERRDOS[i].smb_err == 0)				break;			else if (mapping_table_ERRDOS[i].smb_err ==								smberrcode) {				rc = mapping_table_ERRDOS[i].posix_code;				break;			}			/* else try next error mapping one to see if match */		}	} else if (smberrclass == ERRSRV) {   /* server class of error codes */		for (i = 0;		     i <		     sizeof(mapping_table_ERRSRV) /		     sizeof(struct smb_to_posix_error); i++) {			if (mapping_table_ERRSRV[i].smb_err == 0)				break;			else if (mapping_table_ERRSRV[i].smb_err ==								smberrcode) {				rc = mapping_table_ERRSRV[i].posix_code;				break;			}			/* else try next error mapping to see if match */		}	}	/* else ERRHRD class errors or junk  - return EIO */	cFYI(1, ("Mapping smb error code %d to POSIX err %d",		 smberrcode, rc));	/* generic corrective action e.g. reconnect SMB session on	 * ERRbaduid could be added */	return rc;}/* * calculate the size of the SMB message based on the fixed header * portion, the number of word parameters and the data portion of the message */unsigned intsmbCalcSize(struct smb_hdr *ptr){	return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +		2 /* size of the bcc field */ + BCC(ptr));}unsigned intsmbCalcSize_LE(struct smb_hdr *ptr){	return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +		2 /* size of the bcc field */ + le16_to_cpu(BCC_LE(ptr)));}/* The following are taken from fs/ntfs/util.c */#define NTFS_TIME_OFFSET ((u64)(369*365 + 89) * 24 * 3600 * 10000000)    /*     * Convert the NT UTC (based 1601-01-01, in hundred nanosecond units)     * into Unix UTC (based 1970-01-01, in seconds).     */struct timespeccifs_NTtimeToUnix(u64 ntutc){	struct timespec ts;	/* BB what about the timezone? BB */	/* Subtract the NTFS time offset, then convert to 1s intervals. */	u64 t;	t = ntutc - NTFS_TIME_OFFSET;	ts.tv_nsec = do_div(t, 10000000) * 100;	ts.tv_sec = t;	return ts;}/* Convert the Unix UTC into NT UTC. */u64cifs_UnixTimeToNT(struct timespec t){	/* Convert to 100ns intervals and then add the NTFS time offset. */	return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET;}static int total_days_of_prev_months[] ={0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};__le64 cnvrtDosCifsTm(__u16 date, __u16 time){	return cpu_to_le64(cifs_UnixTimeToNT(cnvrtDosUnixTm(date, time)));}struct timespec cnvrtDosUnixTm(__u16 date, __u16 time){	struct timespec ts;	int sec, min, days, month, year;	SMB_TIME * st = (SMB_TIME *)&time;	SMB_DATE * sd = (SMB_DATE *)&date;	cFYI(1, ("date %d time %d", date, time));	sec = 2 * st->TwoSeconds;	min = st->Minutes;	if ((sec > 59) || (min > 59))		cERROR(1, ("illegal time min %d sec %d", min, sec));	sec += (min * 60);	sec += 60 * 60 * st->Hours;	if (st->Hours > 24)		cERROR(1, ("illegal hours %d", st->Hours));	days = sd->Day;	month = sd->Month;	if ((days > 31) || (month > 12)) {		cERROR(1, ("illegal date, month %d day: %d", month, days));		if (month > 12)			month = 12;	}	month -= 1;	days += total_days_of_prev_months[month];	days += 3652; /* account for difference in days between 1980 and 1970 */	year = sd->Year;	days += year * 365;	days += (year/4); /* leap year */	/* generalized leap year calculation is more complex, ie no leap year	for years/100 except for years/400, but since the maximum number for DOS	 year is 2**7, the last year is 1980+127, which means we need only	 consider 2 special case years, ie the years 2000 and 2100, and only	 adjust for the lack of leap year for the year 2100, as 2000 was a	 leap year (divisable by 400) */	if (year >= 120)  /* the year 2100 */		days = days - 1;  /* do not count leap year for the year 2100 */	/* adjust for leap year where we are still before leap day */	if (year != 120)		days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);	sec += 24 * 60 * 60 * days;	ts.tv_sec = sec;	/* cFYI(1,("sec after cnvrt dos to unix time %d",sec)); */	ts.tv_nsec = 0;	return ts;}

⌨️ 快捷键说明

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