dir.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  3. * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
  4. *
  5. * This copyrighted material is made available to anyone wishing to use,
  6. * modify, copy, or redistribute it subject to the terms and conditions
  7. * of the GNU General Public License v.2.
  8. */
  9. #ifndef __DIR_DOT_H__
  10. #define __DIR_DOT_H__
  11. /**
  12. * gfs2_filldir_t - Report a directory entry to the caller of gfs2_dir_read()
  13. * @opaque: opaque data used by the function
  14. * @name: the name of the directory entry
  15. * @length: the length of the name
  16. * @offset: the entry's offset in the directory
  17. * @inum: the inode number the entry points to
  18. * @type: the type of inode the entry points to
  19. *
  20. * Returns: 0 on success, 1 if buffer full
  21. */
  22. typedef int (*gfs2_filldir_t) (void *opaque,
  23. const char *name, unsigned int length,
  24. uint64_t offset,
  25. struct gfs2_inum *inum, unsigned int type);
  26. int gfs2_dir_search(struct inode *dir, const struct qstr *filename,
  27. struct gfs2_inum *inum, unsigned int *type);
  28. int gfs2_dir_add(struct inode *inode, const struct qstr *filename,
  29. const struct gfs2_inum *inum, unsigned int type);
  30. int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *filename);
  31. int gfs2_dir_read(struct gfs2_inode *dip, uint64_t * offset, void *opaque,
  32. gfs2_filldir_t filldir);
  33. int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
  34. struct gfs2_inum *new_inum, unsigned int new_type);
  35. int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip);
  36. int gfs2_diradd_alloc_required(struct inode *dir,
  37. const struct qstr *filename);
  38. int gfs2_dir_get_buffer(struct gfs2_inode *ip, uint64_t block, int new,
  39. struct buffer_head **bhp);
  40. /* N.B. This probably ought to take inum & type as args as well */
  41. static inline void gfs2_qstr2dirent(const struct qstr *name, u16 reclen, struct gfs2_dirent *dent)
  42. {
  43. dent->de_inum.no_addr = cpu_to_be64(0);
  44. dent->de_inum.no_formal_ino = cpu_to_be64(0);
  45. dent->de_hash = cpu_to_be32(name->hash);
  46. dent->de_rec_len = cpu_to_be16(reclen);
  47. dent->de_name_len = cpu_to_be16(name->len);
  48. dent->de_type = cpu_to_be16(0);
  49. memset(dent->__pad, 0, sizeof(dent->__pad));
  50. memcpy((char*)(dent+1), name->name, name->len);
  51. }
  52. #endif /* __DIR_DOT_H__ */