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

Last change on this file since 3874 was 3874, checked in by Bruno Cornec, 18 months ago

remove differentiated support for cdrw

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