1 | /* my-stuff.h |
---|
2 | $Id: my-stuff.h 1928 2008-04-18 13:14:36Z bruno $ |
---|
3 | */ |
---|
4 | |
---|
5 | #define HAVE_MALLOC 1 |
---|
6 | |
---|
7 | |
---|
8 | // Extra info for ACLs and SELINUX users |
---|
9 | #define STAR_ACL_SZ "-xfflags -acl" |
---|
10 | //#define STAR_ACL_SZ "-xfflags" |
---|
11 | //#define STAR_ACL_SZ "" |
---|
12 | // Enable the first line and disable the second if you are a Fedora Core 2 user |
---|
13 | |
---|
14 | /** |
---|
15 | * @file |
---|
16 | * The main header file for Mondo. |
---|
17 | */ |
---|
18 | |
---|
19 | #if !defined(bool) && !defined(__cplusplus) |
---|
20 | /** |
---|
21 | * Create the illusion of a Boolean type. |
---|
22 | */ |
---|
23 | #define bool int |
---|
24 | #define TRUE 1 |
---|
25 | #define FALSE 0 |
---|
26 | #endif |
---|
27 | |
---|
28 | #ifndef _MY_STUFF_H_ |
---|
29 | #define _MY_STUFF_H_ |
---|
30 | |
---|
31 | #ifdef HAVE_CONFIG_H |
---|
32 | #include <config.h> |
---|
33 | #endif |
---|
34 | |
---|
35 | #ifndef __FreeBSD__ |
---|
36 | #include <getopt.h> |
---|
37 | #endif |
---|
38 | #include <sys/types.h> |
---|
39 | #include <sys/shm.h> |
---|
40 | #include <sys/ipc.h> |
---|
41 | #include <sys/ioctl.h> |
---|
42 | #include <sys/sem.h> |
---|
43 | #include <sys/param.h> |
---|
44 | #include <stdio.h> |
---|
45 | #include <stdlib.h> |
---|
46 | #ifndef __USE_FILE_OFFSET64 |
---|
47 | #define __USE_FILE_OFFSET64 |
---|
48 | #endif |
---|
49 | #ifndef __USE_LARGEFILE64 |
---|
50 | #define __USE_LARGEFILE64 |
---|
51 | #endif |
---|
52 | #include <sys/stat.h> |
---|
53 | #include <fcntl.h> |
---|
54 | #include <errno.h> |
---|
55 | #include <stddef.h> |
---|
56 | #include <sys/stat.h> |
---|
57 | #include <sys/wait.h> |
---|
58 | #include <time.h> |
---|
59 | #include <unistd.h> |
---|
60 | #include <signal.h> |
---|
61 | //#include <curses.h> |
---|
62 | #include <newt.h> |
---|
63 | #include <ctype.h> |
---|
64 | #include <string.h> |
---|
65 | #include <pthread.h> |
---|
66 | #include <assert.h> |
---|
67 | |
---|
68 | #if defined(DEBUG) && !__cplusplus |
---|
69 | int count; |
---|
70 | char trace_log[255]; /*buffer for logging */ |
---|
71 | char *trace_log_ptr; |
---|
72 | #endif /* DEBUG */ |
---|
73 | |
---|
74 | #define IA64_BOOT_SIZE "16384" /* Should be coherent with mindi */ |
---|
75 | #define STD_PREFIX "mondorescue" /* Should be coherent with mindi */ |
---|
76 | |
---|
77 | /** |
---|
78 | * The biggielist stub (appended to the directory where all.tar.gz was unpacked). |
---|
79 | */ |
---|
80 | #define BIGGIELIST_TXT_STUB "./tmp/biggielist.txt" |
---|
81 | |
---|
82 | /** |
---|
83 | * The filelist stub (appended to the directory where all.tar.gz was unpacked). |
---|
84 | */ |
---|
85 | #define FILELIST_FULL_STUB "./tmp/filelist.full.gz" |
---|
86 | |
---|
87 | /** |
---|
88 | * The mountlist stub (appended to the directory where all.tar.gz was unpacked). |
---|
89 | */ |
---|
90 | #define MOUNTLIST_FNAME_STUB "./tmp/mountlist.txt" |
---|
91 | |
---|
92 | /** |
---|
93 | * The mondo-restore.cfg stub (appended to the directory where all.tar.gz was unpacked). |
---|
94 | */ |
---|
95 | #define MONDO_CFG_FILE_STUB "./tmp/mondo-restore.cfg" |
---|
96 | /** |
---|
97 | * The location where mindi media images are stored. |
---|
98 | */ |
---|
99 | #define MINDI_CACHE "/var/cache/mindi" |
---|
100 | |
---|
101 | /** |
---|
102 | * The location where mondo changed info are stored. |
---|
103 | */ |
---|
104 | #define MONDO_CACHE "/var/cache/mondo" |
---|
105 | |
---|
106 | /** |
---|
107 | * The RAID kernel proc file |
---|
108 | */ |
---|
109 | #define MDSTAT_FILE "/proc/mdstat" |
---|
110 | |
---|
111 | /** |
---|
112 | * @bug Apparently unused. |
---|
113 | */ |
---|
114 | #define MONDO_TRACEFILE "/var/log/mondo-tracefile.log" |
---|
115 | |
---|
116 | #undef assert |
---|
117 | |
---|
118 | extern void _mondo_assert_fail(const char *file, const char *function, |
---|
119 | int line, const char *exp); |
---|
120 | |
---|
121 | /** |
---|
122 | * An assert macro that calls _mondo_assert_fail() when it fails. |
---|
123 | */ |
---|
124 | #ifdef NDEBUG |
---|
125 | #define assert(exp) ((void)0) |
---|
126 | #else |
---|
127 | #define assert(exp) ((exp)?((void)0):_mondo_assert_fail(__FILE__, __FUNCTION__, __LINE__, #exp)) |
---|
128 | #endif |
---|
129 | |
---|
130 | #define CRC_M16 0xA001 ///< Mask for crc16. |
---|
131 | #define CRC_MTT 0x1021 ///< Mask for crc-ccitt. |
---|
132 | |
---|
133 | #define FALSE 0 ///< The ubiquitous FALSE macro. |
---|
134 | #define TRUE 1 ///< The even more ubiquitous TRUE macro. |
---|
135 | |
---|
136 | #define SCREEN_LENGTH 25 ///< The default size of the screen. |
---|
137 | #define NOOF_ERR_LINES 6 ///< The number of lines of log output to keep at the bottom of the screen. |
---|
138 | #define ARBITRARY_MAXIMUM 2000 ///< The maximum number of items showing at once in the mountlist or filelist editor. |
---|
139 | #define MAX_TAPECATALOG_ENTRIES 8192 ///< The maximum number of entries in the tape catalog. |
---|
140 | #define MAX_STR_LEN 384 ///< The maximum length of almost all @p char buffers in Mondo. |
---|
141 | /// Note: Make this divisible by eight to avoid aligment issues |
---|
142 | /// on 64bit platforms like ia64. |
---|
143 | #define MAXIMUM_RAID_DEVS 32 ///< The maximum number of RAID devices in the raidlist. |
---|
144 | #define MAXIMUM_ADDITIONAL_RAID_VARS 32 ///< The maximum number of additional RAID variables per RAID device in the raidlist. |
---|
145 | #define MAXIMUM_DISKS_PER_RAID_DEV 32 ///< The maximum number of disks per RAID device in the raidtab. |
---|
146 | |
---|
147 | #define RAIDTAB_FNAME "/etc/raidtab" ///< The filename of the raidtab file, at least on Linux. |
---|
148 | |
---|
149 | #define BLK_START_OF_BACKUP 1 ///< Marker block: start a backup. |
---|
150 | #define BLK_START_OF_TAPE 2 ///< Marker block: start a tape. |
---|
151 | #define BLK_START_AFIOBALLS 10 ///< Marker block: start the afioball section. |
---|
152 | #define BLK_STOP_AFIOBALLS 19 ///< Marker block: stop the afioball section. |
---|
153 | #define BLK_START_AN_AFIO_OR_SLICE 20 ///< Marker block: start an afioball or a slice. |
---|
154 | #define BLK_STOP_AN_AFIO_OR_SLICE 29 ///< Marker block: stop an afioball or a slice. |
---|
155 | #define BLK_START_BIGGIEFILES 30 ///< Marker block: start the biggiefile section. |
---|
156 | #define BLK_STOP_BIGGIEFILES 39 ///< Marker block: stop the biggiefile section. |
---|
157 | #define BLK_START_A_NORMBIGGIE 40 ///< Marker block: start a normal biggiefile. |
---|
158 | #define BLK_START_A_PIHBIGGIE 41 ///< Marker block: start a ntfsprog'd biggiefile |
---|
159 | #define BLK_START_EXTENDED_ATTRIBUTES 45 ///< Marker block: start xattr/acl info |
---|
160 | #define BLK_STOP_EXTENDED_ATTRIBUTES 46 ///< Marker block: stop xattr/acl info |
---|
161 | #define BLK_START_EXAT_FILE 47 |
---|
162 | #define BLK_STOP_EXAT_FILE 48 |
---|
163 | #define BLK_STOP_A_BIGGIE 59 ///< Marker block: stop a biggiefile. |
---|
164 | #define BLK_START_FILE 80 ///< Marker block: start a file (non-afio or slice). |
---|
165 | #define BLK_STOP_FILE 89 ///< Marker block: stop a file (non-afio or slice). |
---|
166 | #define BLK_END_OF_TAPE 100 ///< Marker block: end of tape. |
---|
167 | #define BLK_END_OF_BACKUP 101 ///< Marker block: end of backup. |
---|
168 | #define BLK_ABORTED_BACKUP 102 ///< Marker block: backup was aborted. |
---|
169 | |
---|
170 | /// The external tape blocksize. |
---|
171 | #ifdef EXTTAPE |
---|
172 | #define TAPE_BLOCK_SIZE (long)EXTTAPE |
---|
173 | #else |
---|
174 | #define TAPE_BLOCK_SIZE 131072L /* was 8192; 06/2002-->65536; 11/2002-->131072 */ |
---|
175 | #endif |
---|
176 | |
---|
177 | #define DEFAULT_INTERNAL_TAPE_BLOCK_SIZE 32768 // Nov 2003? |
---|
178 | |
---|
179 | |
---|
180 | |
---|
181 | |
---|
182 | #define SLICE_SIZE 4096 ///< The size of a slice of a biggiefile. |
---|
183 | |
---|
184 | |
---|
185 | |
---|
186 | |
---|
187 | |
---|
188 | |
---|
189 | /** |
---|
190 | * Determine whether @p x (t_bkptype) is a streaming backup. |
---|
191 | */ |
---|
192 | #define IS_THIS_A_STREAMING_BACKUP(x) (x == tape || x == udev || x == cdstream) |
---|
193 | |
---|
194 | |
---|
195 | /** |
---|
196 | * @c mkisofs command to generate a nonbootable CD, except for -o option and the directory to image. |
---|
197 | */ |
---|
198 | #define MONDO_MKISOFS_NONBOOT "mkisofs -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_" |
---|
199 | |
---|
200 | /** |
---|
201 | * @c mkisofs command to generate a bootable CD using isolinux, except for -o option and the directory to image. |
---|
202 | */ |
---|
203 | #define MONDO_MKISOFS_REGULAR_SYSLINUX "mkisofs -J -boot-info-table -no-emul-boot -b isolinux.bin -c boot.cat -boot-load-size 4 -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_" |
---|
204 | |
---|
205 | /** |
---|
206 | * @c mkisofs command to generate a bootable CD using LILO, except for -o option and the directory to image. |
---|
207 | */ |
---|
208 | #define MONDO_MKISOFS_REGULAR_LILO "mkisofs -boot-info-table -no-emul-boot -b isolinux.bin -c boot.cat -boot-load-size 4 -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_" |
---|
209 | |
---|
210 | /** |
---|
211 | * @c mkisofs command to generate a bootable CD using ELILO, except for -o option and the directory to image. |
---|
212 | */ |
---|
213 | // Should replace 8192 by IA64_BOOT_SIZE |
---|
214 | #define MONDO_MKISOFS_REGULAR_ELILO "mkisofs -no-emul-boot -b images/mindi-bootroot.8192.img -c boot.cat -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_" |
---|
215 | |
---|
216 | /** |
---|
217 | * The stub name of the temporary ISO image to create, burn, and remove. |
---|
218 | */ |
---|
219 | #define MONDO_TMPISOS "temporary.iso" |
---|
220 | |
---|
221 | /** |
---|
222 | * @c growisofs command to generate a bootable DVD using isolinux, except for the directory to image. |
---|
223 | */ |
---|
224 | #define MONDO_GROWISOFS_REGULAR_SYSLINUX "growisofs -use-the-force-luke -J -no-emul-boot -boot-load-size 4 -b isolinux.bin --boot-info-table -c boot.cat -boot-load-size 4 -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_ -v" |
---|
225 | |
---|
226 | /** |
---|
227 | * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image. |
---|
228 | */ |
---|
229 | #define MONDO_GROWISOFS_REGULAR_ELILO "growisofs -use-the-force-luke -no-emul-boot -b images/mindi-boot.2880.img -c boot.cat -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v" |
---|
230 | |
---|
231 | /** |
---|
232 | * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image. |
---|
233 | */ |
---|
234 | #define MONDO_GROWISOFS_REGULAR_LILO "growisofs -no-emul-boot -b isolinux.bin -c boot.cat -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v" |
---|
235 | |
---|
236 | /** |
---|
237 | * @c growisofs command to generate a nonbootable DVD, except for the directory to image. |
---|
238 | */ |
---|
239 | #define MONDO_GROWISOFS_NONBOOT "growisofs -use-the-force-luke -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v" |
---|
240 | |
---|
241 | /** |
---|
242 | * Welcome string displayed at the top of the newt interface. |
---|
243 | */ |
---|
244 | #define WELCOME_STRING "W E L C O M E T O M O N D O R E S C U E" |
---|
245 | |
---|
246 | /** |
---|
247 | * The maximum length of a filename in the tape catalog. |
---|
248 | */ |
---|
249 | #define MAX_TAPECAT_FNAME_LEN 32 |
---|
250 | |
---|
251 | //#define strcpy(y,x) strncpy(y, x, sizeof(y)-1) |
---|
252 | |
---|
253 | |
---|
254 | /** |
---|
255 | * Assert that (@p x != NULL) and (@p x[0] != '\\0'). |
---|
256 | */ |
---|
257 | #define assert_string_is_neither_NULL_nor_zerolength(x) {assert(x!=NULL);assert(x[0]!='\0');} |
---|
258 | |
---|
259 | /** |
---|
260 | * Log the file, line, Mondo error message, and OS error message (errno). |
---|
261 | */ |
---|
262 | #define log_OS_error(x) {log_msg(0, "%s (%s)", x, strerror(errno));} |
---|
263 | |
---|
264 | /** |
---|
265 | * Assert that (@p x != NULL). |
---|
266 | */ |
---|
267 | #define assert_pointer_is_not_NULL(x) {assert(x!=NULL);} |
---|
268 | |
---|
269 | /** |
---|
270 | * close() @p x and log a message if it fails. |
---|
271 | */ |
---|
272 | #define paranoid_close(x) {if(close(x)) {log_msg(5, "close err");} x=-999; } |
---|
273 | |
---|
274 | /** |
---|
275 | * fclose() @p x and log a message if it fails. |
---|
276 | */ |
---|
277 | #define paranoid_fclose(x) {if(fclose(x)) {log_msg(5, "fclose err");} x=NULL; } |
---|
278 | |
---|
279 | /** |
---|
280 | * pclose() @p x and log a message if it fails. |
---|
281 | */ |
---|
282 | #define paranoid_pclose(x) {if(pclose(x)) {log_msg(5, "pclose err");} x=NULL; } |
---|
283 | |
---|
284 | /** |
---|
285 | * Run the command @p x and log it if it fails. |
---|
286 | */ |
---|
287 | #define paranoid_system(x) {if(system(x)) log_msg(4, x); } |
---|
288 | |
---|
289 | /** |
---|
290 | * Free @p x and set it to NULL. |
---|
291 | */ |
---|
292 | #define paranoid_free(x) {if (x != NULL) free(x); x=NULL;} |
---|
293 | |
---|
294 | /** |
---|
295 | * Free variables and call finish(@p x). |
---|
296 | */ |
---|
297 | #define paranoid_MR_finish(x) {free_MR_global_filenames (); finish(x); } |
---|
298 | |
---|
299 | /** |
---|
300 | * Log file, function, line, and @p x. |
---|
301 | */ |
---|
302 | #define iamhere(x) {log_it("%s, %s, %ld: %s", __FILE__, __FUNCTION__, __LINE__, x);} |
---|
303 | |
---|
304 | /** |
---|
305 | * Yes, we want malloc() to help us fix bugs. |
---|
306 | */ |
---|
307 | #define MALLOC_CHECK_ 1 |
---|
308 | |
---|
309 | /** |
---|
310 | * Malloc @p x to be MAX_STR_LEN bytes and call fatal_error() if we're out of memory. |
---|
311 | */ |
---|
312 | #define malloc_string(x) { x = (char *)malloc(MAX_STR_LEN); if (!x) { fatal_error("Unable to malloc"); } x[0] = x[1] = '\0'; } |
---|
313 | |
---|
314 | /** |
---|
315 | * Path to the location the hard drive is mounted on during a restore. |
---|
316 | */ |
---|
317 | #define MNT_RESTORING "/mnt/RESTORING" |
---|
318 | |
---|
319 | /** @def VANILLA_SCSI_CDROM The first SCSI CD-ROM in the system (most likely to be the one to write to). */ |
---|
320 | /** @def VANILLA_SCSI_TAPE The first SCSI tape in the system (most likely to be the one towrite to. */ |
---|
321 | /** @def DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE A string whose presence in a device name indicates the |
---|
322 | * inability to check this device for errors in the mountlist. */ |
---|
323 | /** @def RAID_DEVICE_STUB The stub of a RAID device (set up RAID if we find it). */ |
---|
324 | /** @def SANE_FORMATS Sane formats for this OS, separated by spaces. */ |
---|
325 | /** @def ALT_TAPE The first IDE tape in the system. */ |
---|
326 | /** @def MKE2FS_OR_NEWFS @c mke2fs or @c newfs, depending on the OS. */ |
---|
327 | /** @def CP_BIN The GNU @c cp binary to use. */ |
---|
328 | #ifdef __FreeBSD__ |
---|
329 | #define VANILLA_SCSI_CDROM "/dev/cd0" |
---|
330 | #define VANILLA_SCSI_TAPE "/dev/sa0" |
---|
331 | #define VANILLA_USB_DEVICE "tobegivenbybsdguru" |
---|
332 | #define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/vinum/" |
---|
333 | #define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE |
---|
334 | #define SANE_FORMATS "swap image msdosfs nfs ntfs raid lvm ffs ufs ext2fs" |
---|
335 | #define ALT_TAPE "/dev/ast0" |
---|
336 | #define MKE2FS_OR_NEWFS "newfs" |
---|
337 | #define CP_BIN "gcp" |
---|
338 | #else |
---|
339 | #define VANILLA_SCSI_CDROM "/dev/scd0" |
---|
340 | #define VANILLA_SCSI_TAPE "/dev/st0" |
---|
341 | #define VANILLA_USB_DEVICE "/dev/hda" |
---|
342 | #define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/md" |
---|
343 | #define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE |
---|
344 | #define SANE_FORMATS "swap image vfat ext2 ext3 xfs vfs jfs reiserfs vmfs dos minix coda nfs ntfs hpfs raid lvm cifs" |
---|
345 | #define ALT_TAPE "/dev/ht0" |
---|
346 | #define MKE2FS_OR_NEWFS "mke2fs" |
---|
347 | #define CP_BIN "cp" |
---|
348 | #endif |
---|
349 | |
---|
350 | |
---|
351 | /** |
---|
352 | * The template for a filelist filename. |
---|
353 | * The first argument (%s) is the tempdir and the second (%d) is the filelist number. |
---|
354 | */ |
---|
355 | #define FILELIST_FNAME_RAW_SZ "%s/filelist.%ld" |
---|
356 | |
---|
357 | #define XATTR_LIST_FNAME_RAW_SZ "%s/xattr_list.%ld.gz" |
---|
358 | #define XATTR_BIGGLST_FNAME_RAW_SZ "%s/xattr_list.big.gz" |
---|
359 | #define ACL_LIST_FNAME_RAW_SZ "%s/acl_list.%ld.gz" |
---|
360 | #define ACL_BIGGLST_FNAME_RAW_SZ "%s/acl_list.big.gz" |
---|
361 | |
---|
362 | /** |
---|
363 | * The template for an afioball filename. |
---|
364 | * The first argument (%s) is the tempdir and the second (%d) is the filelist number. |
---|
365 | */ |
---|
366 | #define AFIOBALL_FNAME_RAW_SZ (bkpinfo->use_star)?"%s/tmpfs/%ld.star.%s":"%s/tmpfs/%ld.afio.%s" |
---|
367 | #define ARCH_THREADS 2 ///< The number of simultaneous threads running afio in the background. |
---|
368 | #define ARCH_BUFFER_NUM (ARCH_THREADS*4) // Number of permissible queued afio files |
---|
369 | #define FORTY_SPACES " " ///< 40 spaces. |
---|
370 | #define PPCFG_RAMDISK_SIZE 350 ///< Size of the tmpfs, in megabytes, to attempt to mount (to speed up Mondo). |
---|
371 | |
---|
372 | #define DO_MBR_PLEASE "/tmp/DO-MBR-PLEASE" |
---|
373 | |
---|
374 | |
---|
375 | /** |
---|
376 | * Compatibility define to change log_it() calls to log_debug_msg() calls. |
---|
377 | */ |
---|
378 | #define log_it(format, args...) log_debug_msg(2, __FILE__, __FUNCTION__, __LINE__, format, ## args) |
---|
379 | |
---|
380 | /** |
---|
381 | * Macro to log a message along with file, line, and function information. |
---|
382 | */ |
---|
383 | #define log_msg(level, format, args...) log_debug_msg(level, __FILE__, __FUNCTION__, __LINE__, format, ## args) |
---|
384 | |
---|
385 | #define DEFAULT_DVD_DISK_SIZE 4480 ///< The default size (in MB) of a DVD disk, unless the user says otherwise. |
---|
386 | |
---|
387 | #define DEFAULT_DEBUG_LEVEL 4 ///< By default, don't log messages with a loglevel higher than this. |
---|
388 | |
---|
389 | #define SZ_NTFSPROG_VOLSIZE "1048576" // was 4096 |
---|
390 | #define NTFSPROG_PARAMS "-z0 -V" SZ_NTFSPROG_VOLSIZE " -o -b -d -g1" |
---|
391 | |
---|
392 | #define MNT_CDROM "/mnt/cdrom" |
---|
393 | #define MNT_FLOPPY "/mnt/floppy" |
---|
394 | |
---|
395 | #define DEFAULT_MR_LOGLEVEL 4 |
---|
396 | |
---|
397 | #endif /* _MY_STUFF_H_ */ |
---|