udfdecl.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. #ifndef __UDF_DECL_H
  2. #define __UDF_DECL_H
  3. #include "ecma_167.h"
  4. #include "osta_udf.h"
  5. #include <linux/fs.h>
  6. #include <linux/types.h>
  7. #include <linux/buffer_head.h>
  8. #include <linux/udf_fs_i.h>
  9. #include "udf_sb.h"
  10. #include "udfend.h"
  11. #include "udf_i.h"
  12. #define UDF_PREALLOCATE
  13. #define UDF_DEFAULT_PREALLOC_BLOCKS 8
  14. #undef UDFFS_DEBUG
  15. #ifdef UDFFS_DEBUG
  16. #define udf_debug(f, a...) \
  17. do { \
  18. printk(KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \
  19. __FILE__, __LINE__, __func__); \
  20. printk(f, ##a); \
  21. } while (0)
  22. #else
  23. #define udf_debug(f, a...) /**/
  24. #endif
  25. #define udf_info(f, a...) \
  26. printk(KERN_INFO "UDF-fs INFO " f, ##a);
  27. #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) )
  28. #define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) )
  29. #define UDF_EXTENT_LENGTH_MASK 0x3FFFFFFF
  30. #define UDF_EXTENT_FLAG_MASK 0xC0000000
  31. #define UDF_NAME_PAD 4
  32. #define UDF_NAME_LEN 256
  33. #define UDF_PATH_LEN 1023
  34. static inline size_t udf_file_entry_alloc_offset(struct inode *inode)
  35. {
  36. struct udf_inode_info *iinfo = UDF_I(inode);
  37. if (iinfo->i_use)
  38. return sizeof(struct unallocSpaceEntry);
  39. else if (iinfo->i_efe)
  40. return sizeof(struct extendedFileEntry) + iinfo->i_lenEAttr;
  41. else
  42. return sizeof(struct fileEntry) + iinfo->i_lenEAttr;
  43. }
  44. static inline size_t udf_ext0_offset(struct inode *inode)
  45. {
  46. if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB)
  47. return udf_file_entry_alloc_offset(inode);
  48. else
  49. return 0;
  50. }
  51. /* computes tag checksum */
  52. u8 udf_tag_checksum(const struct tag *t);
  53. struct dentry;
  54. struct inode;
  55. struct task_struct;
  56. struct buffer_head;
  57. struct super_block;
  58. extern const struct export_operations udf_export_ops;
  59. extern const struct inode_operations udf_dir_inode_operations;
  60. extern const struct file_operations udf_dir_operations;
  61. extern const struct inode_operations udf_file_inode_operations;
  62. extern const struct file_operations udf_file_operations;
  63. extern const struct inode_operations udf_symlink_inode_operations;
  64. extern const struct address_space_operations udf_aops;
  65. extern const struct address_space_operations udf_adinicb_aops;
  66. extern const struct address_space_operations udf_symlink_aops;
  67. struct udf_fileident_bh {
  68. struct buffer_head *sbh;
  69. struct buffer_head *ebh;
  70. int soffset;
  71. int eoffset;
  72. };
  73. struct udf_vds_record {
  74. uint32_t block;
  75. uint32_t volDescSeqNum;
  76. };
  77. struct generic_desc {
  78. struct tag descTag;
  79. __le32 volDescSeqNum;
  80. };
  81. struct ustr {
  82. uint8_t u_cmpID;
  83. uint8_t u_name[UDF_NAME_LEN - 2];
  84. uint8_t u_len;
  85. };
  86. struct extent_position {
  87. struct buffer_head *bh;
  88. uint32_t offset;
  89. struct kernel_lb_addr block;
  90. };
  91. /* super.c */
  92. extern void udf_warning(struct super_block *, const char *, const char *, ...);
  93. static inline void udf_updated_lvid(struct super_block *sb)
  94. {
  95. struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh;
  96. BUG_ON(!bh);
  97. WARN_ON_ONCE(((struct logicalVolIntegrityDesc *)
  98. bh->b_data)->integrityType !=
  99. cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN));
  100. sb->s_dirt = 1;
  101. UDF_SB(sb)->s_lvid_dirty = 1;
  102. }
  103. /* namei.c */
  104. extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *,
  105. struct fileIdentDesc *, struct udf_fileident_bh *,
  106. uint8_t *, uint8_t *);
  107. /* file.c */
  108. extern long udf_ioctl(struct file *, unsigned int, unsigned long);
  109. /* inode.c */
  110. extern struct inode *udf_iget(struct super_block *, struct kernel_lb_addr *);
  111. extern int udf_sync_inode(struct inode *);
  112. extern void udf_expand_file_adinicb(struct inode *, int, int *);
  113. extern struct buffer_head *udf_expand_dir_adinicb(struct inode *, int *, int *);
  114. extern struct buffer_head *udf_bread(struct inode *, int, int, int *);
  115. extern void udf_truncate(struct inode *);
  116. extern void udf_read_inode(struct inode *);
  117. extern void udf_evict_inode(struct inode *);
  118. extern int udf_write_inode(struct inode *, struct writeback_control *wbc);
  119. extern long udf_block_map(struct inode *, sector_t);
  120. extern int udf_extend_file(struct inode *, struct extent_position *,
  121. struct kernel_long_ad *, sector_t);
  122. extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *,
  123. struct kernel_lb_addr *, uint32_t *, sector_t *);
  124. extern int8_t udf_add_aext(struct inode *, struct extent_position *,
  125. struct kernel_lb_addr *, uint32_t, int);
  126. extern int8_t udf_write_aext(struct inode *, struct extent_position *,
  127. struct kernel_lb_addr *, uint32_t, int);
  128. extern int8_t udf_delete_aext(struct inode *, struct extent_position,
  129. struct kernel_lb_addr, uint32_t);
  130. extern int8_t udf_next_aext(struct inode *, struct extent_position *,
  131. struct kernel_lb_addr *, uint32_t *, int);
  132. extern int8_t udf_current_aext(struct inode *, struct extent_position *,
  133. struct kernel_lb_addr *, uint32_t *, int);
  134. /* misc.c */
  135. extern struct buffer_head *udf_tgetblk(struct super_block *, int);
  136. extern struct buffer_head *udf_tread(struct super_block *, int);
  137. extern struct genericFormat *udf_add_extendedattr(struct inode *, uint32_t,
  138. uint32_t, uint8_t);
  139. extern struct genericFormat *udf_get_extendedattr(struct inode *, uint32_t,
  140. uint8_t);
  141. extern struct buffer_head *udf_read_tagged(struct super_block *, uint32_t,
  142. uint32_t, uint16_t *);
  143. extern struct buffer_head *udf_read_ptagged(struct super_block *,
  144. struct kernel_lb_addr *, uint32_t,
  145. uint16_t *);
  146. extern void udf_update_tag(char *, int);
  147. extern void udf_new_tag(char *, uint16_t, uint16_t, uint16_t, uint32_t, int);
  148. /* lowlevel.c */
  149. extern unsigned int udf_get_last_session(struct super_block *);
  150. extern unsigned long udf_get_last_block(struct super_block *);
  151. /* partition.c */
  152. extern uint32_t udf_get_pblock(struct super_block *, uint32_t, uint16_t,
  153. uint32_t);
  154. extern uint32_t udf_get_pblock_virt15(struct super_block *, uint32_t, uint16_t,
  155. uint32_t);
  156. extern uint32_t udf_get_pblock_virt20(struct super_block *, uint32_t, uint16_t,
  157. uint32_t);
  158. extern uint32_t udf_get_pblock_spar15(struct super_block *, uint32_t, uint16_t,
  159. uint32_t);
  160. extern uint32_t udf_get_pblock_meta25(struct super_block *, uint32_t, uint16_t,
  161. uint32_t);
  162. extern int udf_relocate_blocks(struct super_block *, long, long *);
  163. static inline uint32_t
  164. udf_get_lb_pblock(struct super_block *sb, struct kernel_lb_addr *loc,
  165. uint32_t offset)
  166. {
  167. return udf_get_pblock(sb, loc->logicalBlockNum,
  168. loc->partitionReferenceNum, offset);
  169. }
  170. /* unicode.c */
  171. extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int);
  172. extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *,
  173. int);
  174. extern int udf_build_ustr(struct ustr *, dstring *, int);
  175. extern int udf_CS0toUTF8(struct ustr *, const struct ustr *);
  176. /* ialloc.c */
  177. extern void udf_free_inode(struct inode *);
  178. extern struct inode *udf_new_inode(struct inode *, int, int *);
  179. /* truncate.c */
  180. extern void udf_truncate_tail_extent(struct inode *);
  181. extern void udf_discard_prealloc(struct inode *);
  182. extern void udf_truncate_extents(struct inode *);
  183. /* balloc.c */
  184. extern void udf_free_blocks(struct super_block *, struct inode *,
  185. struct kernel_lb_addr *, uint32_t, uint32_t);
  186. extern int udf_prealloc_blocks(struct super_block *, struct inode *, uint16_t,
  187. uint32_t, uint32_t);
  188. extern int udf_new_block(struct super_block *, struct inode *, uint16_t,
  189. uint32_t, int *);
  190. /* directory.c */
  191. extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *,
  192. struct udf_fileident_bh *,
  193. struct fileIdentDesc *,
  194. struct extent_position *,
  195. struct kernel_lb_addr *, uint32_t *,
  196. sector_t *);
  197. extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize,
  198. int *offset);
  199. extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int);
  200. extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
  201. /* udftime.c */
  202. extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest,
  203. struct timestamp src);
  204. extern struct timestamp *udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
  205. #endif /* __UDF_DECL_H */