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

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