udfdecl.h 8.6 KB

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