udfdecl.h 8.1 KB

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