Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *  linux/fs/hpfs/dentry.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *  Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *  dcache operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "hpfs_fn.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  * Note: the dentry argument is the parent dentry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) static int hpfs_hash_dentry(const struct dentry *dentry, struct qstr *qstr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	unsigned long	 hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	int		 i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	unsigned l = qstr->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	if (l == 1) if (qstr->name[0]=='.') goto x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	if (l == 2) if (qstr->name[0]=='.' || qstr->name[1]=='.') goto x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	hpfs_adjust_length(qstr->name, &l);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	/*if (hpfs_chk_name(qstr->name,&l))*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		/*return -ENAMETOOLONG;*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 		/*return -ENOENT;*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	x:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	hash = init_name_hash(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	for (i = 0; i < l; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 		hash = partial_name_hash(hpfs_upcase(hpfs_sb(dentry->d_sb)->sb_cp_table,qstr->name[i]), hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	qstr->hash = end_name_hash(hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static int hpfs_compare_dentry(const struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		unsigned int len, const char *str, const struct qstr *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	unsigned al = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	unsigned bl = name->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	hpfs_adjust_length(str, &al);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	/*hpfs_adjust_length(b->name, &bl);*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	 * 'str' is the nane of an already existing dentry, so the name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	 * must be valid. 'name' must be validated first.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	if (hpfs_chk_name(name->name, &bl))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	if (hpfs_compare_names(dentry->d_sb, str, al, name->name, bl, 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) const struct dentry_operations hpfs_dentry_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	.d_hash		= hpfs_hash_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	.d_compare	= hpfs_compare_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) };