source: trunk/mondo/src/include/my-stuff.h @ 1106

Last change on this file since 1106 was 1106, checked in by bruno, 13 years ago

merge -r1082:1105 $SVN_M/branches/stable

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