1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *  Name                 : qnx6_fs.h
4  *  Author               : Kai Bankett
5  *  Function             : qnx6 global filesystem definitions
6  *  History              : 17-01-2012 created
7  */
8 #ifndef _LINUX_QNX6_FS_H
9 #define _LINUX_QNX6_FS_H
10 
11 #include <linux/types.h>
12 #include <linux/magic.h>
13 
14 #define QNX6_ROOT_INO 1
15 
16 /* for di_status */
17 #define QNX6_FILE_DIRECTORY	0x01
18 #define QNX6_FILE_DELETED	0x02
19 #define QNX6_FILE_NORMAL	0x03
20 
21 #define QNX6_SUPERBLOCK_SIZE	0x200	/* superblock always is 512 bytes */
22 #define QNX6_SUPERBLOCK_AREA	0x1000	/* area reserved for superblock */
23 #define	QNX6_BOOTBLOCK_SIZE	0x2000	/* heading bootblock area */
24 #define QNX6_DIR_ENTRY_SIZE	0x20	/* dir entry size of 32 bytes */
25 #define QNX6_INODE_SIZE		0x80	/* each inode is 128 bytes */
26 #define QNX6_INODE_SIZE_BITS	7	/* inode entry size shift */
27 
28 #define QNX6_NO_DIRECT_POINTERS	16	/* 16 blockptrs in sbl/inode */
29 #define QNX6_PTR_MAX_LEVELS	5	/* maximum indirect levels */
30 
31 /* for filenames */
32 #define QNX6_SHORT_NAME_MAX	27
33 #define QNX6_LONG_NAME_MAX	510
34 
35 /* list of mount options */
36 #define QNX6_MOUNT_MMI_FS	0x010000 /* mount as Audi MMI 3G fs */
37 
38 /*
39  * This is the original qnx6 inode layout on disk.
40  * Each inode is 128 byte long.
41  */
42 struct qnx6_inode_entry {
43 	__fs64		di_size;
44 	__fs32		di_uid;
45 	__fs32		di_gid;
46 	__fs32		di_ftime;
47 	__fs32		di_mtime;
48 	__fs32		di_atime;
49 	__fs32		di_ctime;
50 	__fs16		di_mode;
51 	__fs16		di_ext_mode;
52 	__fs32		di_block_ptr[QNX6_NO_DIRECT_POINTERS];
53 	__u8		di_filelevels;
54 	__u8		di_status;
55 	__u8		di_unknown2[2];
56 	__fs32		di_zero2[6];
57 };
58 
59 /*
60  * Each directory entry is maximum 32 bytes long.
61  * If more characters or special characters required it is stored
62  * in the longfilenames structure.
63  */
64 struct qnx6_dir_entry {
65 	__fs32		de_inode;
66 	__u8		de_size;
67 	char		de_fname[QNX6_SHORT_NAME_MAX];
68 };
69 
70 /*
71  * Longfilename direntries have a different structure
72  */
73 struct qnx6_long_dir_entry {
74 	__fs32		de_inode;
75 	__u8		de_size;
76 	__u8		de_unknown[3];
77 	__fs32		de_long_inode;
78 	__fs32		de_checksum;
79 };
80 
81 struct qnx6_long_filename {
82 	__fs16		lf_size;
83 	__u8		lf_fname[QNX6_LONG_NAME_MAX];
84 };
85 
86 struct qnx6_root_node {
87 	__fs64		size;
88 	__fs32		ptr[QNX6_NO_DIRECT_POINTERS];
89 	__u8		levels;
90 	__u8		mode;
91 	__u8		spare[6];
92 };
93 
94 struct qnx6_super_block {
95 	__fs32		sb_magic;
96 	__fs32		sb_checksum;
97 	__fs64		sb_serial;
98 	__fs32		sb_ctime;	/* time the fs was created */
99 	__fs32		sb_atime;	/* last access time */
100 	__fs32		sb_flags;
101 	__fs16		sb_version1;	/* filesystem version information */
102 	__fs16		sb_version2;	/* filesystem version information */
103 	__u8		sb_volumeid[16];
104 	__fs32		sb_blocksize;
105 	__fs32		sb_num_inodes;
106 	__fs32		sb_free_inodes;
107 	__fs32		sb_num_blocks;
108 	__fs32		sb_free_blocks;
109 	__fs32		sb_allocgroup;
110 	struct qnx6_root_node Inode;
111 	struct qnx6_root_node Bitmap;
112 	struct qnx6_root_node Longfile;
113 	struct qnx6_root_node Unknown;
114 };
115 
116 /* Audi MMI 3G superblock layout is different to plain qnx6 */
117 struct qnx6_mmi_super_block {
118 	__fs32		sb_magic;
119 	__fs32		sb_checksum;
120 	__fs64		sb_serial;
121 	__u8		sb_spare0[12];
122 	__u8		sb_id[12];
123 	__fs32		sb_blocksize;
124 	__fs32		sb_num_inodes;
125 	__fs32		sb_free_inodes;
126 	__fs32		sb_num_blocks;
127 	__fs32		sb_free_blocks;
128 	__u8		sb_spare1[4];
129 	struct qnx6_root_node Inode;
130 	struct qnx6_root_node Bitmap;
131 	struct qnx6_root_node Longfile;
132 	struct qnx6_root_node Unknown;
133 };
134 
135 #endif
136