source: MondoRescue/trunk/mondo/mondo/common/mondostructures.h@ 688

Last change on this file since 688 was 561, checked in by bcornec, 18 years ago

merge -r 542:560 $SVN_M/branches/stable

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