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

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