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

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

merge -r 506:516 $SVN_M/branches/stable

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