source: MondoRescue/branches/stable/mondo/src/include/my-stuff.h

Last change on this file was 1939, checked in by Bruno Cornec, 12 years ago

svn merge -r 1923:1938 $SVN_M/branches/2.2.6

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 23.1 KB
Line 
1/*
2 * Common defines across the project
3 *
4 *  $Id: my-stuff.h 1939 2008-05-16 23:29:54Z bruno $
5 */
6
7#ifndef _MY_STUFF_H_
8#define _MY_STUFF_H_
9
10// Extra info for ACLs and SELINUX users
11#define STAR_ACL_SZ "-xfflags -acl"
12
13/*The number of lines of log output to keep at the bottom of the screen.*/
14#define NOOF_ERR_LINES  6   
15
16/* Hardcoded: Bad for the moment */
17#define MONDO_CACHE "/var/cache/mondo"
18#define MINDI_CACHE "/var/cache/mindi"
19#define MONDORESTORECFG MONDO_CACHE"/mondo-restore.cfg"
20
21/**
22 * The mondo-restore.cfg stub (appended to the directory where all.tar.gz was unpacked).
23 */
24#define MONDO_CFG_FILE_STUB "./tmp/mondo-restore.cfg"
25
26/**
27 * @file
28 * The main header file for Mondo.
29 */
30
31#include <stdio.h>
32#include "mr_mem.h"
33#include "mr_msg.h"
34#include "mr_types.h"
35
36#ifdef HAVE_CONFIG_H
37#include <config.h>
38#endif
39/* BERLIOS
40 * Useful ?
41*/
42
43#ifndef __FreeBSD__
44#include <getopt.h>
45#endif
46
47#include <sys/types.h>
48#include <sys/shm.h>
49#include <sys/ipc.h>
50#include <sys/ioctl.h>
51#include <sys/sem.h>
52#include <sys/param.h>
53
54#include <stdlib.h>
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 <newt.h>
67#include <ctype.h>
68#include <string.h>
69#ifndef S_SPLINT_S
70#include <pthread.h>
71#endif
72#include <assert.h>
73
74/**
75 * The biggielist stub (appended to the directory where all.tar.gz was unpacked).
76 */
77#define BIGGIELIST_TXT_STUB "./tmp/biggielist.txt"
78
79/**
80 * The filelist stub (appended to the directory where all.tar.gz was unpacked).
81 */
82#define FILELIST_FULL_STUB "./tmp/filelist.full.gz"
83
84/**
85 * The mountlist stub (appended to the directory where all.tar.gz was unpacked).
86 */
87#define MOUNTLIST_FNAME_STUB "./tmp/mountlist.txt"
88
89/**
90 * The mondo-restore.cfg stub (appended to the directory where all.tar.gz was unpacked).
91 */
92#define MONDO_CFG_FILE_STUB "./tmp/mondo-restore.cfg"
93
94/**
95 * The location where mondo changed info are stored.
96 */
97#define MONDO_CACHE "/var/cache/mondo"
98
99/**
100 * The RAID kernel proc file
101 */
102#define MDSTAT_FILE "/proc/mdstat"
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#   ifndef S_SPLINT_S
116#       define assert(exp) ((exp)?((void)0):_mondo_assert_fail(__FILE__, __FUNCTION__, __LINE__, #exp))
117#   else
118#       define assert(exp) ((void)0)
119#   endif
120#endif
121
122#define CRC_M16 0xA001          ///< Mask for crc16.
123#define CRC_MTT 0x1021          ///< Mask for crc-ccitt.
124
125#define SCREEN_LENGTH 25        ///< The default size of the screen.
126#define ARBITRARY_MAXIMUM 2000  ///< The maximum number of items showing at once in the mountlist or filelist editor.
127#define MAX_TAPECATALOG_ENTRIES 8192    ///< The maximum number of entries in the tape catalog.
128#define MAX_STR_LEN 384         ///< The maximum length of almost all @p char buffers in Mondo.
129                                        ///  Note: Make this divisible by eight to avoid aligment issues
130                                        ///        on 64bit platforms like ia64.
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/**
159 * Determine whether @p x (t_bkptype) is a streaming backup.
160 */
161#define IS_THIS_A_STREAMING_BACKUP(x) (x == tape || x == udev || x == cdstream)
162
163/**
164 * The stub name of the temporary ISO image to create, burn, and remove.
165 */
166#define MONDO_TMPISOS "temporary.iso"
167
168/**
169 * Assert that (@p x != NULL) and (@p x[0] != '\\0').
170 */
171#define assert_string_is_neither_NULL_nor_zerolength(x) {assert(x!=NULL);assert(x[0]!='\0');}
172
173/**
174 * Log the file, line, Mondo error message, and OS error message (errno).
175 */
176#define log_OS_error(x) {mr_msg(1, "%s, (%s)", x, strerror(errno));}
177
178/**
179 * Assert that (@p x != NULL).
180 */
181#define assert_pointer_is_not_NULL(x) {assert(x!=NULL);}
182
183/**
184 * close() @p x and log a message if it fails.
185 */
186#define paranoid_close(x) {if(close(x)) {mr_msg(5, "close err");} x=-999; }
187
188/**
189 * fclose() @p x and log a message if it fails.
190 */
191#define paranoid_fclose(x) {if(fclose(x)) {mr_msg(5, "fclose err");} x=NULL; }
192
193/**
194 * pclose() @p x and log a message if it fails.
195 */
196#define paranoid_pclose(x) {if(pclose(x)) {mr_msg(5, "pclose err");} x=NULL; }
197
198/**
199 * Run the command @p x and log it if it fails.
200 */
201#define paranoid_system(x) {if(system(x)) mr_msg(4, x); }
202
203/**
204 * Free variables and call finish(@p x).
205 */
206#define paranoid_MR_finish(x) {free_MR_global_filenames (); finish(x); }
207
208/**
209 * Log file, function, line, and @p x.
210 */
211#define iamhere(x) {mr_msg(2, x);}
212
213/**
214 * Yes, we want malloc() to help us fix bugs.
215 */
216#define MALLOC_CHECK_ 1
217
218/**
219 * Malloc @p x to be MAX_STR_LEN bytes and call fatal_error() if we're out of memory.
220 */
221#define malloc_string(x) { x = (char *)mr_malloc(MAX_STR_LEN); x[0] = x[1] = '\0'; }
222
223/**
224 * Path to the location the hard drive is mounted on during a restore.
225 */
226#define MNT_RESTORING "/mnt/RESTORING"
227
228/** @def VANILLA_SCSI_TAPE  The SCSI tape radical on the system (most likely to be the one towrite to. */
229/** @def DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE A string whose presence in a device name indicates the
230 * inability to check this device for errors in the mountlist. */
231/** @def RAID_DEVICE_STUB The stub of a RAID device (set up RAID if we find it). */
232/** @def SANE_FORMATS Sane formats for this OS, separated by spaces. */
233/** @def ALT_TAPE The first IDE tape in the system. */
234/** @def MKE2FS_OR_NEWFS @c mke2fs or @c newfs, depending on the OS. */
235/** @def CP_BIN The GNU @c cp binary to use. */
236#ifdef __FreeBSD__
237#define VANILLA_SCSI_TAPE   "/dev/sa"
238#define VANILLA_USB_DEVICE  "tobegivenbybsdguru"
239#define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE  "/dev/vinum/"
240#define RAID_DEVICE_STUB    DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE
241#define SANE_FORMATS        "swap image msdosfs nfs ntfs raid lvm ffs ufs ext2fs"
242#define ALT_TAPE        "/dev/ast"
243#define MKE2FS_OR_NEWFS "newfs"
244#define CP_BIN      "gcp"
245#else
246#define VANILLA_SCSI_TAPE   "/dev/st0"
247#define VANILLA_USB_DEVICE  "/dev/hda"
248#define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE  "/dev/md"
249#define RAID_DEVICE_STUB    DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE
250#define SANE_FORMATS        "swap image vfat ext2 ext3 xfs vfs jfs reiserfs dos minix coda nfs ntfs hpfs raid lvm cifs"
251#define ALT_TAPE        "/dev/ht0"
252#define MKE2FS_OR_NEWFS "mke2fs"
253#define CP_BIN      "cp"
254#endif
255
256
257/**
258 * The template for a filelist filename.
259 * The first argument (%s) is the tempdir and the second (%d) is the filelist number.
260 */
261#define FILELIST_FNAME_RAW_SZ "%s/filelist.%ld"
262
263#define XATTR_LIST_FNAME_RAW_SZ      "%s/xattr_list.%ld.gz"
264#define XATTR_BIGGLST_FNAME_RAW_SZ   "%s/xattr_list.big.gz"
265#define ACL_LIST_FNAME_RAW_SZ        "%s/acl_list.%ld.gz"
266#define ACL_BIGGLST_FNAME_RAW_SZ     "%s/acl_list.big.gz"
267
268/**
269 * The template for an afioball filename.
270 * The first argument (%s) is the tempdir and the second (%d) is the filelist number.
271 */
272#define AFIOBALL_FNAME_RAW_SZ (bkpinfo->use_star)?"%s/tmpfs/%ld.star.%s":"%s/tmpfs/%ld.afio.%s"
273#define ARCH_THREADS 2          ///< The number of simultaneous threads running afio in the background.
274#define ARCH_BUFFER_NUM (ARCH_THREADS*4)    // Number of permissible queued afio files
275#define PPCFG_RAMDISK_SIZE 350  ///< Size of the tmpfs, in megabytes, to attempt to mount (to speed up Mondo).
276
277/**
278 * Shorter log command
279 */
280#define log_it(format, args...) mr_msg(2, format, ## args)
281
282#define SZ_NTFSPROG_VOLSIZE "1048576"   // was 4096
283#define NTFSPROG_PARAMS "-z0 -V" SZ_NTFSPROG_VOLSIZE " -o -b -d -g1"
284
285#define MNT_CDROM "/mnt/cdrom"
286
287#endif                          /* _MY_STUFF_H_ */
288=======
289/* my-stuff.h
290   $Id: my-stuff.h 1939 2008-05-16 23:29:54Z bruno $
291*/
292
293#define HAVE_MALLOC 1
294
295
296// Extra info for ACLs and SELINUX users
297#define STAR_ACL_SZ "-xfflags -acl"
298//#define STAR_ACL_SZ "-xfflags"
299//#define STAR_ACL_SZ ""
300// Enable the first line and disable the second if you are a Fedora Core 2 user
301
302/**
303 * @file
304 * The main header file for Mondo.
305 */
306
307#if !defined(bool) && !defined(__cplusplus)
308/**
309 * Create the illusion of a Boolean type.
310 */
311#define bool int
312#define TRUE 1
313#define FALSE 0
314#endif
315
316#ifndef _MY_STUFF_H_
317#define _MY_STUFF_H_
318
319#ifdef HAVE_CONFIG_H
320#include <config.h>
321#endif
322
323#ifndef __FreeBSD__
324#include <getopt.h>
325#endif
326#include <sys/types.h>
327#include <sys/shm.h>
328#include <sys/ipc.h>
329#include <sys/ioctl.h>
330#include <sys/sem.h>
331#include <sys/param.h>
332#include <stdio.h>
333#include <stdlib.h>
334#ifndef  __USE_FILE_OFFSET64
335#define  __USE_FILE_OFFSET64
336#endif
337#ifndef  __USE_LARGEFILE64
338#define  __USE_LARGEFILE64
339#endif
340#include <sys/stat.h>
341#include <fcntl.h>
342#include <errno.h>
343#include <stddef.h>
344#include <sys/stat.h>
345#include <sys/wait.h>
346#include <time.h>
347#include <unistd.h>
348#include <signal.h>
349//#include <curses.h>
350#include <newt.h>
351#include <ctype.h>
352#include <string.h>
353#include <pthread.h>
354#include <assert.h>
355
356#if defined(DEBUG) && !__cplusplus
357int count;
358char trace_log[255];            /*buffer for logging */
359char *trace_log_ptr;
360#endif                          /* DEBUG */
361
362#define IA64_BOOT_SIZE "16384"  /* Should be coherent with mindi */
363#define STD_PREFIX "mondorescue"    /* Should be coherent with mindi */
364
365/**
366 * The biggielist stub (appended to the directory where all.tar.gz was unpacked).
367 */
368#define BIGGIELIST_TXT_STUB "./tmp/biggielist.txt"
369
370/**
371 * The filelist stub (appended to the directory where all.tar.gz was unpacked).
372 */
373#define FILELIST_FULL_STUB "./tmp/filelist.full.gz"
374
375/**
376 * The mountlist stub (appended to the directory where all.tar.gz was unpacked).
377 */
378#define MOUNTLIST_FNAME_STUB "./tmp/mountlist.txt"
379
380/**
381 * The mondo-restore.cfg stub (appended to the directory where all.tar.gz was unpacked).
382 */
383#define MONDO_CFG_FILE_STUB "./tmp/mondo-restore.cfg"
384/**
385 * The location where mindi media images are stored.
386 */
387#define MINDI_CACHE "/var/cache/mindi"
388
389/**
390 * The location where mondo changed info are stored.
391 */
392#define MONDO_CACHE "/var/cache/mondo"
393
394/**
395 * The RAID kernel proc file
396 */
397#define MDSTAT_FILE "/proc/mdstat"
398
399/**
400 * @bug Apparently unused.
401 */
402#define MONDO_TRACEFILE "/var/log/mondo-tracefile.log"
403
404#undef assert
405
406extern void _mondo_assert_fail(const char *file, const char *function,
407                               int line, const char *exp);
408
409/**
410 * An assert macro that calls _mondo_assert_fail() when it fails.
411 */
412#ifdef NDEBUG
413#define assert(exp) ((void)0)
414#else
415#define assert(exp) ((exp)?((void)0):_mondo_assert_fail(__FILE__, __FUNCTION__, __LINE__, #exp))
416#endif
417
418#define CRC_M16 0xA001          ///< Mask for crc16.
419#define CRC_MTT 0x1021          ///< Mask for crc-ccitt.
420
421#define FALSE 0                 ///< The ubiquitous FALSE macro.
422#define TRUE 1                  ///< The even more ubiquitous TRUE macro.
423
424#define SCREEN_LENGTH 25        ///< The default size of the screen.
425#define NOOF_ERR_LINES 6        ///< The number of lines of log output to keep at the bottom of the screen.
426#define ARBITRARY_MAXIMUM 2000  ///< The maximum number of items showing at once in the mountlist or filelist editor.
427#define MAX_TAPECATALOG_ENTRIES 8192    ///< The maximum number of entries in the tape catalog.
428#define MAX_STR_LEN 384         ///< The maximum length of almost all @p char buffers in Mondo.
429                                        ///  Note: Make this divisible by eight to avoid aligment issues
430                                        ///        on 64bit platforms like ia64.
431#define MAXIMUM_RAID_DEVS 32    ///< The maximum number of RAID devices in the raidlist.
432#define MAXIMUM_ADDITIONAL_RAID_VARS 32 ///< The maximum number of additional RAID variables per RAID device in the raidlist.
433#define MAXIMUM_DISKS_PER_RAID_DEV 32   ///< The maximum number of disks per RAID device in the raidtab.
434
435#define RAIDTAB_FNAME "/etc/raidtab"    ///< The filename of the raidtab file, at least on Linux.
436
437#define BLK_START_OF_BACKUP     1   ///< Marker block: start a backup.
438#define BLK_START_OF_TAPE       2   ///< Marker block: start a tape.
439#define BLK_START_AFIOBALLS 10  ///< Marker block: start the afioball section.
440#define BLK_STOP_AFIOBALLS  19  ///< Marker block: stop the afioball section.
441#define BLK_START_AN_AFIO_OR_SLICE      20  ///< Marker block: start an afioball or a slice.
442#define BLK_STOP_AN_AFIO_OR_SLICE   29  ///< Marker block: stop an afioball or a slice.
443#define BLK_START_BIGGIEFILES   30  ///< Marker block: start the biggiefile section.
444#define BLK_STOP_BIGGIEFILES    39  ///< Marker block: stop the biggiefile section.
445#define BLK_START_A_NORMBIGGIE  40  ///< Marker block: start a normal biggiefile.
446#define BLK_START_A_PIHBIGGIE   41  ///< Marker block: start a ntfsprog'd biggiefile
447#define BLK_START_EXTENDED_ATTRIBUTES 45    ///< Marker block: start xattr/acl info
448#define BLK_STOP_EXTENDED_ATTRIBUTES 46 ///< Marker block: stop xattr/acl info
449#define BLK_START_EXAT_FILE     47
450#define BLK_STOP_EXAT_FILE      48
451#define BLK_STOP_A_BIGGIE   59  ///< Marker block: stop a biggiefile.
452#define BLK_START_FILE          80  ///< Marker block: start a file (non-afio or slice).
453#define BLK_STOP_FILE           89  ///< Marker block: stop a file (non-afio or slice).
454#define BLK_END_OF_TAPE         100 ///< Marker block: end of tape.
455#define BLK_END_OF_BACKUP       101 ///< Marker block: end of backup.
456#define BLK_ABORTED_BACKUP      102 ///< Marker block: backup was aborted.
457
458/// The external tape blocksize.
459#ifdef EXTTAPE
460#define TAPE_BLOCK_SIZE (long)EXTTAPE
461#else
462#define TAPE_BLOCK_SIZE 131072L /* was 8192; 06/2002-->65536; 11/2002-->131072 */
463#endif
464
465#define DEFAULT_INTERNAL_TAPE_BLOCK_SIZE 32768  // Nov 2003?
466
467
468
469
470#define SLICE_SIZE 4096         ///< The size of a slice of a biggiefile.
471
472
473
474
475
476
477/**
478 * Determine whether @p x (t_bkptype) is a streaming backup.
479 */
480#define IS_THIS_A_STREAMING_BACKUP(x) (x == tape || x == udev || x == cdstream)
481
482
483/**
484 * @c mkisofs command to generate a nonbootable CD, except for -o option and the directory to image.
485 */
486#define MONDO_MKISOFS_NONBOOT   "mkisofs -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_"
487
488/**
489 * @c mkisofs command to generate a bootable CD using isolinux, except for -o option and the directory to image.
490 */
491#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#_"
492
493/**
494 * @c mkisofs command to generate a bootable CD using LILO, except for -o option and the directory to image.
495 */
496#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#_"
497
498/**
499 * @c mkisofs command to generate a bootable CD using ELILO, except for -o option and the directory to image.
500 */
501// Should replace 8192 by IA64_BOOT_SIZE
502#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#_"
503
504/**
505 * The stub name of the temporary ISO image to create, burn, and remove.
506 */
507#define MONDO_TMPISOS "temporary.iso"
508
509/**
510 * @c growisofs command to generate a bootable DVD using isolinux, except for the directory to image.
511 */
512#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"
513
514/**
515 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image.
516     */
517#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"
518
519/**
520 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image.
521     */
522#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"
523
524/**
525 * @c growisofs command to generate a nonbootable DVD, except for the directory to image.
526 */
527#define MONDO_GROWISOFS_NONBOOT          "growisofs -use-the-force-luke -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v"
528
529/**
530 * Welcome string displayed at the top of the newt interface.
531 */
532#define WELCOME_STRING "W E L C O M E   T O   M O N D O   R E S C U E"
533
534/**
535 * The maximum length of a filename in the tape catalog.
536 */
537#define MAX_TAPECAT_FNAME_LEN 32
538
539//#define strcpy(y,x) strncpy(y, x, sizeof(y)-1)
540
541
542/**
543 * Assert that (@p x != NULL) and (@p x[0] != '\\0').
544 */
545#define assert_string_is_neither_NULL_nor_zerolength(x) {assert(x!=NULL);assert(x[0]!='\0');}
546
547/**
548 * Log the file, line, Mondo error message, and OS error message (errno).
549 */
550#define log_OS_error(x) {log_msg(0, "%s (%s)", x, strerror(errno));}
551
552/**
553 * Assert that (@p x != NULL).
554 */
555#define assert_pointer_is_not_NULL(x) {assert(x!=NULL);}
556
557/**
558 * close() @p x and log a message if it fails.
559 */
560#define paranoid_close(x) {if(close(x)) {log_msg(5, "close err");} x=-999; }
561
562/**
563 * fclose() @p x and log a message if it fails.
564 */
565#define paranoid_fclose(x) {if(fclose(x)) {log_msg(5, "fclose err");} x=NULL; }
566
567/**
568 * pclose() @p x and log a message if it fails.
569 */
570#define paranoid_pclose(x) {if(pclose(x)) {log_msg(5, "pclose err");} x=NULL; }
571
572/**
573 * Run the command @p x and log it if it fails.
574 */
575#define paranoid_system(x) {if(system(x)) log_msg(4, x); }
576
577/**
578 * Free @p x and set it to NULL.
579 */
580#define paranoid_free(x) {if (x != NULL) free(x); x=NULL;}
581
582/**
583 * Free variables and call finish(@p x).
584 */
585#define paranoid_MR_finish(x) {free_MR_global_filenames (); finish(x); }
586
587/**
588 * Log file, function, line, and @p x.
589 */
590#define iamhere(x) {log_it("%s, %s, %ld: %s", __FILE__, __FUNCTION__, __LINE__, x);}
591
592/**
593 * Yes, we want malloc() to help us fix bugs.
594 */
595#define MALLOC_CHECK_ 1
596
597/**
598 * Malloc @p x to be MAX_STR_LEN bytes and call fatal_error() if we're out of memory.
599 */
600#define malloc_string(x) { x = (char *)malloc(MAX_STR_LEN); if (!x) { fatal_error("Unable to malloc"); } x[0] = x[1] = '\0'; }
601
602/**
603 * Path to the location the hard drive is mounted on during a restore.
604 */
605#define MNT_RESTORING "/mnt/RESTORING"
606
607/** @def VANILLA_SCSI_CDROM The first SCSI CD-ROM in the system (most likely to be the one to write to). */
608/** @def VANILLA_SCSI_TAPE  The first SCSI tape in the system (most likely to be the one towrite to. */
609/** @def DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE A string whose presence in a device name indicates the
610 * inability to check this device for errors in the mountlist. */
611/** @def RAID_DEVICE_STUB The stub of a RAID device (set up RAID if we find it). */
612/** @def SANE_FORMATS Sane formats for this OS, separated by spaces. */
613/** @def ALT_TAPE The first IDE tape in the system. */
614/** @def MKE2FS_OR_NEWFS @c mke2fs or @c newfs, depending on the OS. */
615/** @def CP_BIN The GNU @c cp binary to use. */
616#ifdef __FreeBSD__
617#define VANILLA_SCSI_CDROM  "/dev/cd0"
618#define VANILLA_SCSI_TAPE   "/dev/sa0"
619#define VANILLA_USB_DEVICE  "tobegivenbybsdguru"
620#define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE  "/dev/vinum/"
621#define RAID_DEVICE_STUB    DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE
622#define SANE_FORMATS        "swap image msdosfs nfs ntfs raid lvm ffs ufs ext2fs"
623#define ALT_TAPE        "/dev/ast0"
624#define MKE2FS_OR_NEWFS "newfs"
625#define CP_BIN      "gcp"
626#else
627#define VANILLA_SCSI_CDROM  "/dev/scd0"
628#define VANILLA_SCSI_TAPE   "/dev/st0"
629#define VANILLA_USB_DEVICE  "/dev/hda"
630#define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE  "/dev/md"
631#define RAID_DEVICE_STUB    DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE
632#define SANE_FORMATS        "swap image vfat ext2 ext3 xfs vfs jfs reiserfs vmfs dos minix coda nfs ntfs hpfs raid lvm cifs"
633#define ALT_TAPE        "/dev/ht0"
634#define MKE2FS_OR_NEWFS "mke2fs"
635#define CP_BIN      "cp"
636#endif
637
638
639/**
640 * The template for a filelist filename.
641 * The first argument (%s) is the tempdir and the second (%d) is the filelist number.
642 */
643#define FILELIST_FNAME_RAW_SZ "%s/filelist.%ld"
644
645#define XATTR_LIST_FNAME_RAW_SZ      "%s/xattr_list.%ld.gz"
646#define XATTR_BIGGLST_FNAME_RAW_SZ   "%s/xattr_list.big.gz"
647#define ACL_LIST_FNAME_RAW_SZ        "%s/acl_list.%ld.gz"
648#define ACL_BIGGLST_FNAME_RAW_SZ     "%s/acl_list.big.gz"
649
650/**
651 * The template for an afioball filename.
652 * The first argument (%s) is the tempdir and the second (%d) is the filelist number.
653 */
654#define AFIOBALL_FNAME_RAW_SZ (bkpinfo->use_star)?"%s/tmpfs/%ld.star.%s":"%s/tmpfs/%ld.afio.%s"
655#define ARCH_THREADS 2          ///< The number of simultaneous threads running afio in the background.
656#define ARCH_BUFFER_NUM (ARCH_THREADS*4)    // Number of permissible queued afio files
657#define FORTY_SPACES "                                         "    ///< 40 spaces.
658#define PPCFG_RAMDISK_SIZE 350  ///< Size of the tmpfs, in megabytes, to attempt to mount (to speed up Mondo).
659
660#define DO_MBR_PLEASE "/tmp/DO-MBR-PLEASE"
661
662
663/**
664 * Compatibility define to change log_it() calls to log_debug_msg() calls.
665 */
666#define log_it(format, args...) log_debug_msg(2, __FILE__, __FUNCTION__, __LINE__, format, ## args)
667
668/**
669 * Macro to log a message along with file, line, and function information.
670 */
671#define log_msg(level, format, args...) log_debug_msg(level, __FILE__, __FUNCTION__, __LINE__, format, ## args)
672
673#define DEFAULT_DVD_DISK_SIZE 4480  ///< The default size (in MB) of a DVD disk, unless the user says otherwise.
674
675#define DEFAULT_DEBUG_LEVEL 4   ///< By default, don't log messages with a loglevel higher than this.
676
677#define SZ_NTFSPROG_VOLSIZE "1048576"   // was 4096
678#define NTFSPROG_PARAMS "-z0 -V" SZ_NTFSPROG_VOLSIZE " -o -b -d -g1"
679
680#define MNT_CDROM "/mnt/cdrom"
681#define MNT_FLOPPY "/mnt/floppy"
682
683#define DEFAULT_MR_LOGLEVEL 4
684
685#endif                          /* _MY_STUFF_H_ */
Note: See TracBrowser for help on using the repository browser.