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

Last change on this file since 2696 was 2696, checked in by Bruno Cornec, 13 years ago
  • Adds preliminary support for hpacucli. Needs test
  • Fix a compilation issue due to bad fatal_error call (no param allowed)
  • Fix some HTML syntax issues in the docs page + link to Wiki articles
  • Boot size pushed to 20MB
  • A bit more precise for error msg from PBDI
  • Exits if the protocol used is not recognized (error with -n fs:// typo)
  • Adds support for r8169 net driver
  • Fix a cast issue
  • Precise a test case to avoid ambiguity
  • Die and related functions placed before any other code as used early, and ash doesn't support function declaration. So will solve #446 by exiting mindi before doing anything weird in it.
  • Fix #445 with another technical solution to avoid vg with similar names to b wrongly excluded (vgroot and vgroot-san e.g.) (Michael Shapiro)
  • Fix a bug on exclusion of path with common content (/home and /path/home e.g.) which was handled correctly only in a certain order (John Pearson <johnp_at_gtagalenco.com.au>)
  • mount-media function is now placed in libmondo-devices.c as used by more programs.
  • Avoids calling mount_media when it's not mandatory (change the way mondorestore was working up to now but could solve some bugs reported)
  • Add xhci support to mindi.
  • Rewrite Xen kernel support to use TryToFindKernelPath systematically.
  • mindi now copies also the /lib/firmware content in order to have it for drivers needing it (bnx2 reported)
  • Push MAX_STR_LEN to 512 to allow supporting more exclude dir (2.2.10 and dyn allocation is the way to go there)
  • Add virtio driver to mindi
  • Initialize extra_cdrom_params in any case tp avoid passing null to cdrecord later on
  • Also escapes white spaces in gen_aux_list to avoid issues in getfacl call
  • Adds multiple missing drivers to mindi (mega_sr, ide_gd_mod, pata_jmicron, cp210x, dca, raid6_pq, xor async_tx, async_memcpy, async_xor)
  • Fix #434 by really testing thet udevd is not running already (chucky)
  • Adds support of pata_sil680 driver
  • Fix again #412 !! by removing calls to tee which voids the return value of the previous command
  • The way grub.unsupported was called for opensuse 11.2 was wrong. It should be done bfore calling grub-install which also exists. And tested for existence. Now this should fix #412.
  • Try to provide a workaround in code to the #401 (over-allocation of space due to rounding errors)
  • Fix a bug when using ACLs and file with spaces in their names by adding double quotes in getfacl invocation (Tom Mortell tomm_at_dslextreme.com). Also adding the same quotes on the touch commands made earlier.
  • Points to the current latest presentation instead of the old one
  • mondo-ref-card added to the docs web page
  • Add the mondoarchive reference card (Lester Wade)
  • Change useless comments for more useful ones
  • mindi is now able to handle compressed kernel with .gz or .bz2 suffix (case of OpenSuSE 11.2)
  • Improves logging for external binary
  • Improve Xen kernel detection and avoid false detection (Michael Shapiro)
  • Updated P2V doc from Lester Wade (lester.wade_at_hp.com)

Baclports from 2.2.9
svn merge -r 2650:2695 svn+ssh://bruno@svn.mondorescue.org/mondo/svn/mondorescue/branches/2.2.9 .

  • Property svn:keywords set to Id
File size: 12.5 KB
Line 
1/* my-stuff.h
2 $Id: my-stuff.h 2696 2011-01-25 09:34:40Z 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#ifdef __FreeBSD__
90#define CMDLINE "/tmp/cmdline"
91#else
92// Default Linux
93#define CMDLINE "/proc/cmdline"
94#endif
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#define assert(exp) ((exp)?((void)0):_mondo_assert_fail(__FILE__, __FUNCTION__, __LINE__, #exp))
108#endif
109
110#define CRC_M16 0xA001 ///< Mask for crc16.
111#define CRC_MTT 0x1021 ///< Mask for crc-ccitt.
112
113#define FALSE 0 ///< The ubiquitous FALSE macro.
114#define TRUE 1 ///< The even more ubiquitous TRUE macro.
115
116#define SCREEN_LENGTH 25 ///< The default size of the screen.
117#define NOOF_ERR_LINES 6 ///< The number of lines of log output to keep at the bottom 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 16384 ///< The maximum number of entries in the tape catalog.
120#define MAX_MOUNTLIST_ENTRIES 8192 ///< The maximum number of entries in the mountlist.
121#define MAX_STR_LEN 512 ///< The maximum length of almost all @p char buffers in Mondo.
122 /// Note: Make this divisible by eight to avoid aligment issues
123 /// on 64bit platforms like ia64.
124#define MAXIMUM_RAID_DEVS 32 ///< The maximum number of RAID devices in the raidlist.
125#define MAXIMUM_ADDITIONAL_RAID_VARS 32 ///< The maximum number of additional RAID variables per RAID device in the raidlist.
126#define MAXIMUM_DISKS_PER_RAID_DEV 1024 ///< The maximum number of disks per RAID device in the raidtab.
127
128#define RAIDTAB_FNAME "/etc/raidtab" ///< The filename of the raidtab file, at least on Linux.
129
130#define BLK_START_OF_BACKUP 1 ///< Marker block: start a backup.
131#define BLK_START_OF_TAPE 2 ///< Marker block: start a tape.
132#define BLK_START_AFIOBALLS 10 ///< Marker block: start the afioball section.
133#define BLK_STOP_AFIOBALLS 19 ///< Marker block: stop the afioball section.
134#define BLK_START_AN_AFIO_OR_SLICE 20 ///< Marker block: start an afioball or a slice.
135#define BLK_STOP_AN_AFIO_OR_SLICE 29 ///< Marker block: stop an afioball or a slice.
136#define BLK_START_BIGGIEFILES 30 ///< Marker block: start the biggiefile section.
137#define BLK_STOP_BIGGIEFILES 39 ///< Marker block: stop the biggiefile section.
138#define BLK_START_A_NORMBIGGIE 40 ///< Marker block: start a normal biggiefile.
139#define BLK_START_A_PIHBIGGIE 41 ///< Marker block: start a ntfsprog'd biggiefile
140#define BLK_START_EXTENDED_ATTRIBUTES 45 ///< Marker block: start xattr/acl info
141#define BLK_STOP_EXTENDED_ATTRIBUTES 46 ///< Marker block: stop xattr/acl info
142#define BLK_START_EXAT_FILE 47
143#define BLK_STOP_EXAT_FILE 48
144#define BLK_STOP_A_BIGGIE 59 ///< Marker block: stop a biggiefile.
145#define BLK_START_FILE 80 ///< Marker block: start a file (non-afio or slice).
146#define BLK_STOP_FILE 89 ///< Marker block: stop a file (non-afio or slice).
147#define BLK_END_OF_TAPE 100 ///< Marker block: end of tape.
148#define BLK_END_OF_BACKUP 101 ///< Marker block: end of backup.
149#define BLK_ABORTED_BACKUP 102 ///< Marker block: backup was aborted.
150
151/// The external tape blocksize.
152#ifdef EXTTAPE
153#define TAPE_BLOCK_SIZE (long)EXTTAPE
154#else
155#define TAPE_BLOCK_SIZE 131072L /* was 8192; 06/2002-->65536; 11/2002-->131072 */
156#endif
157
158#define DEFAULT_INTERNAL_TAPE_BLOCK_SIZE 32768 // Nov 2003?
159
160
161
162
163#define SLICE_SIZE 4096 ///< The size of a slice of a biggiefile.
164
165
166
167
168
169
170/**
171 * Determine whether @p x (t_bkptype) is a streaming backup.
172 */
173#define IS_THIS_A_STREAMING_BACKUP(x) (x == tape || x == udev || x == cdstream)
174
175
176#define MONDO_MKISOFS "mkisofs -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version "
177
178/**
179 * @c mkisofs command to generate a bootable CD using isolinux, except for -o option and the directory to image.
180 */
181#define MONDO_MKISOFS_REGULAR_SYSLINUX MONDO_MKISOFS"-J -boot-info-table -no-emul-boot -b isolinux.bin -c boot.cat -boot-load-size 4 "
182
183/**
184 * @c mkisofs command to generate a bootable CD using LILO, except for -o option and the directory to image.
185 */
186#define MONDO_MKISOFS_REGULAR_LILO MONDO_MKISOFS_REGULAR_SYSLINUX
187
188/**
189 * @c mkisofs command to generate a bootable CD using ELILO, except for -o option and the directory to image.
190 */
191#define MONDO_MKISOFS_REGULAR_ELILO MONDO_MKISOFS"-J -no-emul-boot -b images/mindi-bootroot."IA64_BOOT_SIZE".img -c boot.cat "
192
193/**
194 * The stub name of the temporary ISO image to create, burn, and remove.
195 */
196#define MONDO_TMPISOS "temporary.iso"
197
198/**
199 * @c growisofs command to generate a bootable DVD using isolinux, except for the directory to image.
200 */
201#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"
202
203/**
204 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image.
205 */
206#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"
207
208/**
209 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image.
210 */
211#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"
212
213/**
214 * @c growisofs command to generate a nonbootable DVD, except for the directory to image.
215 */
216#define MONDO_GROWISOFS_NONBOOT "growisofs -use-the-force-luke -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v"
217
218/**
219 * Welcome string displayed at the top of the newt interface.
220 */
221#define WELCOME_STRING "W E L C O M E T O M O N D O R E S C U E"
222
223/**
224 * The maximum length of a filename in the tape catalog.
225 */
226#define MAX_TAPECAT_FNAME_LEN 32
227
228/**
229 * Assert that (@p x != NULL) and (@p x[0] != '\\0').
230 */
231#define assert_string_is_neither_NULL_nor_zerolength(x) {assert(x!=NULL);assert(x[0]!='\0');}
232
233/**
234 * Log the file, line, Mondo error message, and OS error message (errno).
235 */
236#define log_OS_error(x) {log_msg(0, "%s (%s)", x, strerror(errno));}
237
238/**
239 * Assert that (@p x != NULL).
240 */
241#define assert_pointer_is_not_NULL(x) {assert(x!=NULL);}
242
243/**
244 * close() @p x and log a message if it fails.
245 */
246#define paranoid_close(x) {if(close(x)) {log_msg(5, "close err");} x=-999; }
247
248/**
249 * fclose() @p x and log a message if it fails.
250 */
251#define paranoid_fclose(x) {if(fclose(x)) {log_msg(5, "fclose err");} x=NULL; }
252
253/**
254 * pclose() @p x and log a message if it fails.
255 */
256#define paranoid_pclose(x) {if(pclose(x)) {log_msg(5, "pclose err");} x=NULL; }
257
258/**
259 * Run the command @p x and log it if it fails.
260 */
261#define paranoid_system(x) {if(system(x)) log_msg(4, x); }
262
263/**
264 * Free @p x and set it to NULL.
265 */
266#define paranoid_free(x) {if (x != NULL) free(x); x=NULL;}
267
268/**
269 * Free variables and call finish(@p x).
270 */
271#define paranoid_MR_finish(x) {free_MR_global_filenames (); finish(x); }
272
273/**
274 * Yes, we want malloc() to help us fix bugs.
275 */
276#define MALLOC_CHECK_ 1
277
278/**
279 * Malloc @p x to be MAX_STR_LEN bytes and call fatal_error() if we're out of memory.
280 */
281#define malloc_string(x) { x = (char *)malloc(MAX_STR_LEN); if (!x) { fatal_error("Unable to malloc"); } x[0] = x[1] = '\0'; }
282
283/**
284 * Path to the location the hard drive is mounted on during a restore.
285 */
286#define MNT_RESTORING "/mnt/RESTORING"
287
288/** @def VANILLA_SCSI_CDROM The first SCSI CD-ROM in the system (most likely to be the one to write to). */
289/** @def VANILLA_SCSI_TAPE The first SCSI tape in the system (most likely to be the one towrite to. */
290/** @def DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE A string whose presence in a device name indicates the
291 * inability to check this device for errors in the mountlist. */
292/** @def RAID_DEVICE_STUB The stub of a RAID device (set up RAID if we find it). */
293/** @def SANE_FORMATS Sane formats for this OS, separated by spaces. */
294/** @def ALT_TAPE The first IDE tape in the system. */
295/** @def MKE2FS_OR_NEWFS @c mke2fs or @c newfs, depending on the OS. */
296/** @def CP_BIN The GNU @c cp binary to use. */
297#ifdef __FreeBSD__
298#define VANILLA_SCSI_CDROM "/dev/cd0"
299#define VANILLA_SCSI_TAPE "/dev/sa0"
300#define VANILLA_USB_DEVICE "tobegivenbybsdguru"
301#define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/vinum/"
302#define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE
303#define SANE_FORMATS "swap image msdosfs nfs ntfs ntfs-3g raid lvm ffs ufs ext2fs"
304#define ALT_TAPE "/dev/ast0"
305#define MKE2FS_OR_NEWFS "newfs"
306#define CP_BIN "gcp"
307#else
308#define VANILLA_SCSI_CDROM "/dev/scd0"
309#define VANILLA_SCSI_TAPE "/dev/st0"
310#define VANILLA_USB_DEVICE "/dev/hda"
311#define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/md"
312#define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE
313#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"
314#define ALT_TAPE "/dev/ht0"
315#define MKE2FS_OR_NEWFS "mke2fs"
316#define CP_BIN "cp"
317#endif
318
319
320/**
321 * The template for a filelist filename.
322 * The first argument (%s) is the tempdir and the second (%d) is the filelist number.
323 */
324#define FILELIST_FNAME_RAW_SZ "%s/filelist.%ld"
325
326#define XATTR_LIST_FNAME_RAW_SZ "%s/xattr_list.%ld.gz"
327#define XATTR_BIGGLST_FNAME_RAW_SZ "%s/xattr_list.big.gz"
328#define ACL_LIST_FNAME_RAW_SZ "%s/acl_list.%ld.gz"
329#define ACL_BIGGLST_FNAME_RAW_SZ "%s/acl_list.big.gz"
330
331/**
332 * The template for an afioball filename.
333 * The first argument (%s) is the tempdir and the second (%d) is the filelist number.
334 */
335#define AFIOBALL_FNAME_RAW_SZ (bkpinfo->use_star)?"%s/tmpfs/%ld.star.%s":"%s/tmpfs/%ld.afio.%s"
336#define ARCH_THREADS 2 ///< The number of simultaneous threads running afio in the background.
337#define ARCH_BUFFER_NUM (ARCH_THREADS*4) // Number of permissible queued afio files
338#define DO_MBR_PLEASE "/tmp/DO-MBR-PLEASE"
339
340
341/**
342 * Compatibility define to change log_it() calls to log_debug_msg() calls.
343 */
344#define log_it(format, args...) log_debug_msg(2, __FILE__, __FUNCTION__, __LINE__, format, ## args)
345
346/**
347 * Macro to log a message along with file, line, and function information.
348 */
349#define log_msg(level, format, args...) log_debug_msg(level, __FILE__, __FUNCTION__, __LINE__, format, ## args)
350
351#define DEFAULT_DVD_DISK_SIZE 4480 ///< The default size (in MB) of a DVD disk, unless the user says otherwise.
352
353#define DEFAULT_DEBUG_LEVEL 4 ///< By default, don't log messages with a loglevel higher than this.
354
355#define SZ_NTFSPROG_VOLSIZE "1048576" // was 4096
356#define NTFSPROG_PARAMS "-z0 -V" SZ_NTFSPROG_VOLSIZE " -o -b -d -g1"
357
358#define MNT_CDROM "/mnt/cdrom"
359#define MNT_FLOPPY "/mnt/floppy"
360
361#define DEFAULT_MR_LOGLEVEL 4
362
363#endif /* _MY_STUFF_H_ */
Note: See TracBrowser for help on using the repository browser.