dentry.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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(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(struct dentry *dentry, struct qstr *a, struct qstr *b)
  31. {
  32. unsigned al=a->len;
  33. unsigned bl=b->len;
  34. hpfs_adjust_length(a->name, &al);
  35. /*hpfs_adjust_length(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(b->name, &bl))
  40. return 1;
  41. if (hpfs_compare_names(dentry->d_sb, a->name, al, b->name, bl, 0))
  42. return 1;
  43. return 0;
  44. }
  45. static const struct dentry_operations hpfs_dentry_operations = {
  46. .d_hash = hpfs_hash_dentry,
  47. .d_compare = hpfs_compare_dentry,
  48. };
  49. void hpfs_set_dentry_operations(struct dentry *dentry)
  50. {
  51. dentry->d_op = &hpfs_dentry_operations;
  52. }