dentry.c 1.4 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 *  linux/fs/hpfs/dentry.c
 *
 *  Mikulas Patocka (mikulas@artax.karlin.mff.cuni.cz), 1998-1999
 *
 *  dcache operations
 */

#include "hpfs_fn.h"

/*
 * Note: the dentry argument is the parent dentry.
 */

15
static int hpfs_hash_dentry(const struct dentry *dentry, struct qstr *qstr)
L
Linus Torvalds 已提交
16 17 18 19 20 21 22
{
	unsigned long	 hash;
	int		 i;
	unsigned l = qstr->len;

	if (l == 1) if (qstr->name[0]=='.') goto x;
	if (l == 2) if (qstr->name[0]=='.' || qstr->name[1]=='.') goto x;
23 24
	hpfs_adjust_length(qstr->name, &l);
	/*if (hpfs_chk_name(qstr->name,&l))*/
L
Linus Torvalds 已提交
25 26 27 28
		/*return -ENAMETOOLONG;*/
		/*return -ENOENT;*/
	x:

29
	hash = init_name_hash(dentry);
L
Linus Torvalds 已提交
30 31 32 33 34 35 36
	for (i = 0; i < l; i++)
		hash = partial_name_hash(hpfs_upcase(hpfs_sb(dentry->d_sb)->sb_cp_table,qstr->name[i]), hash);
	qstr->hash = end_name_hash(hash);

	return 0;
}

37
static int hpfs_compare_dentry(const struct dentry *dentry,
N
Nick Piggin 已提交
38
		unsigned int len, const char *str, const struct qstr *name)
L
Linus Torvalds 已提交
39
{
N
Nick Piggin 已提交
40 41 42 43
	unsigned al = len;
	unsigned bl = name->len;

	hpfs_adjust_length(str, &al);
44
	/*hpfs_adjust_length(b->name, &bl);*/
N
Nick Piggin 已提交
45 46 47 48

	/*
	 * 'str' is the nane of an already existing dentry, so the name
	 * must be valid. 'name' must be validated first.
L
Linus Torvalds 已提交
49 50
	 */

N
Nick Piggin 已提交
51
	if (hpfs_chk_name(name->name, &bl))
52
		return 1;
53
	if (hpfs_compare_names(dentry->d_sb, str, al, name->name, bl, 0))
54
		return 1;
L
Linus Torvalds 已提交
55 56 57
	return 0;
}

A
Al Viro 已提交
58
const struct dentry_operations hpfs_dentry_operations = {
L
Linus Torvalds 已提交
59 60 61
	.d_hash		= hpfs_hash_dentry,
	.d_compare	= hpfs_compare_dentry,
};