11da177e4SLinus Torvalds #ifndef __UDF_DECL_H 21da177e4SLinus Torvalds #define __UDF_DECL_H 31da177e4SLinus Torvalds 41da177e4SLinus Torvalds #include "ecma_167.h" 51da177e4SLinus Torvalds #include "osta_udf.h" 61da177e4SLinus Torvalds 71da177e4SLinus Torvalds #include <linux/fs.h> 81da177e4SLinus Torvalds #include <linux/types.h> 91da177e4SLinus Torvalds #include <linux/buffer_head.h> 1015aebd28SChristoph Hellwig #include <linux/udf_fs_i.h> 111da177e4SLinus Torvalds 1215aebd28SChristoph Hellwig #include "udf_sb.h" 131da177e4SLinus Torvalds #include "udfend.h" 14d652eefbSmarcin.slusarz@gmail.com #include "udf_i.h" 151da177e4SLinus Torvalds 1615aebd28SChristoph Hellwig #define UDF_PREALLOCATE 1715aebd28SChristoph Hellwig #define UDF_DEFAULT_PREALLOC_BLOCKS 8 1815aebd28SChristoph Hellwig 19706047a7SSebastian Manciulea #define UDFFS_DEBUG 2015aebd28SChristoph Hellwig 2115aebd28SChristoph Hellwig #ifdef UDFFS_DEBUG 2215aebd28SChristoph Hellwig #define udf_debug(f, a...) \ 2315aebd28SChristoph Hellwig do { \ 2415aebd28SChristoph Hellwig printk(KERN_DEBUG "UDF-fs DEBUG %s:%d:%s: ", \ 2515aebd28SChristoph Hellwig __FILE__, __LINE__, __func__); \ 2615aebd28SChristoph Hellwig printk(f, ##a); \ 2715aebd28SChristoph Hellwig } while (0) 2815aebd28SChristoph Hellwig #else 2915aebd28SChristoph Hellwig #define udf_debug(f, a...) /**/ 3015aebd28SChristoph Hellwig #endif 3115aebd28SChristoph Hellwig 3215aebd28SChristoph Hellwig #define udf_info(f, a...) \ 3315aebd28SChristoph Hellwig printk(KERN_INFO "UDF-fs INFO " f, ##a); 3415aebd28SChristoph Hellwig 3515aebd28SChristoph Hellwig 361da177e4SLinus Torvalds #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) ) 371da177e4SLinus Torvalds #define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) ) 381da177e4SLinus Torvalds 391da177e4SLinus Torvalds #define UDF_EXTENT_LENGTH_MASK 0x3FFFFFFF 401da177e4SLinus Torvalds #define UDF_EXTENT_FLAG_MASK 0xC0000000 411da177e4SLinus Torvalds 421da177e4SLinus Torvalds #define UDF_NAME_PAD 4 431da177e4SLinus Torvalds #define UDF_NAME_LEN 256 441da177e4SLinus Torvalds #define UDF_PATH_LEN 1023 451da177e4SLinus Torvalds 46d652eefbSmarcin.slusarz@gmail.com static inline size_t udf_file_entry_alloc_offset(struct inode *inode) 47d652eefbSmarcin.slusarz@gmail.com { 48d652eefbSmarcin.slusarz@gmail.com struct udf_inode_info *iinfo = UDF_I(inode); 49d652eefbSmarcin.slusarz@gmail.com if (iinfo->i_use) 50d652eefbSmarcin.slusarz@gmail.com return sizeof(struct unallocSpaceEntry); 51d652eefbSmarcin.slusarz@gmail.com else if (iinfo->i_efe) 52d652eefbSmarcin.slusarz@gmail.com return sizeof(struct extendedFileEntry) + iinfo->i_lenEAttr; 53d652eefbSmarcin.slusarz@gmail.com else 54d652eefbSmarcin.slusarz@gmail.com return sizeof(struct fileEntry) + iinfo->i_lenEAttr; 55d652eefbSmarcin.slusarz@gmail.com } 561da177e4SLinus Torvalds 57d652eefbSmarcin.slusarz@gmail.com static inline size_t udf_ext0_offset(struct inode *inode) 58d652eefbSmarcin.slusarz@gmail.com { 59d652eefbSmarcin.slusarz@gmail.com if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) 60d652eefbSmarcin.slusarz@gmail.com return udf_file_entry_alloc_offset(inode); 61d652eefbSmarcin.slusarz@gmail.com else 62d652eefbSmarcin.slusarz@gmail.com return 0; 63d652eefbSmarcin.slusarz@gmail.com } 641da177e4SLinus Torvalds 651da177e4SLinus Torvalds #define udf_get_lb_pblock(sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset)) 661da177e4SLinus Torvalds 673f2587bbSMarcin Slusarz /* computes tag checksum */ 683f2587bbSMarcin Slusarz u8 udf_tag_checksum(const tag *t); 693f2587bbSMarcin Slusarz 701da177e4SLinus Torvalds struct dentry; 711da177e4SLinus Torvalds struct inode; 721da177e4SLinus Torvalds struct task_struct; 731da177e4SLinus Torvalds struct buffer_head; 741da177e4SLinus Torvalds struct super_block; 751da177e4SLinus Torvalds 76221e583aSRasmus Rohde extern const struct export_operations udf_export_ops; 77c5ef1c42SArjan van de Ven extern const struct inode_operations udf_dir_inode_operations; 784b6f5d20SArjan van de Ven extern const struct file_operations udf_dir_operations; 79c5ef1c42SArjan van de Ven extern const struct inode_operations udf_file_inode_operations; 804b6f5d20SArjan van de Ven extern const struct file_operations udf_file_operations; 81f5e54d6eSChristoph Hellwig extern const struct address_space_operations udf_aops; 82f5e54d6eSChristoph Hellwig extern const struct address_space_operations udf_adinicb_aops; 83f5e54d6eSChristoph Hellwig extern const struct address_space_operations udf_symlink_aops; 841da177e4SLinus Torvalds 85cb00ea35SCyrill Gorcunov struct udf_fileident_bh { 861da177e4SLinus Torvalds struct buffer_head *sbh; 871da177e4SLinus Torvalds struct buffer_head *ebh; 881da177e4SLinus Torvalds int soffset; 891da177e4SLinus Torvalds int eoffset; 901da177e4SLinus Torvalds }; 911da177e4SLinus Torvalds 92cb00ea35SCyrill Gorcunov struct udf_vds_record { 931da177e4SLinus Torvalds uint32_t block; 941da177e4SLinus Torvalds uint32_t volDescSeqNum; 951da177e4SLinus Torvalds }; 961da177e4SLinus Torvalds 97cb00ea35SCyrill Gorcunov struct generic_desc { 981da177e4SLinus Torvalds tag descTag; 991da177e4SLinus Torvalds __le32 volDescSeqNum; 1001da177e4SLinus Torvalds }; 1011da177e4SLinus Torvalds 102cb00ea35SCyrill Gorcunov struct ustr { 1031da177e4SLinus Torvalds uint8_t u_cmpID; 1041da177e4SLinus Torvalds uint8_t u_name[UDF_NAME_LEN - 2]; 1051da177e4SLinus Torvalds uint8_t u_len; 1061da177e4SLinus Torvalds }; 1071da177e4SLinus Torvalds 108ff116fc8SJan Kara struct extent_position { 109ff116fc8SJan Kara struct buffer_head *bh; 110ff116fc8SJan Kara uint32_t offset; 111ff116fc8SJan Kara kernel_lb_addr block; 112ff116fc8SJan Kara }; 113ff116fc8SJan Kara 1141da177e4SLinus Torvalds /* super.c */ 1151da177e4SLinus Torvalds extern void udf_warning(struct super_block *, const char *, const char *, ...); 1161da177e4SLinus Torvalds 1171da177e4SLinus Torvalds /* namei.c */ 118cb00ea35SCyrill Gorcunov extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *, 119cb00ea35SCyrill Gorcunov struct fileIdentDesc *, struct udf_fileident_bh *, 120cb00ea35SCyrill Gorcunov uint8_t *, uint8_t *); 1211da177e4SLinus Torvalds 1221da177e4SLinus Torvalds /* file.c */ 123cb00ea35SCyrill Gorcunov extern int udf_ioctl(struct inode *, struct file *, unsigned int, 124cb00ea35SCyrill Gorcunov unsigned long); 1251da177e4SLinus Torvalds 1261da177e4SLinus Torvalds /* inode.c */ 1271da177e4SLinus Torvalds extern struct inode *udf_iget(struct super_block *, kernel_lb_addr); 1281da177e4SLinus Torvalds extern int udf_sync_inode(struct inode *); 1291da177e4SLinus Torvalds extern void udf_expand_file_adinicb(struct inode *, int, int *); 1301da177e4SLinus Torvalds extern struct buffer_head *udf_expand_dir_adinicb(struct inode *, int *, int *); 1311da177e4SLinus Torvalds extern struct buffer_head *udf_bread(struct inode *, int, int, int *); 1321da177e4SLinus Torvalds extern void udf_truncate(struct inode *); 1331da177e4SLinus Torvalds extern void udf_read_inode(struct inode *); 1341da177e4SLinus Torvalds extern void udf_delete_inode(struct inode *); 1351da177e4SLinus Torvalds extern void udf_clear_inode(struct inode *); 1361da177e4SLinus Torvalds extern int udf_write_inode(struct inode *, int); 13760448b1dSJan Kara extern long udf_block_map(struct inode *, sector_t); 138cb00ea35SCyrill Gorcunov extern int udf_extend_file(struct inode *, struct extent_position *, 139cb00ea35SCyrill Gorcunov kernel_long_ad *, sector_t); 140cb00ea35SCyrill Gorcunov extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *, 141cb00ea35SCyrill Gorcunov kernel_lb_addr *, uint32_t *, sector_t *); 142cb00ea35SCyrill Gorcunov extern int8_t udf_add_aext(struct inode *, struct extent_position *, 143cb00ea35SCyrill Gorcunov kernel_lb_addr, uint32_t, int); 144cb00ea35SCyrill Gorcunov extern int8_t udf_write_aext(struct inode *, struct extent_position *, 145cb00ea35SCyrill Gorcunov kernel_lb_addr, uint32_t, int); 146cb00ea35SCyrill Gorcunov extern int8_t udf_delete_aext(struct inode *, struct extent_position, 147cb00ea35SCyrill Gorcunov kernel_lb_addr, uint32_t); 148cb00ea35SCyrill Gorcunov extern int8_t udf_next_aext(struct inode *, struct extent_position *, 149cb00ea35SCyrill Gorcunov kernel_lb_addr *, uint32_t *, int); 150cb00ea35SCyrill Gorcunov extern int8_t udf_current_aext(struct inode *, struct extent_position *, 151cb00ea35SCyrill Gorcunov kernel_lb_addr *, uint32_t *, int); 1521da177e4SLinus Torvalds 1531da177e4SLinus Torvalds /* misc.c */ 1541da177e4SLinus Torvalds extern struct buffer_head *udf_tgetblk(struct super_block *, int); 1551da177e4SLinus Torvalds extern struct buffer_head *udf_tread(struct super_block *, int); 156cb00ea35SCyrill Gorcunov extern struct genericFormat *udf_add_extendedattr(struct inode *, uint32_t, 157cb00ea35SCyrill Gorcunov uint32_t, uint8_t); 158cb00ea35SCyrill Gorcunov extern struct genericFormat *udf_get_extendedattr(struct inode *, uint32_t, 159cb00ea35SCyrill Gorcunov uint8_t); 160cb00ea35SCyrill Gorcunov extern struct buffer_head *udf_read_tagged(struct super_block *, uint32_t, 161cb00ea35SCyrill Gorcunov uint32_t, uint16_t *); 162cb00ea35SCyrill Gorcunov extern struct buffer_head *udf_read_ptagged(struct super_block *, 163cb00ea35SCyrill Gorcunov kernel_lb_addr, uint32_t, 164cb00ea35SCyrill Gorcunov uint16_t *); 1651da177e4SLinus Torvalds extern void udf_update_tag(char *, int); 1661da177e4SLinus Torvalds extern void udf_new_tag(char *, uint16_t, uint16_t, uint16_t, uint32_t, int); 1671da177e4SLinus Torvalds 1681da177e4SLinus Torvalds /* lowlevel.c */ 1691da177e4SLinus Torvalds extern unsigned int udf_get_last_session(struct super_block *); 1701da177e4SLinus Torvalds extern unsigned long udf_get_last_block(struct super_block *); 1711da177e4SLinus Torvalds 1721da177e4SLinus Torvalds /* partition.c */ 173cb00ea35SCyrill Gorcunov extern uint32_t udf_get_pblock(struct super_block *, uint32_t, uint16_t, 174cb00ea35SCyrill Gorcunov uint32_t); 175cb00ea35SCyrill Gorcunov extern uint32_t udf_get_pblock_virt15(struct super_block *, uint32_t, uint16_t, 176cb00ea35SCyrill Gorcunov uint32_t); 177cb00ea35SCyrill Gorcunov extern uint32_t udf_get_pblock_virt20(struct super_block *, uint32_t, uint16_t, 178cb00ea35SCyrill Gorcunov uint32_t); 179cb00ea35SCyrill Gorcunov extern uint32_t udf_get_pblock_spar15(struct super_block *, uint32_t, uint16_t, 180cb00ea35SCyrill Gorcunov uint32_t); 181bfb257a5SJan Kara extern uint32_t udf_get_pblock_meta25(struct super_block *, uint32_t, uint16_t, 182bfb257a5SJan Kara uint32_t); 1831da177e4SLinus Torvalds extern int udf_relocate_blocks(struct super_block *, long, long *); 1841da177e4SLinus Torvalds 1851da177e4SLinus Torvalds /* unicode.c */ 1861da177e4SLinus Torvalds extern int udf_get_filename(struct super_block *, uint8_t *, uint8_t *, int); 187cb00ea35SCyrill Gorcunov extern int udf_put_filename(struct super_block *, const uint8_t *, uint8_t *, 188cb00ea35SCyrill Gorcunov int); 1891da177e4SLinus Torvalds extern int udf_build_ustr(struct ustr *, dstring *, int); 19079cfe0ffSmarcin.slusarz@gmail.com extern int udf_CS0toUTF8(struct ustr *, const struct ustr *); 1911da177e4SLinus Torvalds 1921da177e4SLinus Torvalds /* ialloc.c */ 1931da177e4SLinus Torvalds extern void udf_free_inode(struct inode *); 1941da177e4SLinus Torvalds extern struct inode *udf_new_inode(struct inode *, int, int *); 1951da177e4SLinus Torvalds 1961da177e4SLinus Torvalds /* truncate.c */ 19774584ae5SJan Kara extern void udf_truncate_tail_extent(struct inode *); 1981da177e4SLinus Torvalds extern void udf_discard_prealloc(struct inode *); 1991da177e4SLinus Torvalds extern void udf_truncate_extents(struct inode *); 2001da177e4SLinus Torvalds 2011da177e4SLinus Torvalds /* balloc.c */ 202cb00ea35SCyrill Gorcunov extern void udf_free_blocks(struct super_block *, struct inode *, 203cb00ea35SCyrill Gorcunov kernel_lb_addr, uint32_t, uint32_t); 204cb00ea35SCyrill Gorcunov extern int udf_prealloc_blocks(struct super_block *, struct inode *, uint16_t, 205cb00ea35SCyrill Gorcunov uint32_t, uint32_t); 206cb00ea35SCyrill Gorcunov extern int udf_new_block(struct super_block *, struct inode *, uint16_t, 207cb00ea35SCyrill Gorcunov uint32_t, int *); 2081da177e4SLinus Torvalds 2091da177e4SLinus Torvalds /* fsync.c */ 2101da177e4SLinus Torvalds extern int udf_fsync_file(struct file *, struct dentry *, int); 2111da177e4SLinus Torvalds 2121da177e4SLinus Torvalds /* directory.c */ 213cb00ea35SCyrill Gorcunov extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *, 214cb00ea35SCyrill Gorcunov struct udf_fileident_bh *, 215cb00ea35SCyrill Gorcunov struct fileIdentDesc *, 216cb00ea35SCyrill Gorcunov struct extent_position *, 217cb00ea35SCyrill Gorcunov kernel_lb_addr *, uint32_t *, 218cb00ea35SCyrill Gorcunov sector_t *); 219cb00ea35SCyrill Gorcunov extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, 220cb00ea35SCyrill Gorcunov int *offset); 2211ed16171SMarcin Slusarz extern long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int); 2221ed16171SMarcin Slusarz extern short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int); 2231da177e4SLinus Torvalds 2241da177e4SLinus Torvalds /* udftime.c */ 22556774805SMarcin Slusarz extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest, 22656774805SMarcin Slusarz timestamp src); 22756774805SMarcin Slusarz extern timestamp *udf_time_to_disk_stamp(timestamp *dest, struct timespec src); 2281da177e4SLinus Torvalds 2291da177e4SLinus Torvalds #endif /* __UDF_DECL_H */ 230