adfs.h 3.3 KB

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