dentry.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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, const struct inode *inode,
  13. 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();
  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 *parent,
  32. const struct inode *pinode,
  33. const struct dentry *dentry, const struct inode *inode,
  34. unsigned int len, const char *str, const struct qstr *name)
  35. {
  36. unsigned al = len;
  37. unsigned bl = name->len;
  38. hpfs_adjust_length(str, &al);
  39. /*hpfs_adjust_length(b->name, &bl);*/
  40. /*
  41. * 'str' is the nane of an already existing dentry, so the name
  42. * must be valid. 'name' must be validated first.
  43. */
  44. if (hpfs_chk_name(name->name, &bl))
  45. return 1;
  46. if (hpfs_compare_names(parent->d_sb, str, al, name->name, bl, 0))
  47. return 1;
  48. return 0;
  49. }
  50. const struct dentry_operations hpfs_dentry_operations = {
  51. .d_hash = hpfs_hash_dentry,
  52. .d_compare = hpfs_compare_dentry,
  53. };