source: MondoRescue/branches/stable/mondo/mondo/common/my-stuff.h@ 538

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

Begining of modifications => DOS NOT WORK FOR NOW.
This is done to be merged in trunk. stable will later point back to current 2.0.8 content

Use of mindi conf file in mindi + /var/cache/mindi as a default place
Use of mondo conf file in mondo + separation of messages.
Ultimate goal is to have a cleaner design of files vs functions.

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