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

Last change on this file since 1 was 1, checked in by bcornec, 19 years ago

Initial import from latest mondo-2.04_cvs_20050503/mindi-1.04_cvs_20050503 on http://www.mondorescue.org

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