dentry.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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(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((char *)qstr->name, &l);
  20. /*if (hpfs_chk_name((char *)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(struct dentry *dentry, struct qstr *a, struct qstr *b)
  31. {
  32. unsigned al=a->len;
  33. unsigned bl=b->len;
  34. hpfs_adjust_length((char *)a->name, &al);
  35. /*hpfs_adjust_length((char *)b->name, &bl);*/
  36. /* 'a' is the qstr of an already existing dentry, so the name
  37. * must be valid. 'b' must be validated first.
  38. */
  39. if (hpfs_chk_name((char *)b->name, &bl)) return 1;
  40. if (hpfs_compare_names(dentry->d_sb, (char *)a->name, al, (char *)b->name, bl, 0)) return 1;
  41. return 0;
  42. }
  43. static struct dentry_operations hpfs_dentry_operations = {
  44. .d_hash = hpfs_hash_dentry,
  45. .d_compare = hpfs_compare_dentry,
  46. };
  47. void hpfs_set_dentry_operations(struct dentry *dentry)
  48. {
  49. dentry->d_op = &hpfs_dentry_operations;
  50. }