source: MondoRescue/branches/3.1/mondo/src/common/mondostructures.h@ 3147

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