"Fossies" - the Fresh Open Source Software Archive 
Member "giis_4.6.2/src/giis.h" (27 Mar 2012, 11549 Bytes) of package /linux/misc/old/giis_4.6.2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 /*
2 * /giis/giis.h - The header file.
3 *
4 * gET iT i sAY-giis - EXT3/EXT2 File Undelete Tool. Version 4.4
5 *
6 * Copyright (C) 2009. G.Lakshmipathi.<lakshmipathi.g@giis.co.in> <lakshmipathi.g@gmail.com>
7 *
8 *
9 */
10 #ifndef GIIS_H
11 #define GIIS_H
12
13 /* List of files to be included */
14 #define _LARGEFILE64_SOURCE /* lseek64() required this */
15 #define _GNU_SOURCE
16
17 #include <sys/types.h>
18 #include "ext3_fs.h"
19 #include <sys/stat.h>
20 #include <unistd.h>
21 #include <fcntl.h>
22 #include <errno.h>
23 #include <time.h>
24 #include <pwd.h>
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <string.h>
28
29 /* Pre-defined macro */
30
31 #define O_RDONLY 00
32 #define O_WRONLY 01
33 #define O_RDWR 02
34 #define O_CREAT 0100
35 #define O_EXCL 0200
36 #define O_TRUNC 01000
37
38
39 /* Some macro's used for reading clarity */
40
41 #define JSJ_NO_RETURN 0 /* for routine that need a return code - default to zero */
42
43 /* giis-4.6 LEVEL_VALUE from /etc/giis.conf will be used.
44 #define LEVEL_VALUE 15 //Supports upto 15 levels of sub-dir.(dir1/dir2/dir3.../dir15)
45 */
46 #define INSTALL_DIR1 "/usr/share/giis"
47 #define INSTALL_DIR2 "/usr/share/giis/sys"
48 #define INSTALL_DIR3 "/usr/share/giis/got_it" /* Recovered files */
49 #define INSTALL_DIR4 "/usr/share/giis/unrecovered" /* Unrecovered Files List */
50
51 #define DIR_INFO_FILE "/usr/share/giis/sys/dir" /* Directory informations*/
52 #define FILE_INFO_FILE "/usr/share/giis/sys/file" /* File informations */
53 #define SIND_INFO_FILE "/usr/share/giis/sys/sind" /* single indirect blocks */
54 #define DIND_INFO_FILE "/usr/share/giis/sys/dind" /* Double indirect blocks */
55 #define SAMPLE_DATA_FILE "/usr/share/giis/sys/sample" /* Sample Data File */
56 #define GIIS_RERE_FILE "/usr/share/giis/restore_details.txt" /* File contains info about restore paths */
57 #define GIIS_CONF_FILE "/etc/giis.conf" /* config file*/
58
59 #define DEFAULT_OFFSET_OF_SUPER_BLOCK 1024 /* Default offset */
60 #define ACCESS 0 /* Read only */
61 #define SUPER_BLOCK_SIZE sizeof(struct ext3_super_block)
62 /* #define INODE_SIZE 128 */ // Get from SB
63 #define GROUP_DESC_SIZE sizeof(struct ext3_group_desc)
64 #define DIR_SIZE sizeof(struct ext3_dir_entry_2)
65 #define GIIS_DSIZE sizeof(struct s_dir_recover_info)
66 #define GIIS_FSIZE sizeof(struct s_file_recover_info)
67 #define GIIS_SSIZE sizeof(struct s_sample_file_data)
68
69 #define ROOT_INODE 2
70 #define RANGE 4294967295UL
71 #define MAX_FILE_LENGTH 64
72
73
74 /* Buffers which will be loaded with corresponding structures */
75
76 union get_ext_super_block{
77 struct ext3_super_block sb;
78 char buffer[sizeof(struct ext3_super_block)];
79 }isb;
80
81 union get_ext_group_desc{
82 struct ext3_group_desc gd;
83 char buffer[sizeof(struct ext3_group_desc)];
84 }igd;
85
86 union get_ext_inode{
87 struct ext3_inode in;
88 char buffer[sizeof(struct ext3_inode)];
89 }iin;
90 union get_ext_dir{
91 struct ext3_dir_entry_2 de;
92 char buffer[sizeof(struct ext3_dir_entry_2)];
93 }ide;
94
95 /* Contains file system Infomations */
96 struct file_system{
97
98 /* Group Specific */
99 unsigned long group_number;
100 unsigned long block_bitmap;
101 unsigned long inode_bitmap;
102 unsigned long inode_table;
103 unsigned long free_blocks_count;
104 unsigned long free_inodes_count;
105 /*General info*/
106 unsigned long inode_number;
107 unsigned long block_number;
108 unsigned long super_block_offset;
109 unsigned long group_offset;
110 unsigned long long inode_offset; /* Consist of current inodes offset */
111 unsigned long long root_inode_offset;
112 unsigned long long device_offset;
113 unsigned long long content_offset;
114 unsigned long index_number; /* Index number in Inode Table of Group Descriptor */
115 /*Obtained info */
116 unsigned long inodes_per_group;
117 unsigned long blocks_per_group;
118 int groups_count; /* Total Number of Group Descriptor */
119 unsigned long long inodes_count; /* Total Number of inodes in Group Descriptor */
120 unsigned long long blocks_count; /* Total Number of blocks in Group Descriptor */
121 unsigned long long fs_size; /* File system size */
122 int inode_table_size;
123 int inodes_per_block;
124 int block_size;
125 int first_data_block;
126 int first_group_desc;
127 int inode_size; /* Get it from SB */
128 }fs;
129
130 /* information for recovery */
131
132 union u_file_recover_info{
133 struct s_file_recover_info{
134 char date_time[30]; /* When this entry recorded */
135 char name[64]; /* filename */
136 unsigned long inode_number; /* inode number */
137 unsigned long parent_inode_number; /* Directory inode number */
138 int search_flag; /* Search flags*/
139 uid_t mode; /* File type */
140 uid_t owner; /* owner's uid */
141 unsigned long file_blocks_count; /* Blocks count */
142 unsigned long file_size;
143 unsigned long file_flags;
144 unsigned long data_block[EXT3_N_BLOCKS];/* Contents pointer */
145 unsigned long is_offset; /* Single Indirect Block offset */
146 unsigned long id_offset; /* Double indirect Block offset */
147 int sfragment_flag; /* Which to use */
148 int dfragment_flag;
149 unsigned long last_data_block;/* Block number where last data remains */
150 }info;
151 char buffer[sizeof(struct s_file_recover_info)];
152 }giis_f;
153
154
155 union u_dir_recover_info{
156 struct s_dir_recover_info{
157 char date_time[30]; /* When this entry recorded */
158 char name[64]; /* Directory name */
159 unsigned long inode_number; /* inode number */
160 unsigned long parent_inode_number; /* Directory inode number */
161 int search_flag; /* Indicates entry search or not */
162 }info;
163 char buffer[sizeof(struct s_dir_recover_info)];
164 }giis_d,giis_dt;
165
166
167 union u_sample_file_data{
168 struct s_sample_file_data{
169 unsigned long inode_number; /* inode number */
170 char sdata[32]; /* Sample content of file */
171 }info;
172 char buffer[sizeof(struct s_sample_file_data)];
173 }giis_s;
174
175 /* Recover and Restore */
176 union u_s_rere_info{
177 struct s_rere_info{
178 unsigned long list_of_deleted_inodes[2048]; /* For Recover and Restore */
179 char list_of_restorepaths[150][150]; /* For Recover and Restore */
180 }info;
181 char buffer[sizeof(struct s_rere_info)];
182 }giis_r;
183
184
185 /* Single or Double Indirect */
186 unsigned long idata_block[1024];
187
188 struct passwd *pwfile; /* Used for uid verfication */
189
190
191
192 /*Global Variables */
193 int gi_round,hole,gd;
194 char device_name[100],user[25],search_file[30];
195 char auto_time[5]; /* Time value from conf file */
196 int auto_time2; /* Converted time value */
197 char s_level_value[5]; /* Level value from conf file */
198 int level_value; /* Converted Level value */
199
200 int dir,use_uid,install,fd;
201 int install_file;
202 int update_file,update_dir; /* Required during updates */
203 int entry,found; /* Used in dir.c while recording data */
204 time_t result; /* time n date used to ? */
205 char date_time[25]; /* specific when entries recorded */
206 unsigned long long deleted_inode_offset; /* Deleted inode's offset */
207 unsigned long size,err_size; /* File size used to read a file */
208 unsigned long home_inode; /* inode of /home */
209 unsigned long root_inode; /* inode of /root */
210 unsigned long s_offy; /* SIND offset */
211 unsigned long d_offy; /* DIND offset */
212 int dir_level; /* Directory depth */
213 int fileoverwritten; /* File modified or overwritten */
214 int search_format; /* Get files using its format */
215 int startbyte; /* Used in file.c */
216 int get_version; /* version */
217 int repeat; /* For check */
218 int parent_found; /* Used while displaying list of deleted files */
219 char pathname[150]; /* Same as above */
220 int rere; /* Recover and Restore */
221 char rere_filenames[200][150]; /* To hold file names */
222 int rere_count; /* To hold the count */
223 unsigned long rere_inodes[1024]; /* To hold inodes */
224 char g_directory[100][100];
225 int g_row; /* directories count from config file*/
226 int new_dir_added; /* To be used in update to include all sub-dir*/
227 int large_dir; /* For checking large directories */
228 int dir_seq;
229 int large_dir_count;
230 int install_mode; /* supports config file setup */
231 int day,month,year,day1,month1,year1; /* Get by date */
232 int date_mode;
233 time_t result1; /* time n date used for Time based recovery*/
234 int test_count1,test_count2;
235
236
237 /* Function protocols */
238
239 /* dir.c */
240
241 int set_content_offset(); /* Sets offset to content of inode */
242 int read_dir(); /* Load dirctory into buffer*/
243 int record_dir(unsigned long); /* Writes data into DIR_INFO_FILE */
244 int record_file(unsigned long); /* Writes data into FILE_INFO_FILE */
245 int show_dir(); /* Display directory */
246
247 /* file.c */
248
249 int read_show_file(int,int); /* Read a file */
250 int read_dir_info_file(); /* Reads data from DIR_INFO FILE */
251 int read_file_info_file(); /* Reads data from FILE_INFO_FILE */
252 int read_sind_info_file(); /* Reads SIND_INFO_FILE */
253 int read_dind_info_file(); /* Reads DIND_INFO_FILE */
254 int read_sample_info_file(unsigned long); /* Reads SAMPLE_DATA_FILE */
255 void show_data(char []); /* Displays Given Buffer */
256 int file_repeated(char []); /* No.of times entry exists in sys file */
257 int display_deleted_files(); /* List deleted file names */
258 int lookup(unsigned long); /* Lookup parent of given inode */
259 int read_config_file(char []); /* Get data from giis.conf file */
260 int read_config_file2(); /* Get data from conf file and store in global variable*/
261 int read_conf_file_inum(); /* Get's inode number of config files */
262
263 /* get_it_i_say.c */
264 int get_it(); /* Search for all deleted file and recover */
265 int verify_inode(unsigned long); /* Verifies given inode is free or not */
266 int get_it_i_say(); /* Recovers the deleted file */
267 int get_data_from_block(int,int,unsigned long); /* Get data from block */
268 int force_giis(); /* Get specific file */
269 int recover_restore(); /* Restore the recovered files */
270
271
272 /* group.c */
273 int get_group_desc(); /* Get request Group Desccriptor */
274 int eye_on_gd(); /* Keep track of group */
275
276 /* init.c */
277
278 int search4fs(); /* Searches for root file system */
279 int search4super_block(); /* Searches for superblock */
280 void set_file_system(); /* Set file_system for processing */
281 int search4group_desc(); /* Searches for group descriptor */
282 int init(); /* Initialize Procedure */
283 int init_files(); /* Creates or opens files */
284 int fs_display(); /* Display FS info */
285
286 /* inode.c */
287
288 int find_inode_offset(); /* Initialize offset of inode */
289 int read_inode(); /* Get inode from offset*/
290 int show_inode(); /* Display inode*/
291
292
293 /* searchnupdate.c */
294 int search4dir(); /* searches for directory */
295 int update_dir_info_file(); /* Updates DIR_INFO_FILE */
296 int get_parent_inode_flag(unsigned long); /* Get Parent of given inode */
297 int search4sequence12(); /* Searches for continuous blocks */
298 int search4sequence13(); /* Searches for continuous blocks */
299 int avoid_dups(); /* Removes duplicates */
300 int call2remove(int); /* Helper to above */
301 int check4file_dups(unsigned long); /* Check for duplicates */
302 int check4dir_dups(unsigned long); /* Check for duplicates */
303 int dir_depth(unsigned long ); /* Get directory depth */
304 int get_sample_data(); /* Get file content */
305 int check4samplefile_dups(unsigned long); /* Avoids duplication of sample data */
306
307 /* uninit.c */
308 int remove_giis(); /* Uninstalls giis */
309
310
311 #endif /* GIIS_H */