18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * collate.h - Defines for NTFS kernel collation handling.  Part of the
48c2ecf20Sopenharmony_ci *	       Linux-NTFS project.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (c) 2004 Anton Altaparmakov
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef _LINUX_NTFS_COLLATE_H
108c2ecf20Sopenharmony_ci#define _LINUX_NTFS_COLLATE_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include "types.h"
138c2ecf20Sopenharmony_ci#include "volume.h"
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistatic inline bool ntfs_is_collation_rule_supported(COLLATION_RULE cr) {
168c2ecf20Sopenharmony_ci	int i;
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci	/*
198c2ecf20Sopenharmony_ci	 * FIXME:  At the moment we only support COLLATION_BINARY and
208c2ecf20Sopenharmony_ci	 * COLLATION_NTOFS_ULONG, so we return false for everything else for
218c2ecf20Sopenharmony_ci	 * now.
228c2ecf20Sopenharmony_ci	 */
238c2ecf20Sopenharmony_ci	if (unlikely(cr != COLLATION_BINARY && cr != COLLATION_NTOFS_ULONG))
248c2ecf20Sopenharmony_ci		return false;
258c2ecf20Sopenharmony_ci	i = le32_to_cpu(cr);
268c2ecf20Sopenharmony_ci	if (likely(((i >= 0) && (i <= 0x02)) ||
278c2ecf20Sopenharmony_ci			((i >= 0x10) && (i <= 0x13))))
288c2ecf20Sopenharmony_ci		return true;
298c2ecf20Sopenharmony_ci	return false;
308c2ecf20Sopenharmony_ci}
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ciextern int ntfs_collate(ntfs_volume *vol, COLLATION_RULE cr,
338c2ecf20Sopenharmony_ci		const void *data1, const int data1_len,
348c2ecf20Sopenharmony_ci		const void *data2, const int data2_len);
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#endif /* _LINUX_NTFS_COLLATE_H */
37