1 #ifndef MKSQUASHFS_H
2 #define MKSQUASHFS_H
3 /*
4  * Squashfs
5  *
6  * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
7  * 2012, 2013, 2014
8  * Phillip Lougher <phillip@squashfs.org.uk>
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2,
13  * or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23  *
24  * mksquashfs.h
25  *
26  */
27 
28 struct dir_info {
29 	char			*pathname;
30 	char			*subpath;
31 	unsigned int		count;
32 	unsigned int		directory_count;
33 	int			depth;
34 	unsigned int		excluded;
35 	char			dir_is_ldir;
36 	struct dir_ent		*dir_ent;
37 	struct dir_ent		*list;
38 	DIR			*linuxdir;
39 };
40 
41 struct dir_ent {
42 	char			*name;
43 	char			*source_name;
44 	char			*nonstandard_pathname;
45 	struct inode_info	*inode;
46 	struct dir_info		*dir;
47 	struct dir_info		*our_dir;
48 	struct dir_ent		*next;
49 };
50 
51 struct inode_info {
52 	struct stat		buf;
53 	struct inode_info	*next;
54 	squashfs_inode		inode;
55 	unsigned int		inode_number;
56 	unsigned int		nlink;
57 	int			pseudo_id;
58 	char			type;
59 	char			read;
60 	char			root_entry;
61 	char			pseudo_file;
62 	char			no_fragments;
63 	char			always_use_fragments;
64 	char			noD;
65 	char			noF;
66 	char			symlink[0];
67 };
68 
69 /* in memory file info */
70 struct file_info {
71 	long long		file_size;
72 	long long		bytes;
73 	long long		start;
74 	unsigned int		*block_list;
75 	struct file_info	*next;
76 	struct fragment		*fragment;
77 	unsigned short		checksum;
78 	unsigned short		fragment_checksum;
79 	char			have_frag_checksum;
80 	char			have_checksum;
81 };
82 
83 /* fragment block data structures */
84 struct fragment {
85 	unsigned int		index;
86 	int			offset;
87 	int			size;
88 };
89 
90 /* in memory uid tables */
91 #define ID_ENTRIES 256
92 #define ID_HASH(id) (id & (ID_ENTRIES - 1))
93 #define ISA_UID 1
94 #define ISA_GID 2
95 
96 struct id {
97 	unsigned int id;
98 	int	index;
99 	char	flags;
100 	struct id *next;
101 };
102 
103 /* fragment to file mapping used when appending */
104 struct append_file {
105 	struct file_info *file;
106 	struct append_file *next;
107 };
108 
109 #define PSEUDO_FILE_OTHER	1
110 #define PSEUDO_FILE_PROCESS	2
111 
112 #define IS_PSEUDO(a)		((a)->pseudo_file)
113 #define IS_PSEUDO_PROCESS(a)	((a)->pseudo_file & PSEUDO_FILE_PROCESS)
114 #define IS_PSEUDO_OTHER(a)	((a)->pseudo_file & PSEUDO_FILE_OTHER)
115 
116 /*
117  * Amount of physical memory to use by default, and the default queue
118  * ratios
119  */
120 #define SQUASHFS_TAKE 4
121 #define SQUASHFS_READQ_MEM 4
122 #define SQUASHFS_BWRITEQ_MEM 4
123 #define SQUASHFS_FWRITEQ_MEM 4
124 
125 /*
126  * Lowest amount of physical memory considered viable for Mksquashfs
127  * to run in Mbytes
128  */
129 #define SQUASHFS_LOWMEM 64
130 
131 /* offset of data in compressed metadata blocks (allowing room for
132  * compressed size */
133 #define BLOCK_OFFSET 2
134 
135 extern struct cache *reader_buffer, *fragment_buffer, *reserve_cache;
136 struct cache *bwriter_buffer, *fwriter_buffer;
137 extern struct queue *to_reader, *to_deflate, *to_writer, *from_writer,
138 	*to_frag, *locked_fragment, *to_process_frag;
139 extern struct append_file **file_mapping;
140 extern struct seq_queue *to_main;
141 extern pthread_mutex_t fragment_mutex, dup_mutex;
142 extern struct squashfs_fragment_entry *fragment_table;
143 extern struct compressor *comp;
144 extern int block_size;
145 extern struct file_info *dupl[];
146 extern int read_fs_bytes(int, long long, int, void *);
147 extern void add_file(long long, long long, long long, unsigned int *, int,
148 	unsigned int, int, int);
149 extern struct id *create_id(unsigned int);
150 extern unsigned int get_uid(unsigned int);
151 extern unsigned int get_guid(unsigned int);
152 extern int read_bytes(int, void *, int);
153 extern unsigned short get_checksum_mem(char *, int);
154 #endif
155