Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __UDF_DECL_H
0003 #define __UDF_DECL_H
0004 
0005 #define pr_fmt(fmt) "UDF-fs: " fmt
0006 
0007 #include "ecma_167.h"
0008 #include "osta_udf.h"
0009 
0010 #include <linux/fs.h>
0011 #include <linux/types.h>
0012 #include <linux/buffer_head.h>
0013 #include <linux/udf_fs_i.h>
0014 
0015 #include "udf_sb.h"
0016 #include "udfend.h"
0017 #include "udf_i.h"
0018 
0019 #define UDF_DEFAULT_PREALLOC_BLOCKS 8
0020 
0021 extern __printf(3, 4) void _udf_err(struct super_block *sb,
0022         const char *function, const char *fmt, ...);
0023 #define udf_err(sb, fmt, ...)                   \
0024     _udf_err(sb, __func__, fmt, ##__VA_ARGS__)
0025 
0026 extern __printf(3, 4) void _udf_warn(struct super_block *sb,
0027         const char *function, const char *fmt, ...);
0028 #define udf_warn(sb, fmt, ...)                  \
0029     _udf_warn(sb, __func__, fmt, ##__VA_ARGS__)
0030 
0031 #define udf_info(fmt, ...)                  \
0032     pr_info("INFO " fmt, ##__VA_ARGS__)
0033 
0034 #define udf_debug(fmt, ...)                 \
0035     pr_debug("%s:%d:%s: " fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__)
0036 
0037 #define udf_fixed_to_variable(x) ( ( ( (x) >> 5 ) * 39 ) + ( (x) & 0x0000001F ) )
0038 #define udf_variable_to_fixed(x) ( ( ( (x) / 39 ) << 5 ) + ( (x) % 39 ) )
0039 
0040 #define UDF_EXTENT_LENGTH_MASK  0x3FFFFFFF
0041 #define UDF_EXTENT_FLAG_MASK    0xC0000000
0042 
0043 #define UDF_INVALID_ID ((uint32_t)-1)
0044 
0045 #define UDF_NAME_PAD        4
0046 #define UDF_NAME_LEN        254
0047 #define UDF_NAME_LEN_CS0    255
0048 
0049 static inline size_t udf_file_entry_alloc_offset(struct inode *inode)
0050 {
0051     struct udf_inode_info *iinfo = UDF_I(inode);
0052     if (iinfo->i_use)
0053         return sizeof(struct unallocSpaceEntry);
0054     else if (iinfo->i_efe)
0055         return sizeof(struct extendedFileEntry) + iinfo->i_lenEAttr;
0056     else
0057         return sizeof(struct fileEntry) + iinfo->i_lenEAttr;
0058 }
0059 
0060 static inline size_t udf_ext0_offset(struct inode *inode)
0061 {
0062     if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB)
0063         return udf_file_entry_alloc_offset(inode);
0064     else
0065         return 0;
0066 }
0067 
0068 /* computes tag checksum */
0069 u8 udf_tag_checksum(const struct tag *t);
0070 
0071 typedef uint32_t udf_pblk_t;
0072 
0073 struct dentry;
0074 struct inode;
0075 struct task_struct;
0076 struct buffer_head;
0077 struct super_block;
0078 
0079 extern const struct export_operations udf_export_ops;
0080 extern const struct inode_operations udf_dir_inode_operations;
0081 extern const struct file_operations udf_dir_operations;
0082 extern const struct inode_operations udf_file_inode_operations;
0083 extern const struct file_operations udf_file_operations;
0084 extern const struct inode_operations udf_symlink_inode_operations;
0085 extern const struct address_space_operations udf_aops;
0086 extern const struct address_space_operations udf_adinicb_aops;
0087 extern const struct address_space_operations udf_symlink_aops;
0088 
0089 struct udf_fileident_bh {
0090     struct buffer_head *sbh;
0091     struct buffer_head *ebh;
0092     int soffset;
0093     int eoffset;
0094 };
0095 
0096 struct udf_vds_record {
0097     uint32_t block;
0098     uint32_t volDescSeqNum;
0099 };
0100 
0101 struct generic_desc {
0102     struct tag  descTag;
0103     __le32      volDescSeqNum;
0104 };
0105 
0106 
0107 /* super.c */
0108 
0109 static inline void udf_updated_lvid(struct super_block *sb)
0110 {
0111     struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh;
0112 
0113     BUG_ON(!bh);
0114     WARN_ON_ONCE(((struct logicalVolIntegrityDesc *)
0115              bh->b_data)->integrityType !=
0116              cpu_to_le32(LVID_INTEGRITY_TYPE_OPEN));
0117     UDF_SB(sb)->s_lvid_dirty = 1;
0118 }
0119 extern u64 lvid_get_unique_id(struct super_block *sb);
0120 struct inode *udf_find_metadata_inode_efe(struct super_block *sb,
0121                     u32 meta_file_loc, u32 partition_num);
0122 
0123 /* namei.c */
0124 extern int udf_write_fi(struct inode *inode, struct fileIdentDesc *,
0125             struct fileIdentDesc *, struct udf_fileident_bh *,
0126             uint8_t *, uint8_t *);
0127 static inline unsigned int udf_dir_entry_len(struct fileIdentDesc *cfi)
0128 {
0129     return ALIGN(sizeof(struct fileIdentDesc) +
0130         le16_to_cpu(cfi->lengthOfImpUse) + cfi->lengthFileIdent,
0131         UDF_NAME_PAD);
0132 }
0133 static inline uint8_t *udf_get_fi_ident(struct fileIdentDesc *fi)
0134 {
0135     return ((uint8_t *)(fi + 1)) + le16_to_cpu(fi->lengthOfImpUse);
0136 }
0137 
0138 /* file.c */
0139 extern long udf_ioctl(struct file *, unsigned int, unsigned long);
0140 /* inode.c */
0141 extern struct inode *__udf_iget(struct super_block *, struct kernel_lb_addr *,
0142                 bool hidden_inode);
0143 static inline struct inode *udf_iget_special(struct super_block *sb,
0144                          struct kernel_lb_addr *ino)
0145 {
0146     return __udf_iget(sb, ino, true);
0147 }
0148 static inline struct inode *udf_iget(struct super_block *sb,
0149                      struct kernel_lb_addr *ino)
0150 {
0151     return __udf_iget(sb, ino, false);
0152 }
0153 extern int udf_expand_file_adinicb(struct inode *);
0154 extern struct buffer_head *udf_expand_dir_adinicb(struct inode *inode,
0155                           udf_pblk_t *block, int *err);
0156 extern struct buffer_head *udf_bread(struct inode *inode, udf_pblk_t block,
0157                       int create, int *err);
0158 extern int udf_setsize(struct inode *, loff_t);
0159 extern void udf_evict_inode(struct inode *);
0160 extern int udf_write_inode(struct inode *, struct writeback_control *wbc);
0161 extern udf_pblk_t udf_block_map(struct inode *inode, sector_t block);
0162 extern int8_t inode_bmap(struct inode *, sector_t, struct extent_position *,
0163              struct kernel_lb_addr *, uint32_t *, sector_t *);
0164 extern int udf_setup_indirect_aext(struct inode *inode, udf_pblk_t block,
0165                    struct extent_position *epos);
0166 extern int __udf_add_aext(struct inode *inode, struct extent_position *epos,
0167               struct kernel_lb_addr *eloc, uint32_t elen, int inc);
0168 extern int udf_add_aext(struct inode *, struct extent_position *,
0169             struct kernel_lb_addr *, uint32_t, int);
0170 extern void udf_write_aext(struct inode *, struct extent_position *,
0171                struct kernel_lb_addr *, uint32_t, int);
0172 extern int8_t udf_delete_aext(struct inode *, struct extent_position);
0173 extern int8_t udf_next_aext(struct inode *, struct extent_position *,
0174                 struct kernel_lb_addr *, uint32_t *, int);
0175 extern int8_t udf_current_aext(struct inode *, struct extent_position *,
0176                    struct kernel_lb_addr *, uint32_t *, int);
0177 extern void udf_update_extra_perms(struct inode *inode, umode_t mode);
0178 
0179 /* misc.c */
0180 extern struct buffer_head *udf_tgetblk(struct super_block *sb,
0181                     udf_pblk_t block);
0182 extern struct buffer_head *udf_tread(struct super_block *sb, udf_pblk_t block);
0183 extern struct genericFormat *udf_add_extendedattr(struct inode *, uint32_t,
0184                           uint32_t, uint8_t);
0185 extern struct genericFormat *udf_get_extendedattr(struct inode *, uint32_t,
0186                           uint8_t);
0187 extern struct buffer_head *udf_read_tagged(struct super_block *, uint32_t,
0188                        uint32_t, uint16_t *);
0189 extern struct buffer_head *udf_read_ptagged(struct super_block *,
0190                         struct kernel_lb_addr *, uint32_t,
0191                         uint16_t *);
0192 extern void udf_update_tag(char *, int);
0193 extern void udf_new_tag(char *, uint16_t, uint16_t, uint16_t, uint32_t, int);
0194 
0195 /* lowlevel.c */
0196 extern unsigned int udf_get_last_session(struct super_block *);
0197 extern unsigned long udf_get_last_block(struct super_block *);
0198 
0199 /* partition.c */
0200 extern uint32_t udf_get_pblock(struct super_block *, uint32_t, uint16_t,
0201                    uint32_t);
0202 extern uint32_t udf_get_pblock_virt15(struct super_block *, uint32_t, uint16_t,
0203                       uint32_t);
0204 extern uint32_t udf_get_pblock_virt20(struct super_block *, uint32_t, uint16_t,
0205                       uint32_t);
0206 extern uint32_t udf_get_pblock_spar15(struct super_block *, uint32_t, uint16_t,
0207                       uint32_t);
0208 extern uint32_t udf_get_pblock_meta25(struct super_block *, uint32_t, uint16_t,
0209                       uint32_t);
0210 extern int udf_relocate_blocks(struct super_block *, long, long *);
0211 
0212 static inline uint32_t
0213 udf_get_lb_pblock(struct super_block *sb, struct kernel_lb_addr *loc,
0214           uint32_t offset)
0215 {
0216     return udf_get_pblock(sb, loc->logicalBlockNum,
0217             loc->partitionReferenceNum, offset);
0218 }
0219 
0220 /* unicode.c */
0221 extern int udf_get_filename(struct super_block *, const uint8_t *, int,
0222                 uint8_t *, int);
0223 extern int udf_put_filename(struct super_block *, const uint8_t *, int,
0224                 uint8_t *, int);
0225 extern int udf_dstrCS0toChar(struct super_block *, uint8_t *, int,
0226                  const uint8_t *, int);
0227 
0228 /* ialloc.c */
0229 extern void udf_free_inode(struct inode *);
0230 extern struct inode *udf_new_inode(struct inode *, umode_t);
0231 
0232 /* truncate.c */
0233 extern void udf_truncate_tail_extent(struct inode *);
0234 extern void udf_discard_prealloc(struct inode *);
0235 extern int udf_truncate_extents(struct inode *);
0236 
0237 /* balloc.c */
0238 extern void udf_free_blocks(struct super_block *, struct inode *,
0239                 struct kernel_lb_addr *, uint32_t, uint32_t);
0240 extern int udf_prealloc_blocks(struct super_block *, struct inode *, uint16_t,
0241                    uint32_t, uint32_t);
0242 extern udf_pblk_t udf_new_block(struct super_block *sb, struct inode *inode,
0243                  uint16_t partition, uint32_t goal, int *err);
0244 
0245 /* directory.c */
0246 extern struct fileIdentDesc *udf_fileident_read(struct inode *, loff_t *,
0247                         struct udf_fileident_bh *,
0248                         struct fileIdentDesc *,
0249                         struct extent_position *,
0250                         struct kernel_lb_addr *, uint32_t *,
0251                         sector_t *);
0252 extern struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize,
0253                            int *offset);
0254 extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int);
0255 extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
0256 
0257 /* udftime.c */
0258 extern void udf_disk_stamp_to_time(struct timespec64 *dest,
0259                         struct timestamp src);
0260 extern void udf_time_to_disk_stamp(struct timestamp *dest, struct timespec64 src);
0261 
0262 #endif              /* __UDF_DECL_H */