Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __LINUX_UDF_SB_H
0003 #define __LINUX_UDF_SB_H
0004 
0005 #include <linux/mutex.h>
0006 #include <linux/bitops.h>
0007 #include <linux/magic.h>
0008 
0009 #define UDF_MAX_READ_VERSION        0x0250
0010 #define UDF_MAX_WRITE_VERSION       0x0201
0011 
0012 #define UDF_FLAG_USE_EXTENDED_FE    0
0013 #define UDF_VERS_USE_EXTENDED_FE    0x0200
0014 #define UDF_FLAG_USE_STREAMS        1
0015 #define UDF_VERS_USE_STREAMS        0x0200
0016 #define UDF_FLAG_USE_SHORT_AD       2
0017 #define UDF_FLAG_USE_AD_IN_ICB      3
0018 #define UDF_FLAG_USE_FILE_CTIME_EA  4
0019 #define UDF_FLAG_STRICT         5
0020 #define UDF_FLAG_UNDELETE       6
0021 #define UDF_FLAG_UNHIDE         7
0022 #define UDF_FLAG_VARCONV        8
0023 #define UDF_FLAG_UID_FORGET     11    /* save -1 for uid to disk */
0024 #define UDF_FLAG_GID_FORGET     12
0025 #define UDF_FLAG_UID_SET    13
0026 #define UDF_FLAG_GID_SET    14
0027 #define UDF_FLAG_SESSION_SET    15
0028 #define UDF_FLAG_LASTBLOCK_SET  16
0029 #define UDF_FLAG_BLOCKSIZE_SET  17
0030 #define UDF_FLAG_INCONSISTENT   18
0031 #define UDF_FLAG_RW_INCOMPAT    19  /* Set when we find RW incompatible
0032                      * feature */
0033 
0034 #define UDF_PART_FLAG_UNALLOC_BITMAP    0x0001
0035 #define UDF_PART_FLAG_UNALLOC_TABLE 0x0002
0036 #define UDF_PART_FLAG_READ_ONLY     0x0010
0037 #define UDF_PART_FLAG_WRITE_ONCE    0x0020
0038 #define UDF_PART_FLAG_REWRITABLE    0x0040
0039 #define UDF_PART_FLAG_OVERWRITABLE  0x0080
0040 
0041 #define UDF_MAX_BLOCK_LOADED    8
0042 
0043 #define UDF_TYPE1_MAP15         0x1511U
0044 #define UDF_VIRTUAL_MAP15       0x1512U
0045 #define UDF_VIRTUAL_MAP20       0x2012U
0046 #define UDF_SPARABLE_MAP15      0x1522U
0047 #define UDF_METADATA_MAP25      0x2511U
0048 
0049 #define UDF_INVALID_MODE        ((umode_t)-1)
0050 
0051 #define MF_DUPLICATE_MD     0x01
0052 #define MF_MIRROR_FE_LOADED 0x02
0053 
0054 struct udf_meta_data {
0055     __u32   s_meta_file_loc;
0056     __u32   s_mirror_file_loc;
0057     __u32   s_bitmap_file_loc;
0058     __u32   s_alloc_unit_size;
0059     __u16   s_align_unit_size;
0060     /*
0061      * Partition Reference Number of the associated physical / sparable
0062      * partition
0063      */
0064     __u16   s_phys_partition_ref;
0065     int s_flags;
0066     struct inode *s_metadata_fe;
0067     struct inode *s_mirror_fe;
0068     struct inode *s_bitmap_fe;
0069 };
0070 
0071 struct udf_sparing_data {
0072     __u16   s_packet_len;
0073     struct buffer_head *s_spar_map[4];
0074 };
0075 
0076 struct udf_virtual_data {
0077     __u32   s_num_entries;
0078     __u16   s_start_offset;
0079 };
0080 
0081 struct udf_bitmap {
0082     __u32           s_extPosition;
0083     int         s_nr_groups;
0084     struct buffer_head  *s_block_bitmap[];
0085 };
0086 
0087 struct udf_part_map {
0088     union {
0089         struct udf_bitmap   *s_bitmap;
0090         struct inode        *s_table;
0091     } s_uspace;
0092     __u32   s_partition_root;
0093     __u32   s_partition_len;
0094     __u16   s_partition_type;
0095     __u16   s_partition_num;
0096     union {
0097         struct udf_sparing_data s_sparing;
0098         struct udf_virtual_data s_virtual;
0099         struct udf_meta_data s_metadata;
0100     } s_type_specific;
0101     __u32   (*s_partition_func)(struct super_block *, __u32, __u16, __u32);
0102     __u16   s_volumeseqnum;
0103     __u16   s_partition_flags;
0104 };
0105 
0106 #pragma pack()
0107 
0108 struct udf_sb_info {
0109     struct udf_part_map *s_partmaps;
0110     __u8            s_volume_ident[32];
0111 
0112     /* Overall info */
0113     __u16           s_partitions;
0114     __u16           s_partition;
0115 
0116     /* Sector headers */
0117     __s32           s_session;
0118     __u32           s_anchor;
0119     __u32           s_last_block;
0120 
0121     struct buffer_head  *s_lvid_bh;
0122 
0123     /* Default permissions */
0124     umode_t         s_umask;
0125     kgid_t          s_gid;
0126     kuid_t          s_uid;
0127     umode_t         s_fmode;
0128     umode_t         s_dmode;
0129     /* Lock protecting consistency of above permission settings */
0130     rwlock_t        s_cred_lock;
0131 
0132     /* Root Info */
0133     struct timespec64   s_record_time;
0134 
0135     /* Fileset Info */
0136     __u16           s_serial_number;
0137 
0138     /* highest UDF revision we have recorded to this media */
0139     __u16           s_udfrev;
0140 
0141     /* Miscellaneous flags */
0142     unsigned long       s_flags;
0143 
0144     /* Encoding info */
0145     struct nls_table    *s_nls_map;
0146 
0147     /* VAT inode */
0148     struct inode        *s_vat_inode;
0149 
0150     struct mutex        s_alloc_mutex;
0151     /* Protected by s_alloc_mutex */
0152     unsigned int        s_lvid_dirty;
0153 };
0154 
0155 static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
0156 {
0157     return sb->s_fs_info;
0158 }
0159 
0160 struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct super_block *sb);
0161 
0162 int udf_compute_nr_groups(struct super_block *sb, u32 partition);
0163 
0164 static inline int UDF_QUERY_FLAG(struct super_block *sb, int flag)
0165 {
0166     return test_bit(flag, &UDF_SB(sb)->s_flags);
0167 }
0168 
0169 static inline void UDF_SET_FLAG(struct super_block *sb, int flag)
0170 {
0171     set_bit(flag, &UDF_SB(sb)->s_flags);
0172 }
0173 
0174 static inline void UDF_CLEAR_FLAG(struct super_block *sb, int flag)
0175 {
0176     clear_bit(flag, &UDF_SB(sb)->s_flags);
0177 }
0178 
0179 #endif /* __LINUX_UDF_SB_H */