Blame view

fs/hpfs/dentry.c 1.5 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
  /*
   *  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.
   */
b1e6a015a   Nick Piggin   fs: change d_hash...
14
15
  static int hpfs_hash_dentry(const struct dentry *dentry, const struct inode *inode,
  		struct qstr *qstr)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
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;
7e7742ee0   Al Viro   sanitize signedne...
23
24
  	hpfs_adjust_length(qstr->name, &l);
  	/*if (hpfs_chk_name(qstr->name,&l))*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
26
27
28
29
30
31
32
33
34
35
  		/*return -ENAMETOOLONG;*/
  		/*return -ENOENT;*/
  	x:
  
  	hash = init_name_hash();
  	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;
  }
621e155a3   Nick Piggin   fs: change d_comp...
36
37
38
39
  static int hpfs_compare_dentry(const struct dentry *parent,
  		const struct inode *pinode,
  		const struct dentry *dentry, const struct inode *inode,
  		unsigned int len, const char *str, const struct qstr *name)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
  {
621e155a3   Nick Piggin   fs: change d_comp...
41
42
43
44
  	unsigned al = len;
  	unsigned bl = name->len;
  
  	hpfs_adjust_length(str, &al);
7e7742ee0   Al Viro   sanitize signedne...
45
  	/*hpfs_adjust_length(b->name, &bl);*/
621e155a3   Nick Piggin   fs: change d_comp...
46
47
48
49
  
  	/*
  	 * 'str' is the nane of an already existing dentry, so the name
  	 * must be valid. 'name' must be validated first.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
50
  	 */
621e155a3   Nick Piggin   fs: change d_comp...
51
  	if (hpfs_chk_name(name->name, &bl))
7e7742ee0   Al Viro   sanitize signedne...
52
  		return 1;
621e155a3   Nick Piggin   fs: change d_comp...
53
  	if (hpfs_compare_names(parent->d_sb, str, al, name->name, bl, 0))
7e7742ee0   Al Viro   sanitize signedne...
54
  		return 1;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
55
56
  	return 0;
  }
43d344d77   Al Viro   switch hpfs
57
  const struct dentry_operations hpfs_dentry_operations = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
58
59
60
  	.d_hash		= hpfs_hash_dentry,
  	.d_compare	= hpfs_compare_dentry,
  };