dentry.c 1.4 KB

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