source: MondoRescue/trunk/mondo/mondo/common/my-stuff.h@ 130

Last change on this file since 130 was 127, checked in by bcornec, 18 years ago

merge -r 125:126 $SVN_M/branches/2.05

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