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

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

merge -r457:459 $SVN_M/branches/2.0.7

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