INT32 nls_uniname_cmp(struct super_block *sb, UINT16 *a, UINT16 *b)
{
	INT32 i;

	for (i = 0; i < MAX_NAME_LENGTH; i++, a++, b++) {
		if (nls_upper(sb, *a) != nls_upper(sb, *b)) return(1);
		if (*a == 0x0) return(0);
	}
	return(0);
}
Beispiel #2
0
s32 nls_uniname_cmp(struct super_block *sb, u16 *a, u16 *b)
{
	int i;

	for (i = 0; i < MAX_NAME_LENGTH; i++, a++, b++) {
		if (nls_upper(sb, *a) != nls_upper(sb, *b))
			return 1;
		if (*a == 0x0)
			return 0;
	}
	return 0;
} /* end of nls_uniname_cmp */
void nls_cstring_to_uniname(struct super_block *sb, UNI_NAME_T *p_uniname, UINT8 *p_cstring, INT32 *p_lossy)
{
	INT32 i, j, lossy = FALSE;
	UINT8 *end_of_name;
	UINT8 upname[MAX_NAME_LENGTH * 2];
	UINT16 *uniname = p_uniname->name;
	struct nls_table *nls = EXFAT_SB(sb)->nls_io;


	/* strip all trailing spaces */
	end_of_name = p_cstring + STRLEN((INT8 *) p_cstring);

	while (*(--end_of_name) == ' ') {
		if (end_of_name < p_cstring) break;
	}
	*(++end_of_name) = '\0';

	if (STRCMP((INT8 *) p_cstring, ".") && STRCMP((INT8 *) p_cstring, "..")) {

		/* strip all trailing periods */
		while (*(--end_of_name) == '.') {
			if (end_of_name < p_cstring) break;
		}
		*(++end_of_name) = '\0';
	}

	if (*p_cstring == '\0')
		lossy = TRUE;

	i = j = 0;
	while (j < (MAX_NAME_LENGTH-1)) {
		if (*(p_cstring+i) == '\0') break;

		i += convert_ch_to_uni(nls, uniname, (UINT8 *)(p_cstring+i), &lossy);

		if ((*uniname < 0x0020) || WSTRCHR(bad_uni_chars, *uniname))
			lossy = TRUE;

		SET16_A(upname + j * 2, nls_upper(sb, *uniname));

		uniname++;
		j++;
	}

	if (*(p_cstring+i) != '\0')
		lossy = TRUE;
	*uniname = (UINT16) '\0';

	p_uniname->name_len = j;
	p_uniname->name_hash = calc_checksum_2byte((void *) upname, j<<1, 0, CS_DEFAULT);

	if (p_lossy != NULL)
		*p_lossy = lossy;
} /* end of nls_cstring_to_uniname */
Beispiel #4
0
void nls_cstring_to_uniname(struct super_block *sb, UNI_NAME_T *p_uniname, u8 *p_cstring, s32 *p_lossy)
{
	int i, j, lossy = FALSE;
	u8 *end_of_name;
	u8 upname[MAX_NAME_LENGTH * 2];
	u16 *uniname = p_uniname->name;
	struct nls_table *nls = EXFAT_SB(sb)->nls_io;


	/* strip all trailing spaces */
	end_of_name = p_cstring + strlen((char *) p_cstring);

	while (*(--end_of_name) == ' ') {
		if (end_of_name < p_cstring)
			break;
	}
	*(++end_of_name) = '\0';

	if (strcmp((char *) p_cstring, ".") && strcmp((char *) p_cstring, "..")) {

		/* strip all trailing periods */
		while (*(--end_of_name) == '.') {
			if (end_of_name < p_cstring)
				break;
		}
		*(++end_of_name) = '\0';
	}

	if (*p_cstring == '\0')
		lossy = TRUE;

	if (nls == NULL) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
		i = utf8s_to_utf16s(p_cstring, MAX_NAME_LENGTH, uniname);
#else
		i = utf8s_to_utf16s(p_cstring, MAX_NAME_LENGTH, UTF16_HOST_ENDIAN, uniname, MAX_NAME_LENGTH);
#endif
		for (j = 0; j < i; j++)
			SET16_A(upname + j * 2, nls_upper(sb, uniname[j]));
		uniname[i] = '\0';
	}
	else {
		i = j = 0;
		while (j < (MAX_NAME_LENGTH-1)) {
			if (*(p_cstring+i) == '\0')
				break;

			i += convert_ch_to_uni(nls, uniname, (u8 *)(p_cstring+i), &lossy);

			if ((*uniname < 0x0020) || nls_wstrchr(bad_uni_chars, *uniname))
				lossy = TRUE;

			SET16_A(upname + j * 2, nls_upper(sb, *uniname));

			uniname++;
			j++;
		}

		if (*(p_cstring+i) != '\0')
			lossy = TRUE;
		*uniname = (u16) '\0';
	}

	p_uniname->name_len = j;
	p_uniname->name_hash = calc_checksum_2byte((void *) upname, j<<1, 0, CS_DEFAULT);

	if (p_lossy != NULL)
		*p_lossy = lossy;
} /* end of nls_cstring_to_uniname */