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

Last change on this file since 1069 was 1069, checked in by Bruno Cornec, 13 years ago

resurrect NOOF_ERR_LINES

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