adfs.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Internal data structures for ADFS */
  2. #define ADFS_FREE_FRAG 0
  3. #define ADFS_BAD_FRAG 1
  4. #define ADFS_ROOT_FRAG 2
  5. #define ADFS_NDA_OWNER_READ (1 << 0)
  6. #define ADFS_NDA_OWNER_WRITE (1 << 1)
  7. #define ADFS_NDA_LOCKED (1 << 2)
  8. #define ADFS_NDA_DIRECTORY (1 << 3)
  9. #define ADFS_NDA_EXECUTE (1 << 4)
  10. #define ADFS_NDA_PUBLIC_READ (1 << 5)
  11. #define ADFS_NDA_PUBLIC_WRITE (1 << 6)
  12. #include "dir_f.h"
  13. struct buffer_head;
  14. /*
  15. * Directory handling
  16. */
  17. struct adfs_dir {
  18. struct super_block *sb;
  19. int nr_buffers;
  20. struct buffer_head *bh[4];
  21. unsigned int pos;
  22. unsigned int parent_id;
  23. struct adfs_dirheader dirhead;
  24. union adfs_dirtail dirtail;
  25. };
  26. /*
  27. * This is the overall maximum name length
  28. */
  29. #define ADFS_MAX_NAME_LEN 256
  30. struct object_info {
  31. __u32 parent_id; /* parent object id */
  32. __u32 file_id; /* object id */
  33. __u32 loadaddr; /* load address */
  34. __u32 execaddr; /* execution address */
  35. __u32 size; /* size */
  36. __u8 attr; /* RISC OS attributes */
  37. unsigned char name_len; /* name length */
  38. char name[ADFS_MAX_NAME_LEN];/* file name */
  39. };
  40. struct adfs_dir_ops {
  41. int (*read)(struct super_block *sb, unsigned int id, unsigned int sz, struct adfs_dir *dir);
  42. int (*setpos)(struct adfs_dir *dir, unsigned int fpos);
  43. int (*getnext)(struct adfs_dir *dir, struct object_info *obj);
  44. int (*update)(struct adfs_dir *dir, struct object_info *obj);
  45. int (*create)(struct adfs_dir *dir, struct object_info *obj);
  46. int (*remove)(struct adfs_dir *dir, struct object_info *obj);
  47. void (*free)(struct adfs_dir *dir);
  48. };
  49. struct adfs_discmap {
  50. struct buffer_head *dm_bh;
  51. __u32 dm_startblk;
  52. unsigned int dm_startbit;
  53. unsigned int dm_endbit;
  54. };
  55. /* Inode stuff */
  56. struct inode *adfs_iget(struct super_block *sb, struct object_info *obj);
  57. int adfs_write_inode(struct inode *inode,int unused);
  58. int adfs_notify_change(struct dentry *dentry, struct iattr *attr);
  59. /* map.c */
  60. extern int adfs_map_lookup(struct super_block *sb, unsigned int frag_id, unsigned int offset);
  61. extern unsigned int adfs_map_free(struct super_block *sb);
  62. /* Misc */
  63. void __adfs_error(struct super_block *sb, const char *function,
  64. const char *fmt, ...);
  65. #define adfs_error(sb, fmt...) __adfs_error(sb, __FUNCTION__, fmt)
  66. /* super.c */
  67. /*
  68. * Inodes and file operations
  69. */
  70. /* dir_*.c */
  71. extern const struct inode_operations adfs_dir_inode_operations;
  72. extern const struct file_operations adfs_dir_operations;
  73. extern struct dentry_operations adfs_dentry_operations;
  74. extern struct adfs_dir_ops adfs_f_dir_ops;
  75. extern struct adfs_dir_ops adfs_fplus_dir_ops;
  76. extern int adfs_dir_update(struct super_block *sb, struct object_info *obj);
  77. /* file.c */
  78. extern const struct inode_operations adfs_file_inode_operations;
  79. extern const struct file_operations adfs_file_operations;
  80. static inline __u32 signed_asl(__u32 val, signed int shift)
  81. {
  82. if (shift >= 0)
  83. val <<= shift;
  84. else
  85. val >>= -shift;
  86. return val;
  87. }
  88. /*
  89. * Calculate the address of a block in an object given the block offset
  90. * and the object identity.
  91. *
  92. * The root directory ID should always be looked up in the map [3.4]
  93. */
  94. static inline int
  95. __adfs_block_map(struct super_block *sb, unsigned int object_id,
  96. unsigned int block)
  97. {
  98. if (object_id & 255) {
  99. unsigned int off;
  100. off = (object_id & 255) - 1;
  101. block += off << ADFS_SB(sb)->s_log2sharesize;
  102. }
  103. return adfs_map_lookup(sb, object_id >> 8, block);
  104. }