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

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

merge -r 542:560 $SVN_M/branches/stable

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