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

Last change on this file since 1693 was 1693, checked in by Bruno Cornec, 17 years ago
  • Remove useless copy from mindi to mondo at end of USB handling
  • Fix PB macro vs tools/*2build issue
  • make_usb_fs change of interface (doesn't need a parameter)
  • Fix USB support in mondo to avoid multiple copies of files
  • Use first partiion in mondo for USB device
  • Fixes for USB CLI for both mondo/mindi
  • Try to add USB support for mondoarchive with new functions
  • du => deb for similarity with other distro type under pbconf
  • migrate gento build files under pb
  • remove now obsolete rpm spec file and gentoo build files from distributions
  • Remove DOCDIR usage in mindi + various build fixes

(merge -r1680:1692 $SVN_M/branches/2.2.5)

  • Property svn:eol-style set to native
File size: 9.0 KB
RevLine 
[1054]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
[1069]13/*The number of lines of log output to keep at the bottom of the screen.*/
14#define NOOF_ERR_LINES 6
15
[1087]16/* Hardcoded: Bad for the moment */
17#define MONDO_CACHE "/var/cache/mondo"
[1438]18#define MINDI_CACHE "/var/cache/mindi"
[1087]19#define MONDORESTORECFG MONDO_CACHE"/mondo-restore.cfg"
[1158]20/**
21 * The mondo-restore.cfg stub (appended to the directory where all.tar.gz was unpacked).
22 */
23#define MONDO_CFG_FILE_STUB "tmp/mondo-restore.cfg"
[1087]24
25
[1158]26
[1054]27/**
28 * @file
29 * The main header file for Mondo.
30 */
31
32#include <stdio.h>
[1080]33#include "mr_mem.h"
[1144]34#include "mr_msg.h"
[1264]35#include "mr_types.h"
[1054]36
37#ifdef HAVE_CONFIG_H
38#include <config.h>
39#endif
40/* BERLIOS
41 * Useful ?
42*/
43
44#ifndef __FreeBSD__
45#include <getopt.h>
46#endif
47
48#include <sys/types.h>
49#include <sys/shm.h>
50#include <sys/ipc.h>
51#include <sys/ioctl.h>
52#include <sys/sem.h>
53#include <sys/param.h>
54
55#include <stdlib.h>
56#include <sys/stat.h>
57#include <fcntl.h>
58#include <errno.h>
59#include <stddef.h>
60#include <sys/stat.h>
61#include <sys/wait.h>
62#include <time.h>
63#include <unistd.h>
64#ifndef S_SPLINT_S
65#include <signal.h>
66#endif
67#include <newt.h>
68#include <ctype.h>
69#include <string.h>
70#ifndef S_SPLINT_S
71#include <pthread.h>
72#endif
73#include <assert.h>
74
75/**
76 * The biggielist stub (appended to the directory where all.tar.gz was unpacked).
77 */
78#define BIGGIELIST_TXT_STUB "tmp/biggielist.txt"
79
80/**
81 * The filelist stub (appended to the directory where all.tar.gz was unpacked).
82 */
83#define FILELIST_FULL_STUB "tmp/filelist.full.gz"
84
85/**
86 * The mountlist stub (appended to the directory where all.tar.gz was unpacked).
87 */
88#define MOUNTLIST_FNAME_STUB "tmp/mountlist.txt"
89
90/**
91 * The RAID kernel proc file
92 */
93#define MDSTAT_FILE "/proc/mdstat"
94
95#undef assert
96
97extern void _mondo_assert_fail(const char *file, const char *function,
98 int line, const char *exp);
99
100/**
101 * An assert macro that calls _mondo_assert_fail() when it fails.
102 */
103#ifdef NDEBUG
104# define assert(exp) ((void)0)
105#else
106# ifndef S_SPLINT_S
107# define assert(exp) ((exp)?((void)0):_mondo_assert_fail(__FILE__, __FUNCTION__, __LINE__, #exp))
108# else
109# define assert(exp) ((void)0)
110# endif
111#endif
112
113#define CRC_M16 0xA001 ///< Mask for crc16.
114#define CRC_MTT 0x1021 ///< Mask for crc-ccitt.
115
116#define SCREEN_LENGTH 25 ///< The default size of the screen.
117#define ARBITRARY_MAXIMUM 2000 ///< The maximum number of items showing at once in the mountlist or filelist editor.
118#define MAX_TAPECATALOG_ENTRIES 8192 ///< The maximum number of entries in the tape catalog.
[1078]119#define MAX_STR_LEN 384 ///< The maximum length of almost all @p char buffers in Mondo.
120 /// Note: Make this divisible by eight to avoid aligment issues
121 /// on 64bit platforms like ia64.
[1054]122#define MAXIMUM_RAID_DEVS 32 ///< The maximum number of RAID devices in the raidlist.
123#define MAXIMUM_ADDITIONAL_RAID_VARS 32 ///< The maximum number of additional RAID variables per RAID device in the raidlist.
124#define MAXIMUM_DISKS_PER_RAID_DEV 32 ///< The maximum number of disks per RAID device in the raidtab.
125
126#define RAIDTAB_FNAME "/etc/raidtab" ///< The filename of the raidtab file, at least on Linux.
127
128#define BLK_START_OF_BACKUP 1 ///< Marker block: start a backup.
129#define BLK_START_OF_TAPE 2 ///< Marker block: start a tape.
130#define BLK_START_AFIOBALLS 10 ///< Marker block: start the afioball section.
131#define BLK_STOP_AFIOBALLS 19 ///< Marker block: stop the afioball section.
132#define BLK_START_AN_AFIO_OR_SLICE 20 ///< Marker block: start an afioball or a slice.
133#define BLK_STOP_AN_AFIO_OR_SLICE 29 ///< Marker block: stop an afioball or a slice.
134#define BLK_START_BIGGIEFILES 30 ///< Marker block: start the biggiefile section.
135#define BLK_STOP_BIGGIEFILES 39 ///< Marker block: stop the biggiefile section.
136#define BLK_START_A_NORMBIGGIE 40 ///< Marker block: start a normal biggiefile.
137#define BLK_START_A_PIHBIGGIE 41 ///< Marker block: start a ntfsprog'd biggiefile
138#define BLK_START_EXTENDED_ATTRIBUTES 45 ///< Marker block: start xattr/acl info
139#define BLK_STOP_EXTENDED_ATTRIBUTES 46 ///< Marker block: stop xattr/acl info
140#define BLK_START_EXAT_FILE 47
141#define BLK_STOP_EXAT_FILE 48
142#define BLK_STOP_A_BIGGIE 59 ///< Marker block: stop a biggiefile.
143#define BLK_START_FILE 80 ///< Marker block: start a file (non-afio or slice).
144#define BLK_STOP_FILE 89 ///< Marker block: stop a file (non-afio or slice).
145#define BLK_END_OF_TAPE 100 ///< Marker block: end of tape.
146#define BLK_END_OF_BACKUP 101 ///< Marker block: end of backup.
147#define BLK_ABORTED_BACKUP 102 ///< Marker block: backup was aborted.
148
149/**
150 * Determine whether @p x (t_bkptype) is a streaming backup.
151 */
152#define IS_THIS_A_STREAMING_BACKUP(x) (x == tape || x == udev || x == cdstream)
153
154/**
[1670]155 * The stub name of the temporary ISO image to create, burn, and remove.
156 */
157#define MONDO_TMPISOS "temporary.iso"
158
159/**
[1054]160 * Assert that (@p x != NULL) and (@p x[0] != '\\0').
161 */
162#define assert_string_is_neither_NULL_nor_zerolength(x) {assert(x!=NULL);assert(x[0]!='\0');}
163
164/**
165 * Log the file, line, Mondo error message, and OS error message (errno).
166 */
[1663]167#define log_OS_error(x) {mr_msg(1, "%s, (%s)", x, strerror(errno));}
[1054]168
169/**
170 * Assert that (@p x != NULL).
171 */
172#define assert_pointer_is_not_NULL(x) {assert(x!=NULL);}
173
174/**
175 * close() @p x and log a message if it fails.
176 */
[1144]177#define paranoid_close(x) {if(close(x)) {mr_msg(5, "close err");} x=-999; }
[1054]178
179/**
180 * fclose() @p x and log a message if it fails.
181 */
[1144]182#define paranoid_fclose(x) {if(fclose(x)) {mr_msg(5, "fclose err");} x=NULL; }
[1054]183
184/**
185 * pclose() @p x and log a message if it fails.
186 */
[1144]187#define paranoid_pclose(x) {if(pclose(x)) {mr_msg(5, "pclose err");} x=NULL; }
[1054]188
189/**
190 * Run the command @p x and log it if it fails.
191 */
[1144]192#define paranoid_system(x) {if(system(x)) mr_msg(4, x); }
[1054]193
194/**
195 * Free variables and call finish(@p x).
196 */
[1663]197#define paranoid_MR_finish(x) {free_MR_global_filenames (); finish(x); }
[1054]198
199/**
200 * Log file, function, line, and @p x.
201 */
[1559]202#define iamhere(x) {mr_msg(2, x);}
[1054]203
204/**
205 * Yes, we want malloc() to help us fix bugs.
206 */
207#define MALLOC_CHECK_ 1
208
209/**
210 * Malloc @p x to be MAX_STR_LEN bytes and call fatal_error() if we're out of memory.
211 */
[1080]212#define malloc_string(x) { x = (char *)mr_malloc(MAX_STR_LEN); x[0] = x[1] = '\0'; }
[1054]213
214/**
215 * Path to the location the hard drive is mounted on during a restore.
216 */
217#define MNT_RESTORING "/mnt/RESTORING"
218
219/** @def VANILLA_SCSI_TAPE The SCSI tape radical on the system (most likely to be the one towrite to. */
220/** @def DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE A string whose presence in a device name indicates the
221 * inability to check this device for errors in the mountlist. */
222/** @def RAID_DEVICE_STUB The stub of a RAID device (set up RAID if we find it). */
223/** @def SANE_FORMATS Sane formats for this OS, separated by spaces. */
224/** @def ALT_TAPE The first IDE tape in the system. */
225/** @def MKE2FS_OR_NEWFS @c mke2fs or @c newfs, depending on the OS. */
226/** @def CP_BIN The GNU @c cp binary to use. */
227#ifdef __FreeBSD__
228#define VANILLA_SCSI_TAPE "/dev/sa"
[1693]229#define VANILLA_USB_DEVICE "tobegivenbybsdguru"
[1054]230#define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/vinum/"
231#define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE
232#define SANE_FORMATS "swap image msdosfs nfs ntfs raid lvm ffs ufs ext2fs"
233#define ALT_TAPE "/dev/ast"
234#define MKE2FS_OR_NEWFS "newfs"
235#define CP_BIN "gcp"
236#else
[1574]237#define VANILLA_SCSI_TAPE "/dev/st0"
[1693]238#define VANILLA_USB_DEVICE "/dev/hda"
[1054]239#define DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE "/dev/md"
240#define RAID_DEVICE_STUB DONT_KNOW_HOW_TO_EVALUATE_THIS_DEVICE_TYPE
241#define SANE_FORMATS "swap image vfat ext2 ext3 xfs vfs jfs reiserfs dos minix coda nfs ntfs hpfs raid lvm cifs"
[1574]242#define ALT_TAPE "/dev/ht0"
[1054]243#define MKE2FS_OR_NEWFS "mke2fs"
244#define CP_BIN "cp"
245#endif
246
247
248/**
249 * The template for a filelist filename.
250 * The first argument (%s) is the tempdir and the second (%d) is the filelist number.
251 */
252#define FILELIST_FNAME_RAW_SZ "%s/filelist.%ld"
253
254#define XATTR_LIST_FNAME_RAW_SZ "%s/xattr_list.%ld.gz"
255#define XATTR_BIGGLST_FNAME_RAW_SZ "%s/xattr_list.big.gz"
256#define ACL_LIST_FNAME_RAW_SZ "%s/acl_list.%ld.gz"
257#define ACL_BIGGLST_FNAME_RAW_SZ "%s/acl_list.big.gz"
258
259/**
260 * The template for an afioball filename.
261 * The first argument (%s) is the tempdir and the second (%d) is the filelist number.
262 */
263#define AFIOBALL_FNAME_RAW_SZ (bkpinfo->use_star)?"%s/tmpfs/%ld.star.%s":"%s/tmpfs/%ld.afio.%s"
264#define ARCH_THREADS 2 ///< The number of simultaneous threads running afio in the background.
265#define ARCH_BUFFER_NUM (ARCH_THREADS*4) // Number of permissible queued afio files
266#define PPCFG_RAMDISK_SIZE 350 ///< Size of the tmpfs, in megabytes, to attempt to mount (to speed up Mondo).
267
268/**
[1144]269 * Shorter log command
[1054]270 */
[1144]271#define log_it(format, args...) mr_msg(2, format, ## args)
[1054]272
273#define SZ_NTFSPROG_VOLSIZE "1048576" // was 4096
274#define NTFSPROG_PARAMS "-z0 -V" SZ_NTFSPROG_VOLSIZE " -o -b -d -g1"
275
276#define MNT_CDROM "/mnt/cdrom"
277
278#endif /* _MY_STUFF_H_ */
Note: See TracBrowser for help on using the repository browser.