18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __LINUX_UDF_SB_H 38c2ecf20Sopenharmony_ci#define __LINUX_UDF_SB_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/mutex.h> 68c2ecf20Sopenharmony_ci#include <linux/bitops.h> 78c2ecf20Sopenharmony_ci#include <linux/magic.h> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#define UDF_MAX_READ_VERSION 0x0250 108c2ecf20Sopenharmony_ci#define UDF_MAX_WRITE_VERSION 0x0201 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#define UDF_FLAG_USE_EXTENDED_FE 0 138c2ecf20Sopenharmony_ci#define UDF_VERS_USE_EXTENDED_FE 0x0200 148c2ecf20Sopenharmony_ci#define UDF_FLAG_USE_STREAMS 1 158c2ecf20Sopenharmony_ci#define UDF_VERS_USE_STREAMS 0x0200 168c2ecf20Sopenharmony_ci#define UDF_FLAG_USE_SHORT_AD 2 178c2ecf20Sopenharmony_ci#define UDF_FLAG_USE_AD_IN_ICB 3 188c2ecf20Sopenharmony_ci#define UDF_FLAG_USE_FILE_CTIME_EA 4 198c2ecf20Sopenharmony_ci#define UDF_FLAG_STRICT 5 208c2ecf20Sopenharmony_ci#define UDF_FLAG_UNDELETE 6 218c2ecf20Sopenharmony_ci#define UDF_FLAG_UNHIDE 7 228c2ecf20Sopenharmony_ci#define UDF_FLAG_VARCONV 8 238c2ecf20Sopenharmony_ci#define UDF_FLAG_UID_FORGET 11 /* save -1 for uid to disk */ 248c2ecf20Sopenharmony_ci#define UDF_FLAG_GID_FORGET 12 258c2ecf20Sopenharmony_ci#define UDF_FLAG_UID_SET 13 268c2ecf20Sopenharmony_ci#define UDF_FLAG_GID_SET 14 278c2ecf20Sopenharmony_ci#define UDF_FLAG_SESSION_SET 15 288c2ecf20Sopenharmony_ci#define UDF_FLAG_LASTBLOCK_SET 16 298c2ecf20Sopenharmony_ci#define UDF_FLAG_BLOCKSIZE_SET 17 308c2ecf20Sopenharmony_ci#define UDF_FLAG_INCONSISTENT 18 318c2ecf20Sopenharmony_ci#define UDF_FLAG_RW_INCOMPAT 19 /* Set when we find RW incompatible 328c2ecf20Sopenharmony_ci * feature */ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define UDF_PART_FLAG_UNALLOC_BITMAP 0x0001 358c2ecf20Sopenharmony_ci#define UDF_PART_FLAG_UNALLOC_TABLE 0x0002 368c2ecf20Sopenharmony_ci#define UDF_PART_FLAG_READ_ONLY 0x0010 378c2ecf20Sopenharmony_ci#define UDF_PART_FLAG_WRITE_ONCE 0x0020 388c2ecf20Sopenharmony_ci#define UDF_PART_FLAG_REWRITABLE 0x0040 398c2ecf20Sopenharmony_ci#define UDF_PART_FLAG_OVERWRITABLE 0x0080 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define UDF_MAX_BLOCK_LOADED 8 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define UDF_TYPE1_MAP15 0x1511U 448c2ecf20Sopenharmony_ci#define UDF_VIRTUAL_MAP15 0x1512U 458c2ecf20Sopenharmony_ci#define UDF_VIRTUAL_MAP20 0x2012U 468c2ecf20Sopenharmony_ci#define UDF_SPARABLE_MAP15 0x1522U 478c2ecf20Sopenharmony_ci#define UDF_METADATA_MAP25 0x2511U 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#define UDF_INVALID_MODE ((umode_t)-1) 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#define MF_DUPLICATE_MD 0x01 528c2ecf20Sopenharmony_ci#define MF_MIRROR_FE_LOADED 0x02 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define EFSCORRUPTED EUCLEAN 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistruct udf_meta_data { 578c2ecf20Sopenharmony_ci __u32 s_meta_file_loc; 588c2ecf20Sopenharmony_ci __u32 s_mirror_file_loc; 598c2ecf20Sopenharmony_ci __u32 s_bitmap_file_loc; 608c2ecf20Sopenharmony_ci __u32 s_alloc_unit_size; 618c2ecf20Sopenharmony_ci __u16 s_align_unit_size; 628c2ecf20Sopenharmony_ci /* 638c2ecf20Sopenharmony_ci * Partition Reference Number of the associated physical / sparable 648c2ecf20Sopenharmony_ci * partition 658c2ecf20Sopenharmony_ci */ 668c2ecf20Sopenharmony_ci __u16 s_phys_partition_ref; 678c2ecf20Sopenharmony_ci int s_flags; 688c2ecf20Sopenharmony_ci struct inode *s_metadata_fe; 698c2ecf20Sopenharmony_ci struct inode *s_mirror_fe; 708c2ecf20Sopenharmony_ci struct inode *s_bitmap_fe; 718c2ecf20Sopenharmony_ci}; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cistruct udf_sparing_data { 748c2ecf20Sopenharmony_ci __u16 s_packet_len; 758c2ecf20Sopenharmony_ci struct buffer_head *s_spar_map[4]; 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistruct udf_virtual_data { 798c2ecf20Sopenharmony_ci __u32 s_num_entries; 808c2ecf20Sopenharmony_ci __u16 s_start_offset; 818c2ecf20Sopenharmony_ci}; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cistruct udf_bitmap { 848c2ecf20Sopenharmony_ci __u32 s_extPosition; 858c2ecf20Sopenharmony_ci int s_nr_groups; 868c2ecf20Sopenharmony_ci struct buffer_head *s_block_bitmap[]; 878c2ecf20Sopenharmony_ci}; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_cistruct udf_part_map { 908c2ecf20Sopenharmony_ci union { 918c2ecf20Sopenharmony_ci struct udf_bitmap *s_bitmap; 928c2ecf20Sopenharmony_ci struct inode *s_table; 938c2ecf20Sopenharmony_ci } s_uspace; 948c2ecf20Sopenharmony_ci __u32 s_partition_root; 958c2ecf20Sopenharmony_ci __u32 s_partition_len; 968c2ecf20Sopenharmony_ci __u16 s_partition_type; 978c2ecf20Sopenharmony_ci __u16 s_partition_num; 988c2ecf20Sopenharmony_ci union { 998c2ecf20Sopenharmony_ci struct udf_sparing_data s_sparing; 1008c2ecf20Sopenharmony_ci struct udf_virtual_data s_virtual; 1018c2ecf20Sopenharmony_ci struct udf_meta_data s_metadata; 1028c2ecf20Sopenharmony_ci } s_type_specific; 1038c2ecf20Sopenharmony_ci __u32 (*s_partition_func)(struct super_block *, __u32, __u16, __u32); 1048c2ecf20Sopenharmony_ci __u16 s_volumeseqnum; 1058c2ecf20Sopenharmony_ci __u16 s_partition_flags; 1068c2ecf20Sopenharmony_ci}; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#pragma pack() 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_cistruct udf_sb_info { 1118c2ecf20Sopenharmony_ci struct udf_part_map *s_partmaps; 1128c2ecf20Sopenharmony_ci __u8 s_volume_ident[32]; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci /* Overall info */ 1158c2ecf20Sopenharmony_ci __u16 s_partitions; 1168c2ecf20Sopenharmony_ci __u16 s_partition; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci /* Sector headers */ 1198c2ecf20Sopenharmony_ci __s32 s_session; 1208c2ecf20Sopenharmony_ci __u32 s_anchor; 1218c2ecf20Sopenharmony_ci __u32 s_last_block; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci struct buffer_head *s_lvid_bh; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci /* Default permissions */ 1268c2ecf20Sopenharmony_ci umode_t s_umask; 1278c2ecf20Sopenharmony_ci kgid_t s_gid; 1288c2ecf20Sopenharmony_ci kuid_t s_uid; 1298c2ecf20Sopenharmony_ci umode_t s_fmode; 1308c2ecf20Sopenharmony_ci umode_t s_dmode; 1318c2ecf20Sopenharmony_ci /* Lock protecting consistency of above permission settings */ 1328c2ecf20Sopenharmony_ci rwlock_t s_cred_lock; 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci /* Root Info */ 1358c2ecf20Sopenharmony_ci struct timespec64 s_record_time; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci /* Fileset Info */ 1388c2ecf20Sopenharmony_ci __u16 s_serial_number; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci /* highest UDF revision we have recorded to this media */ 1418c2ecf20Sopenharmony_ci __u16 s_udfrev; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci /* Miscellaneous flags */ 1448c2ecf20Sopenharmony_ci unsigned long s_flags; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci /* Encoding info */ 1478c2ecf20Sopenharmony_ci struct nls_table *s_nls_map; 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci /* VAT inode */ 1508c2ecf20Sopenharmony_ci struct inode *s_vat_inode; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci struct mutex s_alloc_mutex; 1538c2ecf20Sopenharmony_ci /* Protected by s_alloc_mutex */ 1548c2ecf20Sopenharmony_ci unsigned int s_lvid_dirty; 1558c2ecf20Sopenharmony_ci}; 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_cistatic inline struct udf_sb_info *UDF_SB(struct super_block *sb) 1588c2ecf20Sopenharmony_ci{ 1598c2ecf20Sopenharmony_ci return sb->s_fs_info; 1608c2ecf20Sopenharmony_ci} 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_cistruct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct super_block *sb); 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ciint udf_compute_nr_groups(struct super_block *sb, u32 partition); 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_cistatic inline int UDF_QUERY_FLAG(struct super_block *sb, int flag) 1678c2ecf20Sopenharmony_ci{ 1688c2ecf20Sopenharmony_ci return test_bit(flag, &UDF_SB(sb)->s_flags); 1698c2ecf20Sopenharmony_ci} 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_cistatic inline void UDF_SET_FLAG(struct super_block *sb, int flag) 1728c2ecf20Sopenharmony_ci{ 1738c2ecf20Sopenharmony_ci set_bit(flag, &UDF_SB(sb)->s_flags); 1748c2ecf20Sopenharmony_ci} 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_cistatic inline void UDF_CLEAR_FLAG(struct super_block *sb, int flag) 1778c2ecf20Sopenharmony_ci{ 1788c2ecf20Sopenharmony_ci clear_bit(flag, &UDF_SB(sb)->s_flags); 1798c2ecf20Sopenharmony_ci} 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci#endif /* __LINUX_UDF_SB_H */ 182