source: MondoRescue/branches/3.0/mondo/src/include/my-stuff.h@ 3138

Last change on this file since 3138 was 3138, checked in by Bruno Cornec, 11 years ago

r5337@localhost: bruno | 2013-06-13 01:56:06 +0200

  • Attempt to realize #700 by adding a CLI parameter to modify the biggie file size limit. By default 64 MB.
  • Also with previous commit, fixes #700 by using blocks, and adapting autoconf to use it as well.
  • Property svn:keywords set to Id
File size: 12.9 KB
RevLine 
[541]1/* my-stuff.h
2 $Id: my-stuff.h 3138 2013-06-13 04:37:24Z bruno $
[1]3*/
4
[541]5#define HAVE_MALLOC 1
6
7
[1]8// Extra info for ACLs and SELINUX users
[2419]9#define STAR_ACL_SZ "-xattr -acl"
[1]10//#define STAR_ACL_SZ "-xfflags"
11//#define STAR_ACL_SZ ""
12// Enable the first line and disable the second if you are a Fedora Core 2 user
13
14/**
15 * @file
16 * The main header file for Mondo.
17 */
18
19#if !defined(bool) && !defined(__cplusplus)
20/**
21 * Create the illusion of a Boolean type.
22 */
[541]23#define bool int
[1]24#define TRUE 1
25#define FALSE 0
26#endif
27
[541]28#ifndef _MY_STUFF_H_
29#define _MY_STUFF_H_
30
[1]31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35#ifndef __FreeBSD__
36#include <getopt.h>
37#endif
38#include <sys/types.h>
39#include <sys/ipc.h>
40#include <sys/ioctl.h>
41#include <sys/sem.h>
42#include <sys/param.h>
43#include <stdio.h>
44#include <stdlib.h>
45#ifndef __USE_FILE_OFFSET64
46#define __USE_FILE_OFFSET64
47#endif
48#ifndef __USE_LARGEFILE64
49#define __USE_LARGEFILE64
50#endif
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#include <signal.h>
[541]60//#include <curses.h>
[1]61#include <newt.h>
62#include <ctype.h>
63#include <string.h>
64#include <pthread.h>
65#include <assert.h>
66
67#if defined(DEBUG) && !__cplusplus
68int count;
[541]69char trace_log[255]; /*buffer for logging */
[1]70char *trace_log_ptr;
[541]71#endif /* DEBUG */
[1]72
[1821]73#define IA64_BOOT_SIZE "16384" /* Should be coherent with mindi */
[541]74#define STD_PREFIX "mondorescue" /* Should be coherent with mindi */
[1]75
76/**
[1885]77 * The location where mindi media images are stored.
[1437]78 */
79#define MINDI_CACHE "/var/cache/mindi"
[1]80
81/**
[1747]82 * The location where mondo changed info are stored.
83 */
84#define MONDO_CACHE "/var/cache/mondo"
85
86/**
[558]87 * The RAID kernel proc file
88 */
89#define MDSTAT_FILE "/proc/mdstat"
90
[1]91#undef assert
92
[128]93extern void _mondo_assert_fail(const char *file, const char *function,
94 int line, const char *exp);
[1]95
96/**
97 * An assert macro that calls _mondo_assert_fail() when it fails.
98 */
99#ifdef NDEBUG
100#define assert(exp) ((void)0)
101#else
102#define assert(exp) ((exp)?((void)0):_mondo_assert_fail(__FILE__, __FUNCTION__, __LINE__, #exp))
103#endif
104
[128]105#define CRC_M16 0xA001 ///< Mask for crc16.
106#define CRC_MTT 0x1021 ///< Mask for crc-ccitt.
[1]107
[541]108#define FALSE 0 ///< The ubiquitous FALSE macro.
109#define TRUE 1 ///< The even more ubiquitous TRUE macro.
110
[128]111#define SCREEN_LENGTH 25 ///< The default size of the screen.
112#define NOOF_ERR_LINES 6 ///< The number of lines of log output to keep at the bottom of the screen.
[159]113#define ARBITRARY_MAXIMUM 2000 ///< The maximum number of items showing at once in the mountlist or filelist editor.
[2188]114#define MAX_TAPECATALOG_ENTRIES 16384 ///< The maximum number of entries in the tape catalog.
115#define MAX_MOUNTLIST_ENTRIES 8192 ///< The maximum number of entries in the mountlist.
[2679]116#define MAX_STR_LEN 512 ///< The maximum length of almost all @p char buffers in Mondo.
[1236]117 /// Note: Make this divisible by eight to avoid aligment issues
118 /// on 64bit platforms like ia64.
[1]119#define MAXIMUM_RAID_DEVS 32 ///< The maximum number of RAID devices in the raidlist.
[128]120#define MAXIMUM_ADDITIONAL_RAID_VARS 32 ///< The maximum number of additional RAID variables per RAID device in the raidlist.
[2237]121#define MAXIMUM_DISKS_PER_RAID_DEV 1024 ///< The maximum number of disks per RAID device in the raidtab.
[1]122
[128]123#define RAIDTAB_FNAME "/etc/raidtab" ///< The filename of the raidtab file, at least on Linux.
[1]124
[128]125#define BLK_START_OF_BACKUP 1 ///< Marker block: start a backup.
126#define BLK_START_OF_TAPE 2 ///< Marker block: start a tape.
127#define BLK_START_AFIOBALLS 10 ///< Marker block: start the afioball section.
128#define BLK_STOP_AFIOBALLS 19 ///< Marker block: stop the afioball section.
129#define BLK_START_AN_AFIO_OR_SLICE 20 ///< Marker block: start an afioball or a slice.
130#define BLK_STOP_AN_AFIO_OR_SLICE 29 ///< Marker block: stop an afioball or a slice.
131#define BLK_START_BIGGIEFILES 30 ///< Marker block: start the biggiefile section.
132#define BLK_STOP_BIGGIEFILES 39 ///< Marker block: stop the biggiefile section.
133#define BLK_START_A_NORMBIGGIE 40 ///< Marker block: start a normal biggiefile.
[296]134#define BLK_START_A_PIHBIGGIE 41 ///< Marker block: start a ntfsprog'd biggiefile
[128]135#define BLK_START_EXTENDED_ATTRIBUTES 45 ///< Marker block: start xattr/acl info
136#define BLK_STOP_EXTENDED_ATTRIBUTES 46 ///< Marker block: stop xattr/acl info
[1]137#define BLK_START_EXAT_FILE 47
138#define BLK_STOP_EXAT_FILE 48
[128]139#define BLK_STOP_A_BIGGIE 59 ///< Marker block: stop a biggiefile.
140#define BLK_START_FILE 80 ///< Marker block: start a file (non-afio or slice).
141#define BLK_STOP_FILE 89 ///< Marker block: stop a file (non-afio or slice).
142#define BLK_END_OF_TAPE 100 ///< Marker block: end of tape.
143#define BLK_END_OF_BACKUP 101 ///< Marker block: end of backup.
144#define BLK_ABORTED_BACKUP 102 ///< Marker block: backup was aborted.
[1]145
146/// The external tape blocksize.
147#ifdef EXTTAPE
[128]148#define TAPE_BLOCK_SIZE (long)EXTTAPE
[1]149#else
[128]150#define TAPE_BLOCK_SIZE 131072L /* was 8192; 06/2002-->65536; 11/2002-->131072 */
[1]151#endif
152
[128]153#define DEFAULT_INTERNAL_TAPE_BLOCK_SIZE 32768 // Nov 2003?
[1]154
155
156
157
[128]158#define SLICE_SIZE 4096 ///< The size of a slice of a biggiefile.
[1]159
160
161
162
163
164
165/**
166 * Determine whether @p x (t_bkptype) is a streaming backup.
167 */
168#define IS_THIS_A_STREAMING_BACKUP(x) (x == tape || x == udev || x == cdstream)
169
170
[2848]171#define MONDO_MKISOFS_CMD "mkisofs"
172#define MONDO_GENISOIMAGE_CMD "genisoimage"
173#define MONDO_MKISOFS " -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version "
[1]174
175/**
176 * @c mkisofs command to generate a bootable CD using isolinux, except for -o option and the directory to image.
177 */
[2626]178#define MONDO_MKISOFS_REGULAR_SYSLINUX MONDO_MKISOFS"-J -boot-info-table -no-emul-boot -b isolinux.bin -c boot.cat -boot-load-size 4 "
[1]179
180/**
181 * @c mkisofs command to generate a bootable CD using LILO, except for -o option and the directory to image.
182 */
[2626]183#define MONDO_MKISOFS_REGULAR_LILO MONDO_MKISOFS_REGULAR_SYSLINUX
[1]184
185/**
186 * @c mkisofs command to generate a bootable CD using ELILO, except for -o option and the directory to image.
187 */
[2626]188#define MONDO_MKISOFS_REGULAR_ELILO MONDO_MKISOFS"-J -no-emul-boot -b images/mindi-bootroot."IA64_BOOT_SIZE".img -c boot.cat "
[1]189
190/**
191 * The stub name of the temporary ISO image to create, burn, and remove.
192 */
[1666]193#define MONDO_TMPISOS "temporary.iso"
[1]194
195/**
196 * @c growisofs command to generate a bootable DVD using isolinux, except for the directory to image.
197 */
[542]198#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"
[1]199
200/**
201 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image.
[1928]202 */
[542]203#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"
[1]204
205/**
206 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image.
[1928]207 */
[542]208#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"
[1]209
210/**
211 * @c growisofs command to generate a nonbootable DVD, except for the directory to image.
212 */
[542]213#define MONDO_GROWISOFS_NONBOOT "growisofs -use-the-force-luke -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v"
[1]214
215/**
216 * Welcome string displayed at the top of the newt interface.
217 */
[541]218#define WELCOME_STRING "W E L C O M E T O M O N D O R E S C U E"
[1]219
220/**
221 * The maximum length of a filename in the tape catalog.
222 */
223#define MAX_TAPECAT_FNAME_LEN 32
224
225//#define strcpy(y,x) strncpy(y, x, sizeof(y)-1)
226
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 */
[1661]236#define log_OS_error(x) {log_msg(0, "%s (%s)", x, strerror(errno));}
[1]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 */
[31]266#define paranoid_free(x) {if (x != NULL) free(x); x=NULL;}
[1]267
268/**
269 * Free variables and call finish(@p x).
270 */
[1646]271#define paranoid_MR_finish(x) {free_MR_global_filenames (); finish(x); }
[1]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 */
[402]281#define malloc_string(x) { x = (char *)malloc(MAX_STR_LEN); if (!x) { fatal_error("Unable to malloc"); } x[0] = x[1] = '\0'; }
[1]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__
[128]298#define VANILLA_SCSI_CDROM "/dev/cd0"
299#define VANILLA_SCSI_TAPE "/dev/sa0"
[1688]300#define VANILLA_USB_DEVICE "tobegivenbybsdguru"
[128]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
[2104]303#define SANE_FORMATS "swap image msdosfs nfs ntfs ntfs-3g raid lvm ffs ufs ext2fs"
[128]304#define ALT_TAPE "/dev/ast0"
305#define MKE2FS_OR_NEWFS "newfs"
306#define CP_BIN "gcp"
[1]307#else
[128]308#define VANILLA_SCSI_CDROM "/dev/scd0"
309#define VANILLA_SCSI_TAPE "/dev/st0"
[1688]310#define VANILLA_USB_DEVICE "/dev/hda"
[128]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
[2943]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 btrfs"
[128]314#define ALT_TAPE "/dev/ht0"
315#define MKE2FS_OR_NEWFS "mke2fs"
316#define CP_BIN "cp"
[1]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
[3138]331#define BIGGIEMAXSIZE 64L*1024L
[1]332/**
333 * The template for an afioball filename.
334 * The first argument (%s) is the tempdir and the second (%d) is the filelist number.
335 */
336#define AFIOBALL_FNAME_RAW_SZ (bkpinfo->use_star)?"%s/tmpfs/%ld.star.%s":"%s/tmpfs/%ld.afio.%s"
[128]337#define ARCH_THREADS 2 ///< The number of simultaneous threads running afio in the background.
338#define ARCH_BUFFER_NUM (ARCH_THREADS*4) // Number of permissible queued afio files
339#define FORTY_SPACES " " ///< 40 spaces.
[2030]340 ///< Size of the tmpfs, in megabytes, to attempt to mount (to speed up Mondo).
341/*
342#define PPCFG_RAMDISK_SIZE 350
343*/
[1]344
345#define DO_MBR_PLEASE "/tmp/DO-MBR-PLEASE"
[2943]346#define MONDO_MNTLISTCHG "/tmp/mountlist.changed"
[1]347
348
349/**
350 * Compatibility define to change log_it() calls to log_debug_msg() calls.
351 */
352#define log_it(format, args...) log_debug_msg(2, __FILE__, __FUNCTION__, __LINE__, format, ## args)
353
354/**
355 * Macro to log a message along with file, line, and function information.
356 */
357#define log_msg(level, format, args...) log_debug_msg(level, __FILE__, __FUNCTION__, __LINE__, format, ## args)
358
[1522]359#define DEFAULT_DVD_DISK_SIZE 4480 ///< The default size (in MB) of a DVD disk, unless the user says otherwise.
[1]360
[128]361#define DEFAULT_DEBUG_LEVEL 4 ///< By default, don't log messages with a loglevel higher than this.
[1]362
[296]363#define SZ_NTFSPROG_VOLSIZE "1048576" // was 4096
364#define NTFSPROG_PARAMS "-z0 -V" SZ_NTFSPROG_VOLSIZE " -o -b -d -g1"
[1]365
366#define MNT_CDROM "/mnt/cdrom"
367#define MNT_FLOPPY "/mnt/floppy"
368
369#define DEFAULT_MR_LOGLEVEL 4
370
[128]371#endif /* _MY_STUFF_H_ */
Note: See TracBrowser for help on using the repository browser.