source: MondoRescue/branches/2.2.10/mondo/src/include/my-stuff.h@ 2462

Last change on this file since 2462 was 2462, checked in by Bruno Cornec, 15 years ago

r3548@localhost: bruno | 2009-10-16 19:18:27 +0200

  • mindi now boots in a QEMU VM without busybox
  • mindi is now noarch as a consequence
  • MINDI_LIB becomes MINDI_DATA for coherency and as a consequence
  • CACHEDIR becomes MINDI_CACHE for coherency and it's a build parameter and not hardcoded anymore in mindi
  • THat variable is also used at restore time for mondorestore.cfg e.g.
  • FAILSAFE kernel is gone. Just use another kernel of your choice. Most std kernels work anyway
  • TurnTgzIntoRdz rewritten and now really computes data disk size and not suppose its size
  • Interface mondo/mindi changed again => incompatible
  • Non-bootable media not supported anymore.
  • Mondorescue adapted to these changes but not tested yet
  • Doc updated as well
  • Property svn:keywords set to Id
File size: 13.0 KB
Line 
1/* my-stuff.h
2 $Id: my-stuff.h 2462 2009-10-20 14:07:00Z bruno $
3*/
4
5#define HAVE_MALLOC 1
6
7
8// Extra info for ACLs and SELINUX users
9#define STAR_ACL_SZ "-xattr -acl"
10
11/**
12 * @file
13 * The main header file for Mondo.
14 */
15
16#if !defined(bool) && !defined(__cplusplus)
17/**
18 * Create the illusion of a Boolean type.
19 */
20#define bool int
21#define TRUE 1
22#define FALSE 0
23#endif
24
25#ifndef _MY_STUFF_H_
26#define _MY_STUFF_H_
27
28#ifdef HAVE_CONFIG_H
29#include <config.h>
30#endif
31
32#ifndef __FreeBSD__
33#include <getopt.h>
34#endif
35#include <sys/types.h>
36#include <sys/ipc.h>
37#include <sys/ioctl.h>
38#include <sys/sem.h>
39#include <sys/param.h>
40#include <stdio.h>
41#include <stdlib.h>
42#ifndef __USE_FILE_OFFSET64
43#define __USE_FILE_OFFSET64
44#endif
45#ifndef __USE_LARGEFILE64
46#define __USE_LARGEFILE64
47#endif
48#include <sys/stat.h>
49#include <fcntl.h>
50#include <errno.h>
51#include <stddef.h>
52#include <sys/stat.h>
53#include <sys/wait.h>
54#include <time.h>
55#include <unistd.h>
56#include <signal.h>
57//#include <curses.h>
58#include <newt.h>
59#include <ctype.h>
60#include <string.h>
61#include <pthread.h>
62#include <assert.h>
63
64#if defined(DEBUG) && !__cplusplus
65int count;
66char trace_log[255]; /*buffer for logging */
67char *trace_log_ptr;
68#endif /* DEBUG */
69
70#define IA64_BOOT_SIZE "16384" /* Should be coherent with mindi */
71#define STD_PREFIX "mondorescue" /* Should be coherent with mindi */
72
73/**
74 * The location where mindi media images are stored.
75 */
76#define MINDI_CACHE_REL "var/cache/mindi" /* Should be coherent with mindi */
77#define MINDI_CACHE "/"MINDI_CACHE_REL
78
79/**
80 * The location where mondo changed info are stored.
81 */
82#define MONDO_CACHE "/var/cache/mondo"
83
84/**
85 * The RAID kernel proc file
86 */
87#define MDSTAT_FILE "/proc/mdstat"
88
89/**
90 * @bug Apparently unused.
91 */
92#define MONDO_TRACEFILE "/var/log/mondo-tracefile.log"
93
94#ifdef __FreeBSD__
95#define CMDLINE "/tmp/cmdline"
96#else
97// Default Linux
98#define CMDLINE "/proc/cmdline"
99#endif
100
101#undef assert
102
103extern void _mondo_assert_fail(const char *file, const char *function,
104 int line, const char *exp);
105
106/**
107 * An assert macro that calls _mondo_assert_fail() when it fails.
108 */
109#ifdef NDEBUG
110#define assert(exp) ((void)0)
111#else
112#define assert(exp) ((exp)?((void)0):_mondo_assert_fail(__FILE__, __FUNCTION__, __LINE__, #exp))
113#endif
114
115#define CRC_M16 0xA001 ///< Mask for crc16.
116#define CRC_MTT 0x1021 ///< Mask for crc-ccitt.
117
118#define FALSE 0 ///< The ubiquitous FALSE macro.
119#define TRUE 1 ///< The even more ubiquitous TRUE macro.
120
121#define SCREEN_LENGTH 25 ///< The default size of the screen.
122#define NOOF_ERR_LINES 6 ///< The number of lines of log output to keep at the bottom of the screen.
123#define ARBITRARY_MAXIMUM 2000 ///< The maximum number of items showing at once in the mountlist or filelist editor.
124#define MAX_TAPECATALOG_ENTRIES 16384 ///< The maximum number of entries in the tape catalog.
125#define MAX_MOUNTLIST_ENTRIES 8192 ///< The maximum number of entries in the mountlist.
126#define MAX_STR_LEN 384 ///< The maximum length of almost all @p char buffers in Mondo.
127 /// Note: Make this divisible by eight to avoid aligment issues
128 /// on 64bit platforms like ia64.
129#define MAXIMUM_RAID_DEVS 32 ///< The maximum number of RAID devices in the raidlist.
130#define MAXIMUM_ADDITIONAL_RAID_VARS 32 ///< The maximum number of additional RAID variables per RAID device in the raidlist.
131#define MAXIMUM_DISKS_PER_RAID_DEV 1024 ///< The maximum number of disks per RAID device in the raidtab.
132
133#define RAIDTAB_FNAME "/etc/raidtab" ///< The filename of the raidtab file, at least on Linux.
134
135#define BLK_START_OF_BACKUP 1 ///< Marker block: start a backup.
136#define BLK_START_OF_TAPE 2 ///< Marker block: start a tape.
137#define BLK_START_AFIOBALLS 10 ///< Marker block: start the afioball section.
138#define BLK_STOP_AFIOBALLS 19 ///< Marker block: stop the afioball section.
139#define BLK_START_AN_AFIO_OR_SLICE 20 ///< Marker block: start an afioball or a slice.
140#define BLK_STOP_AN_AFIO_OR_SLICE 29 ///< Marker block: stop an afioball or a slice.
141#define BLK_START_BIGGIEFILES 30 ///< Marker block: start the biggiefile section.
142#define BLK_STOP_BIGGIEFILES 39 ///< Marker block: stop the biggiefile section.
143#define BLK_START_A_NORMBIGGIE 40 ///< Marker block: start a normal biggiefile.
144#define BLK_START_A_PIHBIGGIE 41 ///< Marker block: start a ntfsprog'd biggiefile
145#define BLK_START_EXTENDED_ATTRIBUTES 45 ///< Marker block: start xattr/acl info
146#define BLK_STOP_EXTENDED_ATTRIBUTES 46 ///< Marker block: stop xattr/acl info
147#define BLK_START_EXAT_FILE 47
148#define BLK_STOP_EXAT_FILE 48
149#define BLK_STOP_A_BIGGIE 59 ///< Marker block: stop a biggiefile.
150#define BLK_START_FILE 80 ///< Marker block: start a file (non-afio or slice).
151#define BLK_STOP_FILE 89 ///< Marker block: stop a file (non-afio or slice).
152#define BLK_END_OF_TAPE 100 ///< Marker block: end of tape.
153#define BLK_END_OF_BACKUP 101 ///< Marker block: end of backup.
154#define BLK_ABORTED_BACKUP 102 ///< Marker block: backup was aborted.
155
156/// The external tape blocksize.
157#ifdef EXTTAPE
158#define TAPE_BLOCK_SIZE (long)EXTTAPE
159#else
160#define TAPE_BLOCK_SIZE 131072L /* was 8192; 06/2002-->65536; 11/2002-->131072 */
161#endif
162
163#define DEFAULT_INTERNAL_TAPE_BLOCK_SIZE 32768 // Nov 2003?
164
165
166
167
168#define SLICE_SIZE 4096 ///< The size of a slice of a biggiefile.
169
170
171
172
173
174
175/**
176 * Determine whether @p x (t_bkptype) is a streaming backup.
177 */
178#define IS_THIS_A_STREAMING_BACKUP(x) (x == tape || x == udev || x == cdstream)
179
180
181/**
182 * @c mkisofs command to generate a nonbootable CD, except for -o option and the directory to image.
183 */
184#define MONDO_MKISOFS_NONBOOT "mkisofs -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_"
185
186/**
187 * @c mkisofs command to generate a bootable CD using isolinux, except for -o option and the directory to image.
188 */
189#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#_"
190
191/**
192 * @c mkisofs command to generate a bootable CD using LILO, except for -o option and the directory to image.
193 */
194#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#_"
195
196/**
197 * @c mkisofs command to generate a bootable CD using ELILO, except for -o option and the directory to image.
198 */
199// Should replace 8192 by IA64_BOOT_SIZE
200#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#_"
201
202/**
203 * The stub name of the temporary ISO image to create, burn, and remove.
204 */
205#define MONDO_TMPISOS "temporary.iso"
206
207/**
208 * @c growisofs command to generate a bootable DVD using isolinux, except for the directory to image.
209 */
210#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"
211
212/**
213 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image.
214 */
215#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"
216
217/**
218 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image.
219 */
220#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"
221
222/**
223 * @c growisofs command to generate a nonbootable DVD, except for the directory to image.
224 */
225#define MONDO_GROWISOFS_NONBOOT "growisofs -use-the-force-luke -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v"
226
227/**
228 * Welcome string displayed at the top of the newt interface.
229 */
230#define WELCOME_STRING "W E L C O M E T O M O N D O R E S C U E"
231
232/**
233 * The maximum length of a filename in the tape catalog.
234 */
235#define MAX_TAPECAT_FNAME_LEN 32
236
237/**
238 * Assert that (@p x != NULL) and (@p x[0] != '\\0').
239 */
240#define assert_string_is_neither_NULL_nor_zerolength(x) {assert(x!=NULL);assert(x[0]!='\0');}
241
242/**
243 * Log the file, line, Mondo error message, and OS error message (errno).
244 */
245#define log_OS_error(x) {log_msg(0, "%s (%s)", x, strerror(errno));}
246
247/**
248 * Assert that (@p x != NULL).
249 */
250#define assert_pointer_is_not_NULL(x) {assert(x!=NULL);}
251
252/**
253 * close() @p x and log a message if it fails.
254 */
255#define paranoid_close(x) {if(close(x)) {log_msg(5, "close err");} x=-999; }
256
257/**
258 * fclose() @p x and log a message if it fails.
259 */
260#define paranoid_fclose(x) {if(fclose(x)) {log_msg(5, "fclose err");} x=NULL; }
261
262/**
263 * pclose() @p x and log a message if it fails.
264 */
265#define paranoid_pclose(x) {if(pclose(x)) {log_msg(5, "pclose err");} x=NULL; }
266
267/**
268 * Run the command @p x and log it if it fails.
269 */
270#define paranoid_system(x) {if(system(x)) log_msg(4, x); }
271
272/**
273 * Free @p x and set it to NULL.
274 */
275#define paranoid_free(x) {if (x != NULL) free(x); x=NULL;}
276
277/**
278 * Free variables and call finish(@p x).
279 */
280#define paranoid_MR_finish(x) {free_MR_global_filenames (); finish(x); }
281
282/**
283 * Yes, we want malloc() to help us fix bugs.
284 */
285#define MALLOC_CHECK_ 1
286
287/**
288 * Malloc @p x to be MAX_STR_LEN bytes and call fatal_error() if we're out of memory.
289 */
290#define malloc_string(x) { x = (char *)malloc(MAX_STR_LEN); if (!x) { fatal_error("Unable to malloc"); } x[0] = x[1] = '\0'; }
291
292/**
293 * Path to the location the hard drive is mounted on during a restore.
294 */
295#define MNT_RESTORING "/mnt/RESTORING"
296
297/** @def VANILLA_SCSI_CDROM The first SCSI CD-ROM in the system (most likely to be the one to write to). */
298/** @def VANILLA_SCSI_TAPE The first SCSI tape in the system (most likely to be the one towrite to. */
299/** @def DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE A string whose presence in a device name indicates the
300 * inability to check this device for errors in the mountlist. */
301/** @def RAID_DEVICE_STUB The stub of a RAID device (set up RAID if we find it). */
302/** @def SANE_FORMATS Sane formats for this OS, separated by spaces. */
303/** @def ALT_TAPE The first IDE tape in the system. */
304/** @def MKE2FS_OR_NEWFS @c mke2fs or @c newfs, depending on the OS. */
305/** @def CP_BIN The GNU @c cp binary to use. */
306#ifdef __FreeBSD__
307#define VANILLA_SCSI_CDROM "/dev/cd0"
308#define VANILLA_SCSI_TAPE "/dev/sa0"
309#define VANILLA_USB_DEVICE "tobegivenbybsdguru"
310#define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/vinum/"
311#define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE
312#define SANE_FORMATS "swap image msdosfs nfs ntfs ntfs-3g raid lvm ffs ufs ext2fs"
313#define ALT_TAPE "/dev/ast0"
314#define MKE2FS_OR_NEWFS "newfs"
315#define CP_BIN "gcp"
316#else
317#define VANILLA_SCSI_CDROM "/dev/scd0"
318#define VANILLA_SCSI_TAPE "/dev/st0"
319#define VANILLA_USB_DEVICE "/dev/hda"
320#define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/md"
321#define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE
322#define SANE_FORMATS "swap image vfat ext2 ext3 ext4 xfs vfs jfs reiserfs vmfs dos minix coda fuse.sshfs nfs nfs4 ntfs ntfs-3g hpfs raid lvm cifs ocfs ocfs2"
323#define ALT_TAPE "/dev/ht0"
324#define MKE2FS_OR_NEWFS "mke2fs"
325#define CP_BIN "cp"
326#endif
327
328
329/**
330 * The template for a filelist filename.
331 * The first argument (%s) is the tempdir and the second (%d) is the filelist number.
332 */
333#define FILELIST_FNAME_RAW_SZ "%s/filelist.%ld"
334
335#define XATTR_LIST_FNAME_RAW_SZ "%s/xattr_list.%ld.gz"
336#define XATTR_BIGGLST_FNAME_RAW_SZ "%s/xattr_list.big.gz"
337#define ACL_LIST_FNAME_RAW_SZ "%s/acl_list.%ld.gz"
338#define ACL_BIGGLST_FNAME_RAW_SZ "%s/acl_list.big.gz"
339
340/**
341 * The template for an afioball filename.
342 * The first argument (%s) is the tempdir and the second (%d) is the filelist number.
343 */
344#define AFIOBALL_FNAME_RAW_SZ (bkpinfo->use_star)?"%s/tmpfs/%ld.star.%s":"%s/tmpfs/%ld.afio.%s"
345#define ARCH_THREADS 2 ///< The number of simultaneous threads running afio in the background.
346#define ARCH_BUFFER_NUM (ARCH_THREADS*4) // Number of permissible queued afio files
347#define DO_MBR_PLEASE "/tmp/DO-MBR-PLEASE"
348
349
350/**
351 * Compatibility define to change log_it() calls to log_debug_msg() calls.
352 */
353#define log_it(format, args...) log_debug_msg(2, __FILE__, __FUNCTION__, __LINE__, format, ## args)
354
355/**
356 * Macro to log a message along with file, line, and function information.
357 */
358#define log_msg(level, format, args...) log_debug_msg(level, __FILE__, __FUNCTION__, __LINE__, format, ## args)
359
360#define DEFAULT_DVD_DISK_SIZE 4480 ///< The default size (in MB) of a DVD disk, unless the user says otherwise.
361
362#define DEFAULT_DEBUG_LEVEL 4 ///< By default, don't log messages with a loglevel higher than this.
363
364#define SZ_NTFSPROG_VOLSIZE "1048576" // was 4096
365#define NTFSPROG_PARAMS "-z0 -V" SZ_NTFSPROG_VOLSIZE " -o -b -d -g1"
366
367#define MNT_CDROM "/mnt/cdrom"
368#define MNT_FLOPPY "/mnt/floppy"
369
370#define DEFAULT_MR_LOGLEVEL 4
371
372#endif /* _MY_STUFF_H_ */
Note: See TracBrowser for help on using the repository browser.