dentry.c 1.4 KB

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