source: MondoRescue/branches/stable/mondo/src/common/mondostructures.h@ 1904

Last change on this file since 1904 was 1904, checked in by Bruno Cornec, 16 years ago

merge -r 1889:1902 svn+ssh://bruno@svn.mondorescue.org/mondo/svn/mondorescue/branches/2.2.6

  • Property svn:keywords set to Id
File size: 17.5 KB
Line 
1/***************************************************************************
2 * $Id: mondostructures.h 1904 2008-04-09 23:20:42Z bruno $
3 *
4 * @file
5 * The header file defining all of Mondo's structures.
6 */
7
8
9/**
10 * Structure indicating one entry in the mountlist.
11 * There is one mountlist_line for each device we're keeping track of in the mountlist.
12 */
13struct mountlist_line {
14 /**
15 * The name of the device (/dev entry) for this mountlist line. Guaranteed to be unique.
16 */
17 char device[64];
18
19 /**
20 * The mountpoint for this mountlist line. Should be unique.
21 * This can be "raid", for a RAID subdisk, or "lvm", for an LVM PV.
22 */
23 char mountpoint[256];
24
25 /**
26 * The filesystem type of this entry. Examples: ext2, ext3, reiserfs, xfs, swap.
27 * Also, this can be "raid", for a RAID subdisk, or "lvm", for an LVM PV.
28 */
29 char format[64];
30
31 /**
32 * The size in kilobytes of this device. 0 or -1 indicates LVM.
33 */
34 long long size;
35
36 /**
37 * For ext2 and ext3, this is the filesystem label or uuid (if there is one). If not, this should be "".
38 */
39 char label[256];
40
41};
42
43/**
44 * The mountlist structure.
45 * This is used to keep track of a list of all the devices/partitions/formats/sizes/labels in the
46 * system, so we can recreate them in a nuke restore.
47 */
48struct mountlist_itself {
49 /**
50 * Number of entries in the mountlist.
51 */
52 int entries;
53
54 /**
55 * The list of entries, all @p entries of them.
56 */
57 struct mountlist_line el[MAX_TAPECATALOG_ENTRIES];
58};
59
60/**
61 * A structure which holds references to elements of the mountlist.
62 * This is used in resize_drive_proportionately_to_fit_new_drives() to
63 * ensure accurate resizing.
64 */
65struct mountlist_reference {
66 /**
67 * The number of entries in the list of mountlist references.
68 */
69 int entries;
70
71 /**
72 * The array of mountlist_line, allocated on demand.
73 */
74 struct mountlist_line **el;
75};
76
77/**
78 * A line in @p additional_raid_variables.
79 */
80struct raid_var_line {
81 /**
82 * The label for this RAID variable.
83 */
84 char label[64];
85
86 /**
87 * The value for this RAID variable.
88 */
89 char value[64];
90};
91
92/**
93 * The additional RAID variables structure.
94 * This is used to store a list of additional variables to be put in the raidtab,
95 * to allow users to use (new) features of RAID which Mondo doesn't (yet) support directly.
96 * Each @p raid_device_record has one.
97 */
98struct additional_raid_variables {
99 /**
100 * The number of entries in the list.
101 */
102 int entries;
103
104 /**
105 * The list of entries, all @p entries of them.
106 */
107 struct raid_var_line el[MAXIMUM_ADDITIONAL_RAID_VARS];
108};
109
110/**
111 * One disk in a @p list_of_disks.
112 */
113struct s_disk {
114#ifdef __FreeBSD__
115 /**
116 * The name of this disk. If blank it will eventually get filled in automatically.
117 */
118 char name[64];
119#endif
120 /**
121 * The device this entry describes.
122 */
123 char device[64];
124
125 /**
126 * Index number of this entry in the whole disklist.
127 */
128 int index;
129
130 /**
131 * Type of disk.
132 */
133 char type; // ' ' = data (default), S = spare, F = faulty
134
135};
136
137/**
138 * A list of @p s_disk. Every @p raid_device_record has four.
139 */
140struct list_of_disks {
141 /**
142 * The number of entries in the disklist.
143 */
144 int entries;
145
146 /**
147 * The entries themselves, all @p entries of them.
148 */
149 struct s_disk el[MAXIMUM_DISKS_PER_RAID_DEV];
150};
151
152/**
153 * A type of media we're backing up to.
154 */
155typedef enum { none = 0, ///< No type has been set yet.
156 iso, ///< Back up to ISO images.
157 cdr, ///< Back up to recordable CDs (do not erase them).
158 cdrw, ///< Back up to CD-RWs and blank them first.
159 dvd, ///< Back up to DVD+R[W] or DVD-R[W] disks.
160 cdstream, ///< Back up to recordable CDs but treat them like a tape streamer.
161 nfs, ///< Back up to an NFS mount on the local subnet.
162 tape, ///< Back up to tapes.
163 usb, ///< Back up to USB devices.
164 udev ///< Back up to another unsupported device; just send a stream of bytes.
165} t_bkptype;
166
167/*
168 * Type of compression algorithm we're using
169 */
170typedef enum {
171 none = 0, //< No compression
172 gzip, //< Compression with gzip
173 bzip2, //< Compression with bzip2
174 lzo, //< Compression with lzo
175 lzma //< Compression with lzma
176} t_mr_comp;
177
178/**
179 * A type of file in the catalog of recent archives.
180 */
181typedef enum { other, ///< Some other kind of file.
182 fileset, ///< An afioball (fileset), optionally compressed.
183 biggieslice ///< A slice of a biggiefile, optionally compressed.
184} t_archtype;
185
186
187#ifdef __FreeBSD__
188
189struct vinum_subdisk {
190 char which_device[64];
191};
192
193struct vinum_plex {
194 int raidlevel;
195 int stripesize;
196 int subdisks;
197 struct vinum_subdisk sd[MAXIMUM_RAID_DEVS];
198};
199
200struct vinum_volume {
201 char volname[64];
202 int plexes;
203 struct vinum_plex plex[9];
204};
205
206struct raidlist_itself {
207 int entries;
208 struct list_of_disks spares;
209 struct list_of_disks disks;
210 struct vinum_volume el[MAXIMUM_RAID_DEVS];
211};
212
213#else
214
215 /**
216 * A RAID device in the raidlist.
217 */
218struct raid_device_record {
219 /**
220 * The name of the RAID device (e.g. /dev/md0).
221 */
222 char raid_device[64];
223
224 /**
225 * The RAID level (-1 to 5) we're using.
226 */
227 int raid_level;
228
229 /**
230 * Whether the disk has a persistent superblock.
231 */
232 int persistent_superblock;
233
234 /**
235 * The chunk size of this RAID device.
236 */
237 int chunk_size;
238
239 /**
240 * The parity algorithm of this RAID device. (RAID5 only)
241 */
242 int parity; // 0=left-asymmetric, 1=right-asymmetric, 2=left-symmetric, 3=right-symmetric
243
244 /**
245 * A list of the disks to use for storing data.
246 */
247 struct list_of_disks data_disks;
248
249 /**
250 * A list of the disks to use as "hot spares" in case one dies.
251 */
252 struct list_of_disks spare_disks;
253
254 /**
255 * A list of the disks to use for storing parity information.
256 */
257 struct list_of_disks parity_disks;
258
259 /**
260 * A list of the disks in this RAID device that have failed\. Rare.
261 */
262 struct list_of_disks failed_disks;
263
264 /**
265 * The additional RAID variables for this device.
266 */
267 struct additional_raid_variables additional_vars;
268
269 /**
270 * Resync progress for this device.
271 */
272 int progress;
273};
274
275 /**
276 * The list of RAID devices.
277 * This is intended to be used along with the mountlist, and it can be
278 * directly loaded from/saved to raidtab format.
279 */
280struct raidlist_itself {
281 /**
282 * The number of entries in the list.
283 */
284 int entries;
285
286 /**
287 * The RAID devices in the raidlist, all @p entries of them.
288 */
289 struct raid_device_record el[MAXIMUM_RAID_DEVS];
290};
291
292#endif
293
294/**
295 * The backup information structure.
296 *
297 * This is the central structure to all the activity going on inside Mondo.
298 * It is passed to almost every function that is not just a helper, even those
299 * which only use one variable of it, because it is useful keeping all the information
300 * together in one place. The usage of particular fields in the bkpinfo is marked in
301 * function documentation, but it is best to fill out as many fields as apply, because
302 * that function may in turn pass the bkpinfo to other functions which use other fields.
303 *
304 * To fill out the bkpinfo first call reset_bkpinfo() and pre_param_configuration(). Then set
305 * the backup-specific parameters (see mondo/mondoarchive/mondo-cli.c-\>process_switches for
306 * an example). After that, you should call post_param_configuration() to set some final
307 * parameters based on those you have already set. Failure to do the last step will result in
308 * extremely strange and hard-to-track errors in chop_filelist(), since optimal_set_size is 0.
309 */
310struct s_bkpinfo {
311 /**
312 * The device we're backing up to.
313 * If backup_media_type is @b cdr, @b cdrw, or @b cdstream, this should be the SCSI node (e.g. 0,1,0).
314 * If backup_media_type is @b dvd, @b tape, @b usb or @b udev, this should be a /dev entry.
315 * If backup_media_type is anything else, this should be blank.
316 */
317 char *media_device;
318
319 /* SCSI node (a la 0,0,0) or NULL if we use the media_device */
320 char *iso_burning_dev;
321
322 /**
323 *
324 * The size of the media in our backup set, in MB.
325 * If the size should be autodetected, make it -1 (preferable) or 0.
326 *
327 */
328 long media_size;
329
330 /**
331 * The boot loader that is installed. Available choices are:
332 * - 'G' for GRUB
333 * - 'L' for LILO
334 * - 'E' for ELILO
335 * - (FreeBSD only) 'B' for boot0
336 * - (FreeBSD only) 'D' for dangerously dedicated
337 * - 'R' for Raw
338 * - 'U' for Unknown or None
339 *
340 * The function which_boot_loader() can help you set this.
341 */
342 char boot_loader;
343
344 /**
345 * The boot device on which @p boot_loader is installed.
346 * This is a bit difficult to autodetect; you may want
347 * to take truncate_to_drive_name() of where_is_root_mounted().
348 */
349 char boot_device[MAX_STR_LEN / 4];
350
351 /**
352 * The compression program to use. Currently supported
353 * choices are lzop, bzip2, and gzip. This is ignored if
354 * compression_level is 0.
355 */
356 char *compression_tool;
357
358 /**
359 * The extension your compression program uses. lzop uses lzo, bzip uses
360 * bz2, gzip uses gz, etc. Do not include the dot.
361 */
362 char *compression_suffix;
363
364 /**
365 * The compression level (1-9) to use. 0 disables compression.
366 */
367 int compression_level;
368
369 /**
370 * The type of compression
371 */
372 t_mr_comp compression_type;
373
374 /**
375 * Devices to back up as biggiefiles.
376 *
377 * This is useful for backing up NTFS partitions.
378 * @c ntfsclone is used to back up only the used sectors, so the space tradeoff is not bad.
379 * However, several caveats apply to such a partition:
380 * - It must not be mounted during the backup
381 * - It must be in a format that ntfsclone knows how to handle, i.e. NTFS
382 * - It cannot be verified during the verify or compare phase
383 * - It may not be resized or selectively restored at restore-time (all or nothing)
384 *
385 * This is a useful feature, but use at your own risk.
386 */
387 char image_devs[MAX_STR_LEN / 4];
388
389 /**
390 * A filename containing a list of extensions, one per line, to not
391 * compress. If this is set to "", afio will still exclude a set of well-known
392 * compressed files from compression, but biggiefiles that are compressed
393 * will be recompressed again.
394 */
395 char do_not_compress_these[MAX_STR_LEN / 2];
396
397 /**
398 * If TRUE, then we should verify a backup.
399 */
400 bool verify_data;
401
402 /**
403 * If TRUE, then we should back up some data.
404 */
405 bool backup_data;
406
407 /**
408 * If TRUE, then we should restore some data.
409 */
410 bool restore_data;
411
412
413 /**
414 * If TRUE, then we should backup/restore using star, not afio
415 */
416 bool use_star;
417
418
419 /**
420 * Size of internal block reads/writes
421 */
422 long internal_tape_block_size;
423
424 /**
425 * If TRUE, we're making a CD that will autonuke without confirmation when booted.
426 */
427 bool disaster_recovery;
428
429 /**
430 * The directory we're backing up to.
431 * If backup_media_type is @b iso, then this is that directory.
432 * If backup_media_type is anything else, this is ignored.
433 */
434 char isodir[MAX_STR_LEN / 4];
435
436/**
437 * The prefix to put in front of media number
438 * If backup_media_type is @b iso, then this is the prefix for the filename
439 * If backup_media_type is anything else, this is ignored.
440 */
441 char *prefix;
442
443 /**
444 * The scratch directory to use.
445 * This is the "stage" that the CD image is made directly from.
446 * As such, it needs to be at least as large as the largest CD/DVD/ISO.
447 */
448 char scratchdir[MAX_STR_LEN / 4];
449
450 /**
451 * The temp directory to use.
452 * This is where filesets are stored by the archival threads before
453 * the main thread moves them to the scratchdir. You don't need a lot
454 * of space here.
455 */
456 char tmpdir[MAX_STR_LEN / 4];
457
458 /**
459 * The optimal size for each fileset. This is set automatically in
460 * post_param_configuration() based on your @p backup_media_type; you
461 * needn't set it yourself.
462 */
463 long optimal_set_size;
464
465 /**
466 * The type of media we're backing up to.
467 */
468 t_bkptype backup_media_type;
469// bool blank_dvd_first;
470
471 /**
472 * The string corresponding to the media type
473 */
474 char backup_media_string[64];
475
476 /**
477 * Whether we should use a premade filelist or generate our own.
478 * If TRUE, then we generate our own filelist from the directories in @p include_paths.
479 * If FALSE, then we use the filelist whose name is specified in @p include_paths.
480 */
481 bool make_filelist;
482
483 /**
484 * Directories to back up, or (if !make_filelist) the filelist to use.
485 * In the former case, multiple directories should be separated by spaces.
486 * If you do nothing, "/" will be used.
487 */
488 char include_paths[MAX_STR_LEN*4];
489
490 /**
491 * Directories to NOT back up. Ignored if make_filelist == FALSE.
492 * Multiple directories should be separated by spaces. /tmp, /proc,
493 * the scratchdir, and the tempdir are automatically excluded.
494 */
495 char *exclude_paths;
496
497 /**
498 * The path to restore files relative to during a restore.
499 * This is useful if you want to extract the files (to test, for example)
500 * without overwriting the old ones. Ignored during a backup.
501 */
502 char restore_path[MAX_STR_LEN];
503
504 /**
505 * A command to call BEFORE making an ISO image.
506 */
507 char call_before_iso[MAX_STR_LEN];
508
509 /**
510 * A command to call to make an ISO image.
511 */
512 char call_make_iso[MAX_STR_LEN];
513
514 /**
515 * A command to call AFTER making an ISO image.
516 */
517 char call_after_iso[MAX_STR_LEN];
518
519 /**
520 * Path to the user's kernel, or "FAILSAFE" or "SUCKS" to use the kernel
521 * included with Mindi.
522 */
523 char *kernel_path;
524
525 /**
526 * The NFS mount to back up to/restore from.
527 * If backup_media_type is not @b nfs, this is ignored.
528 * It must contain a colon, and the server's address should be in dotted-decimal IP
529 * address form. (Domain names will be resolved in post_param_configuration().)
530 */
531 char nfs_mount[MAX_STR_LEN];
532
533 /**
534 * The directory, relative to the root of @p nfs_mount, to put
535 * the backups in.
536 */
537 char nfs_remote_dir[MAX_STR_LEN];
538
539 /**
540 * A tarball containing a program called "usr/bin/post-nuke" that will be run
541 * after nuking the system. If "", do not use a post-nuke tarball.
542 */
543 char postnuke_tarball[MAX_STR_LEN];
544
545 /**
546 * If TRUE, then pass cdrecord the argument "blank=fast" to wipe the CDs before
547 * writing to them. This has no effect for DVDs.
548 */
549 bool wipe_media_first;
550
551 /**
552 * The differential level of this backup. Currently only FALSE (full backup) and TRUE
553 * (files changed since last full backup) are supported.
554 */
555 bool differential;
556
557 /**
558 * If TRUE, then don't eject media when backing up or restoring.
559 */
560 bool please_dont_eject;
561
562 /**
563 * The speed of the CD-R[W] drive.
564 */
565 int writer_speed;
566
567 /**
568 * If TRUE, then cdrecord will be passed some flags to help compensate for PCs
569 * with eccentric CD-ROM drives. If it has BurnProof technology, or is in a laptop,
570 * it probably falls into this category.
571 */
572 bool manual_tray;
573
574 /**
575 * If TRUE, do not make the first CD bootable. This is dangerous but it saves a minute
576 * or so. It is useful in testing. Use with care.
577 */
578 bool nonbootable_backup;
579
580 /**
581 * If TRUE, make the bootable CD use LILO/ELILO. If FALSE, use isolinux (the default).
582 */
583 bool make_cd_use_lilo;
584};
585
586
587
588/**
589 * A node in a directory structure.
590 * Its internals are managed by load_filelist() et al; you only need to keep track of the top node.
591 * @bug My understanding of this structure is horrendously incomplete. Could you please fill in the details?
592 */
593struct s_node {
594 /**
595 * The character this node contains.
596 */
597 char ch;
598
599 /**
600 * The node to the right of this one.
601 */
602 struct s_node *right;
603
604 /**
605 * The node below this one.
606 */
607 struct s_node *down;
608
609 /**
610 * If TRUE, then this node is selected (for restore, for example).
611 */
612 bool selected;
613
614 /**
615 * If TRUE, then we want to see the directories below this one.
616 */
617 bool expanded;
618};
619
620
621/**
622 * Information about one file.
623 * This is used as the "zeroth slice" of a biggiefile to be able to recreate
624 * its name, mode, owner, group, mtime, atime, and to be able to verify it in Compare Mode.
625 */
626struct s_filename_and_lstat_info {
627 /**
628 * The filename of the file this structure is describing.
629 */
630 char filename[MAX_STR_LEN];
631
632 /**
633 * The MD5 checksum (32 hex digits) of this file.
634 */
635 char checksum[64];
636
637 /**
638 * Unused; kept for backwards compatibility.
639 */
640 char for_backward_compatibility;
641
642 /**
643 * The stat buffer for this file.
644 * Generated with a call to <tt>lstat(&(struc->properties))</tt> where @p struc
645 * is the @p s_filename_and_lstat_info.
646 */
647 struct stat properties;
648 bool use_ntfsprog;
649};
650
651
652/**
653 * A file with associated severity if it differed in a verify or compare.
654 */
655struct s_filelist_entry {
656 /**
657 * The name of the file.
658 */
659 char filename[MAX_STR_LEN];
660 /**
661 * The severity if the file has changed between the backup and live filesystem.
662 * This is on a scale from 1 to 3, 3 being the most important. File patterns which cause
663 * a severity of 1 are:
664 * - /etc/adjtime
665 * - /etc/mtab
666 * - /var/lib/slocate
667 * - /var/lock
668 * - /var/log
669 * - /var/spool (except /var/spool/mail)
670 * - /var/run
671 * - *~
672 * - *.log
673 * - *cache*
674 * - other temporary or unimportant files
675 *
676 * File patterns which cause a severity of 2 are:
677 * - /var (except /var/lock, /var/log, /var/run, /var/spool)
678 * - /home
679 * - /root/.*
680 * - /var/lib (except /var/lib/slocate, /var/lib/rpm)
681 * - /var/spool/mail
682 *
683 * File patterns which cause a severity of 3 are:
684 * - /etc (except /etc/adjtime, /etc/mtab)
685 * - /root (except /root/.*)
686 * - /usr
687 * - /var/lib/rpm
688 * - Anything else not matched explicitly
689 *
690 * @see severity_of_difference
691 */
692 int severity;
693};
694
695
696/**
697 * A list of @c s_filelist_entry.
698 */
699struct s_filelist {
700 /**
701 * The number of entries in the list.
702 */
703 int entries;
704
705 /**
706 * The entries themselves, all @p entries of them.
707 */
708 struct s_filelist_entry el[ARBITRARY_MAXIMUM];
709};
Note: See TracBrowser for help on using the repository browser.