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