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

Last change on this file since 998 was 998, checked in by Bruno Cornec, 17 years ago

Attempt to solve #113

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