xref: /OK3568_Linux_fs/kernel/fs/ntfs/collate.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * collate.h - Defines for NTFS kernel collation handling.  Part of the
4*4882a593Smuzhiyun  *	       Linux-NTFS project.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Copyright (c) 2004 Anton Altaparmakov
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #ifndef _LINUX_NTFS_COLLATE_H
10*4882a593Smuzhiyun #define _LINUX_NTFS_COLLATE_H
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #include "types.h"
13*4882a593Smuzhiyun #include "volume.h"
14*4882a593Smuzhiyun 
ntfs_is_collation_rule_supported(COLLATION_RULE cr)15*4882a593Smuzhiyun static inline bool ntfs_is_collation_rule_supported(COLLATION_RULE cr) {
16*4882a593Smuzhiyun 	int i;
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun 	/*
19*4882a593Smuzhiyun 	 * FIXME:  At the moment we only support COLLATION_BINARY and
20*4882a593Smuzhiyun 	 * COLLATION_NTOFS_ULONG, so we return false for everything else for
21*4882a593Smuzhiyun 	 * now.
22*4882a593Smuzhiyun 	 */
23*4882a593Smuzhiyun 	if (unlikely(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG))
24*4882a593Smuzhiyun 		return false;
25*4882a593Smuzhiyun 	i = le32_to_cpu(cr);
26*4882a593Smuzhiyun 	if (likely(((i >= 0) && (i <= 0x02)) ||
27*4882a593Smuzhiyun 			((i >= 0x10) && (i <= 0x13))))
28*4882a593Smuzhiyun 		return true;
29*4882a593Smuzhiyun 	return false;
30*4882a593Smuzhiyun }
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun extern int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr,
33*4882a593Smuzhiyun 		const void *data1, const int data1_len,
34*4882a593Smuzhiyun 		const void *data2, const int data2_len);
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #endif /* _LINUX_NTFS_COLLATE_H */
37