source: MondoRescue/branches/3.3/mondo/src/common/mondostructures.h@ 3890

Last change on this file since 3890 was 3890, checked in by Bruno Cornec, 4 months ago

Use a bkpinfo boolean to manage the automatic recovery mode

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