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

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

Trunk: indent on all source files

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