xref: /openbmc/linux/fs/udf/udf_sb.h (revision 423cf6dc)
11da177e4SLinus Torvalds #ifndef __LINUX_UDF_SB_H
21da177e4SLinus Torvalds #define __LINUX_UDF_SB_H
31da177e4SLinus Torvalds 
415aebd28SChristoph Hellwig #include <linux/mutex.h>
515aebd28SChristoph Hellwig 
61da177e4SLinus Torvalds /* Since UDF 2.01 is ISO 13346 based... */
71da177e4SLinus Torvalds #define UDF_SUPER_MAGIC			0x15013346
81da177e4SLinus Torvalds 
91da177e4SLinus Torvalds #define UDF_MAX_READ_VERSION		0x0201
101da177e4SLinus Torvalds #define UDF_MAX_WRITE_VERSION		0x0201
111da177e4SLinus Torvalds 
121da177e4SLinus Torvalds #define UDF_FLAG_USE_EXTENDED_FE	0
131da177e4SLinus Torvalds #define UDF_VERS_USE_EXTENDED_FE	0x0200
141da177e4SLinus Torvalds #define UDF_FLAG_USE_STREAMS		1
151da177e4SLinus Torvalds #define UDF_VERS_USE_STREAMS		0x0200
161da177e4SLinus Torvalds #define UDF_FLAG_USE_SHORT_AD		2
171da177e4SLinus Torvalds #define UDF_FLAG_USE_AD_IN_ICB		3
181da177e4SLinus Torvalds #define UDF_FLAG_USE_FILE_CTIME_EA	4
191da177e4SLinus Torvalds #define UDF_FLAG_STRICT			5
201da177e4SLinus Torvalds #define UDF_FLAG_UNDELETE		6
211da177e4SLinus Torvalds #define UDF_FLAG_UNHIDE			7
221da177e4SLinus Torvalds #define UDF_FLAG_VARCONV		8
231da177e4SLinus Torvalds #define UDF_FLAG_NLS_MAP		9
241da177e4SLinus Torvalds #define UDF_FLAG_UTF8			10
254d6660ebSPhillip Susi #define UDF_FLAG_UID_FORGET     11    /* save -1 for uid to disk */
264d6660ebSPhillip Susi #define UDF_FLAG_UID_IGNORE     12    /* use sb uid instead of on disk uid */
274d6660ebSPhillip Susi #define UDF_FLAG_GID_FORGET     13
284d6660ebSPhillip Susi #define UDF_FLAG_GID_IGNORE     14
29ca76d2d8SCyrill Gorcunov #define UDF_FLAG_UID_SET	15
30ca76d2d8SCyrill Gorcunov #define UDF_FLAG_GID_SET	16
316da80894SMiklos Szeredi #define UDF_FLAG_SESSION_SET	17
326da80894SMiklos Szeredi #define UDF_FLAG_LASTBLOCK_SET	18
331da177e4SLinus Torvalds 
341da177e4SLinus Torvalds #define UDF_PART_FLAG_UNALLOC_BITMAP	0x0001
351da177e4SLinus Torvalds #define UDF_PART_FLAG_UNALLOC_TABLE	0x0002
361da177e4SLinus Torvalds #define UDF_PART_FLAG_FREED_BITMAP	0x0004
371da177e4SLinus Torvalds #define UDF_PART_FLAG_FREED_TABLE	0x0008
381da177e4SLinus Torvalds #define UDF_PART_FLAG_READ_ONLY		0x0010
391da177e4SLinus Torvalds #define UDF_PART_FLAG_WRITE_ONCE	0x0020
401da177e4SLinus Torvalds #define UDF_PART_FLAG_REWRITABLE	0x0040
411da177e4SLinus Torvalds #define UDF_PART_FLAG_OVERWRITABLE	0x0080
421da177e4SLinus Torvalds 
4315aebd28SChristoph Hellwig #define UDF_MAX_BLOCK_LOADED	8
4415aebd28SChristoph Hellwig 
4515aebd28SChristoph Hellwig #define UDF_TYPE1_MAP15			0x1511U
4615aebd28SChristoph Hellwig #define UDF_VIRTUAL_MAP15		0x1512U
4715aebd28SChristoph Hellwig #define UDF_VIRTUAL_MAP20		0x2012U
4815aebd28SChristoph Hellwig #define UDF_SPARABLE_MAP15		0x1522U
4915aebd28SChristoph Hellwig 
5015aebd28SChristoph Hellwig #pragma pack(1) /* XXX(hch): Why?  This file just defines in-core structures */
5115aebd28SChristoph Hellwig 
5215aebd28SChristoph Hellwig struct udf_sparing_data {
5315aebd28SChristoph Hellwig 	__u16	s_packet_len;
5415aebd28SChristoph Hellwig 	struct buffer_head *s_spar_map[4];
5515aebd28SChristoph Hellwig };
5615aebd28SChristoph Hellwig 
5715aebd28SChristoph Hellwig struct udf_virtual_data {
5815aebd28SChristoph Hellwig 	__u32	s_num_entries;
5915aebd28SChristoph Hellwig 	__u16	s_start_offset;
6015aebd28SChristoph Hellwig };
6115aebd28SChristoph Hellwig 
6215aebd28SChristoph Hellwig struct udf_bitmap {
6315aebd28SChristoph Hellwig 	__u32			s_extLength;
6415aebd28SChristoph Hellwig 	__u32			s_extPosition;
6515aebd28SChristoph Hellwig 	__u16			s_nr_groups;
6615aebd28SChristoph Hellwig 	struct buffer_head 	**s_block_bitmap;
6715aebd28SChristoph Hellwig };
6815aebd28SChristoph Hellwig 
6915aebd28SChristoph Hellwig struct udf_part_map {
7015aebd28SChristoph Hellwig 	union {
7115aebd28SChristoph Hellwig 		struct udf_bitmap	*s_bitmap;
7215aebd28SChristoph Hellwig 		struct inode		*s_table;
7315aebd28SChristoph Hellwig 	} s_uspace;
7415aebd28SChristoph Hellwig 	union {
7515aebd28SChristoph Hellwig 		struct udf_bitmap	*s_bitmap;
7615aebd28SChristoph Hellwig 		struct inode		*s_table;
7715aebd28SChristoph Hellwig 	} s_fspace;
7815aebd28SChristoph Hellwig 	__u32	s_partition_root;
7915aebd28SChristoph Hellwig 	__u32	s_partition_len;
8015aebd28SChristoph Hellwig 	__u16	s_partition_type;
8115aebd28SChristoph Hellwig 	__u16	s_partition_num;
8215aebd28SChristoph Hellwig 	union {
8315aebd28SChristoph Hellwig 		struct udf_sparing_data s_sparing;
8415aebd28SChristoph Hellwig 		struct udf_virtual_data s_virtual;
8515aebd28SChristoph Hellwig 	} s_type_specific;
8615aebd28SChristoph Hellwig 	__u32	(*s_partition_func)(struct super_block *, __u32, __u16, __u32);
8715aebd28SChristoph Hellwig 	__u16	s_volumeseqnum;
8815aebd28SChristoph Hellwig 	__u16	s_partition_flags;
8915aebd28SChristoph Hellwig };
9015aebd28SChristoph Hellwig 
9115aebd28SChristoph Hellwig #pragma pack()
9215aebd28SChristoph Hellwig 
9315aebd28SChristoph Hellwig struct udf_sb_info {
9415aebd28SChristoph Hellwig 	struct udf_part_map	*s_partmaps;
9515aebd28SChristoph Hellwig 	__u8			s_volume_ident[32];
9615aebd28SChristoph Hellwig 
9715aebd28SChristoph Hellwig 	/* Overall info */
9815aebd28SChristoph Hellwig 	__u16			s_partitions;
9915aebd28SChristoph Hellwig 	__u16			s_partition;
10015aebd28SChristoph Hellwig 
10115aebd28SChristoph Hellwig 	/* Sector headers */
10215aebd28SChristoph Hellwig 	__s32			s_session;
103423cf6dcSJan Kara 	__u32			s_anchor[3];
10415aebd28SChristoph Hellwig 	__u32			s_last_block;
10515aebd28SChristoph Hellwig 
10615aebd28SChristoph Hellwig 	struct buffer_head	*s_lvid_bh;
10715aebd28SChristoph Hellwig 
10815aebd28SChristoph Hellwig 	/* Default permissions */
10915aebd28SChristoph Hellwig 	mode_t			s_umask;
11015aebd28SChristoph Hellwig 	gid_t			s_gid;
11115aebd28SChristoph Hellwig 	uid_t			s_uid;
11215aebd28SChristoph Hellwig 
11315aebd28SChristoph Hellwig 	/* Root Info */
11415aebd28SChristoph Hellwig 	struct timespec		s_record_time;
11515aebd28SChristoph Hellwig 
11615aebd28SChristoph Hellwig 	/* Fileset Info */
11715aebd28SChristoph Hellwig 	__u16			s_serial_number;
11815aebd28SChristoph Hellwig 
11915aebd28SChristoph Hellwig 	/* highest UDF revision we have recorded to this media */
12015aebd28SChristoph Hellwig 	__u16			s_udfrev;
12115aebd28SChristoph Hellwig 
12215aebd28SChristoph Hellwig 	/* Miscellaneous flags */
12315aebd28SChristoph Hellwig 	__u32			s_flags;
12415aebd28SChristoph Hellwig 
12515aebd28SChristoph Hellwig 	/* Encoding info */
12615aebd28SChristoph Hellwig 	struct nls_table	*s_nls_map;
12715aebd28SChristoph Hellwig 
12815aebd28SChristoph Hellwig 	/* VAT inode */
12915aebd28SChristoph Hellwig 	struct inode		*s_vat_inode;
13015aebd28SChristoph Hellwig 
13115aebd28SChristoph Hellwig 	struct mutex		s_alloc_mutex;
13215aebd28SChristoph Hellwig };
13315aebd28SChristoph Hellwig 
1341da177e4SLinus Torvalds static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
1351da177e4SLinus Torvalds {
1361da177e4SLinus Torvalds 	return sb->s_fs_info;
1371da177e4SLinus Torvalds }
1381da177e4SLinus Torvalds 
1396c79e987SMarcin Slusarz struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct udf_sb_info *sbi);
1401da177e4SLinus Torvalds 
141883cb9d1SMarcin Slusarz int udf_compute_nr_groups(struct super_block *sb, u32 partition);
142883cb9d1SMarcin Slusarz 
1431da177e4SLinus Torvalds #define UDF_QUERY_FLAG(X,Y)			( UDF_SB(X)->s_flags & ( 1 << (Y) ) )
1441da177e4SLinus Torvalds #define UDF_SET_FLAG(X,Y)			( UDF_SB(X)->s_flags |= ( 1 << (Y) ) )
1451da177e4SLinus Torvalds #define UDF_CLEAR_FLAG(X,Y)			( UDF_SB(X)->s_flags &= ~( 1 << (Y) ) )
1461da177e4SLinus Torvalds 
1471da177e4SLinus Torvalds #endif /* __LINUX_UDF_SB_H */
148