source: MondoRescue/branches/2.2.10/mondo/src/common/mondostructures.h@ 2328

Last change on this file since 2328 was 2328, checked in by Bruno Cornec, 15 years ago

r3339@localhost: bruno | 2009-08-11 23:56:01 +0200
bkpinfo->kernel_path, bkpinfo->call_before_iso, bkpinfo->call_make_iso, bkpinfo->call_burn_iso, bkpinfo->call_after_iso and bkpinfo->postnuke_tarball are now dynamically allocated

  • 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 2328 2009-08-18 13:20:42Z 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/** @def MAX_NOOF_MEDIA The maximum number of media that can be used in any one backup. */
27///* So we can override it in config.h: */
28//#ifndef MAX_NOOF_MEDIA
29#define MAX_NOOF_MEDIA 50
30//#endif
31
32/**
33 * Structure indicating one entry in the mountlist.
34 * There is one mountlist_line for each device we're keeping track of in the mountlist.
35 */
[128]36struct mountlist_line {
[1]37 /**
38 * The name of the device (/dev entry) for this mountlist line. Guaranteed to be unique.
39 */
[128]40 char device[64];
[1]41
42 /**
43 * The mountpoint for this mountlist line. Should be unique.
44 * This can be "raid", for a RAID subdisk, or "lvm", for an LVM PV.
45 */
[128]46 char mountpoint[256];
[1]47
48 /**
49 * The filesystem type of this entry. Examples: ext2, ext3, reiserfs, xfs, swap.
50 * Also, this can be "raid", for a RAID subdisk, or "lvm", for an LVM PV.
51 */
[128]52 char format[64];
[1]53
54 /**
55 * The size in kilobytes of this device. 0 or -1 indicates LVM.
56 */
[128]57 long long size;
[1]58
59 /**
[1899]60 * For ext2 and ext3, this is the filesystem label or uuid (if there is one). If not, this should be "".
[1]61 */
[128]62 char label[256];
[1295]63
[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 */
[128]71struct mountlist_itself {
[1]72 /**
73 * Number of entries in the mountlist.
74 */
[128]75 int entries;
[1]76
77 /**
78 * The list of entries, all @p entries of them.
79 */
[2188]80 struct mountlist_line el[MAX_MOUNTLIST_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 */
[128]88struct mountlist_reference {
[1]89 /**
90 * The number of entries in the list of mountlist references.
91 */
[128]92 int entries;
[1]93
94 /**
95 * The array of mountlist_line, allocated on demand.
96 */
[128]97 struct mountlist_line **el;
[1]98};
99
100/**
101 * A line in @p additional_raid_variables.
102 */
[128]103struct raid_var_line {
[1]104 /**
105 * The label for this RAID variable.
106 */
[128]107 char label[64];
[1]108
109 /**
110 * The value for this RAID variable.
111 */
[128]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 */
[128]121struct additional_raid_variables {
[1]122 /**
123 * The number of entries in the list.
124 */
[128]125 int entries;
[1]126
127 /**
128 * The list of entries, all @p entries of them.
129 */
[128]130 struct raid_var_line el[MAXIMUM_ADDITIONAL_RAID_VARS];
[1]131};
132
133/**
134 * One disk in a @p list_of_disks.
135 */
[128]136struct s_disk {
[1]137#ifdef __FreeBSD__
[128]138 /**
[1]139 * The name of this disk. If blank it will eventually get filled in automatically.
140 */
[128]141 char name[64];
[1]142#endif
143 /**
144 * The device this entry describes.
145 */
[128]146 char device[64];
[1]147
148 /**
149 * Index number of this entry in the whole disklist.
150 */
[128]151 int index;
[1967]152
[558]153 /**
154 * Type of disk.
155 */
156 char type; // ' ' = data (default), S = spare, F = faulty
[1967]157
[1]158};
159
160/**
161 * A list of @p s_disk. Every @p raid_device_record has four.
162 */
[128]163struct list_of_disks {
[1]164 /**
165 * The number of entries in the disklist.
166 */
[128]167 int entries;
[1]168
169 /**
170 * The entries themselves, all @p entries of them.
171 */
[128]172 struct s_disk el[MAXIMUM_DISKS_PER_RAID_DEV];
[1]173};
174
175/**
176 * A type of media we're backing up to.
177 */
[128]178typedef enum { none = 0, ///< No type has been set yet.
179 iso, ///< Back up to ISO images.
180 cdr, ///< Back up to recordable CDs (do not erase them).
181 cdrw, ///< Back up to CD-RWs and blank them first.
182 dvd, ///< Back up to DVD+R[W] or DVD-R[W] disks.
183 cdstream, ///< Back up to recordable CDs but treat them like a tape streamer.
184 nfs, ///< Back up to an NFS mount on the local subnet.
185 tape, ///< Back up to tapes.
[1687]186 usb, ///< Back up to USB devices.
[128]187 udev ///< Back up to another unsupported device; just send a stream of bytes.
188} t_bkptype;
[1]189
190/**
191 * A type of file in the catalog of recent archives.
192 */
[128]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;
[1]197
[1967]198/**
199 * A type of file in the catalog of recent archives.
200 */
201typedef enum {
202 nuke = 0, /// Nuke mode
203 interactive, /// Interactive mode
204 compare, /// Compare mode
205 mbr, /// MBR mode
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 *
[2321]328 * To fill out the bkpinfo first call init_bkpinfo() and pre_param_configuration(). Then set
[1]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.
337 * If backup_media_type is @b cdr, @b cdrw, or @b cdstream, this should be the SCSI node (e.g. 0,1,0).
[1687]338 * If backup_media_type is @b dvd, @b tape, @b usb or @b udev, this should be a /dev entry.
[1]339 * If backup_media_type is anything else, this should be blank.
340 */
[2325]341 char *media_device;
[1]342
343 /**
344 * An array containing the sizes of each media in our backup set, in MB.
345 * For example, media 1's size would be stored in media_size[1].
346 * Element 0 is unused.
347 * If the size should be autodetected, make it -1 (preferable) or 0.
348 * @bug This should probably be only one variable, not an array.
349 */
[128]350 long media_size[MAX_NOOF_MEDIA + 1];
[1]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 */
[128]364 char boot_loader;
[1]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 */
[2326]371 char *boot_device;
[1]372
373 /**
374 * The compression program to use. Currently supported
375 * choices are lzop and bzip2; gzip may also work. This is ignored if
376 * compression_level is 0.
377 */
[2326]378 char *zip_exe;
[1]379
380 /**
381 * The extension your compression program uses. lzop uses lzo, bzip uses
382 * bz2, gzip uses gz, etc. Do not include the dot.
383 */
[2327]384 char *zip_suffix;
[1]385
386 /**
387 * Devices to back up as biggiefiles.
388 *
389 * This is useful for backing up NTFS partitions.
[296]390 * @c ntfsclone is used to back up only the used sectors, so the space tradeoff is not bad.
[1]391 * However, several caveats apply to such a partition:
392 * - It must not be mounted during the backup
[296]393 * - It must be in a format that ntfsclone knows how to handle, i.e. NTFS
[1]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 */
[2327]399 char *image_devs;
[1]400
401 /**
402 * The compression level (1-9) to use. 0 disables compression.
403 */
[128]404 int compression_level;
[1]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 */
[128]412 bool use_lzo;
[1]413
414 /**
[998]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 /**
[1]423 * If TRUE, then we should verify a backup.
424 */
[128]425 bool verify_data;
[1]426
427 /**
428 * If TRUE, then we should back up some data.
429 */
[128]430 bool backup_data;
[1]431
432 /**
433 * If TRUE, then we should restore some data.
434 */
[128]435 bool restore_data;
[1]436
[128]437
[1]438 /**
439 * If TRUE, then we should backup/restore using star, not afio
440 */
[128]441 bool use_star;
[1]442
[128]443
[1]444 /**
445 * Size of internal block reads/writes
446 */
[128]447 long internal_tape_block_size;
448
[1]449 /**
450 * If TRUE, we're making a CD that will autonuke without confirmation when booted.
451 */
[128]452 bool disaster_recovery;
[1]453
454 /**
455 * The directory we're backing up to.
456 * If backup_media_type is @b iso, then this is that directory.
457 * If backup_media_type is anything else, this is ignored.
458 */
[2323]459 char *isodir;
[1]460
[20]461/**
462 * The prefix to put in front of media number
463 * If backup_media_type is @b iso, then this is the prefix for the filename
464 * If backup_media_type is anything else, this is ignored.
465 */
[2322]466 char *prefix;
[20]467
[1]468 /**
469 * The scratch directory to use.
470 * This is the "stage" that the CD image is made directly from.
471 * As such, it needs to be at least as large as the largest CD/DVD/ISO.
472 */
[2320]473 char *scratchdir;
[1]474
475 /**
476 * The temp directory to use.
477 * This is where filesets are stored by the archival threads before
478 * the main thread moves them to the scratchdir. You don't need a lot
479 * of space here.
480 */
[2321]481 char *tmpdir;
[1]482
483 /**
484 * The optimal size for each fileset. This is set automatically in
485 * post_param_configuration() based on your @p backup_media_type; you
486 * needn't set it yourself.
487 */
[128]488 long optimal_set_size;
[1]489
490 /**
491 * The type of media we're backing up to.
492 */
[128]493 t_bkptype backup_media_type;
[1]494
495 /**
496 * Whether we should use a premade filelist or generate our own.
497 * If TRUE, then we generate our own filelist from the directories in @p include_paths.
498 * If FALSE, then we use the filelist whose name is specified in @p include_paths.
499 */
[128]500 bool make_filelist;
[1]501
502 /**
503 * Directories to back up, or (if !make_filelist) the filelist to use.
504 * In the former case, multiple directories should be separated by spaces.
505 * If you do nothing, "/" will be used.
506 */
[2320]507 char *include_paths;
[1]508
509 /**
510 * Directories to NOT back up. Ignored if make_filelist == FALSE.
511 * Multiple directories should be separated by spaces. /tmp, /proc,
512 * the scratchdir, and the tempdir are automatically excluded.
513 */
[2320]514 char *exclude_paths;
[1]515
516 /**
517 * The path to restore files relative to during a restore.
518 * This is useful if you want to extract the files (to test, for example)
519 * without overwriting the old ones. Ignored during a backup.
520 */
[2327]521 char *restore_path;
[1]522
523 /**
524 * A command to call BEFORE making an ISO image.
525 */
[2328]526 char *call_before_iso;
[1]527
528 /**
529 * A command to call to make an ISO image.
530 */
[2328]531 char *call_make_iso;
[1]532
533 /**
534 * A command to call to burn the ISO image.
535 */
[2328]536 char *call_burn_iso;
[1]537
538 /**
539 * A command to call AFTER making an ISO image.
[2328]540 * BERLIOS: Never initialized in code !!
[1]541 */
[2328]542 char *call_after_iso;
[1]543
544 /**
545 * Path to the user's kernel, or "FAILSAFE" or "SUCKS" to use the kernel
546 * included with Mindi.
547 */
[2328]548 char *kernel_path;
[1]549
550 /**
551 * The NFS mount to back up to/restore from.
552 * If backup_media_type is not @b nfs, this is ignored.
553 * It must contain a colon, and the server's address should be in dotted-decimal IP
554 * address form. (Domain names will be resolved in post_param_configuration().)
555 */
[2325]556 char *nfs_mount;
[1]557
558 /**
559 * The directory, relative to the root of @p nfs_mount, to put
560 * the backups in.
561 */
[2325]562 char *nfs_remote_dir;
[1]563
564 /**
[2224]565 * The potential user to use for NFS backup
566 */
[2226]567 char *nfs_user;
[2224]568
569 /**
[1]570 * A tarball containing a program called "usr/bin/post-nuke" that will be run
571 * after nuking the system. If "", do not use a post-nuke tarball.
572 */
[2328]573 char *postnuke_tarball;
[1]574
575 /**
576 * If TRUE, then pass cdrecord the argument "blank=fast" to wipe the CDs before
577 * writing to them. This has no effect for DVDs.
578 */
[128]579 bool wipe_media_first;
[1]580
[1967]581// patch by Herman Kuster
[1]582 /**
583 * The differential level of this backup. Currently only 0 (full backup) and 1
584 * (files changed since last full backup) are supported.
585 */
[128]586 int differential;
[1967]587// end patch
[1]588
589 /**
590 * If TRUE, then don't eject media when backing up or restoring.
591 */
[128]592 bool please_dont_eject;
[1]593
594 /**
595 * The speed of the CD-R[W] drive.
596 */
[128]597 int cdrw_speed;
[1]598
599 /**
600 * If TRUE, then cdrecord will be passed some flags to help compensate for PCs
601 * with eccentric CD-ROM drives. If it has BurnProof technology, or is in a laptop,
602 * it probably falls into this category.
603 */
[128]604 bool manual_cd_tray;
[1]605
606 /**
607 * If TRUE, do not make the first CD bootable. This is dangerous but it saves a minute
608 * or so. It is useful in testing. Use with care.
609 */
[128]610 bool nonbootable_backup;
[1]611
612 /**
613 * If TRUE, make the bootable CD use LILO/ELILO. If FALSE, use isolinux (the default).
614 */
[128]615 bool make_cd_use_lilo;
[1948]616
617 /**
618 * If TRUE, make the the tape bootable. If FALSE, normal tape, the default
619 */
620 bool use_obdr;
[1967]621
622 /**
623 * Nature of the restore
624 */
625 t_restore_mode restore_mode;
[1]626};
627
628
629
630/**
631 * A node in a directory structure.
632 * Its internals are managed by load_filelist() et al; you only need to keep track of the top node.
633 * @bug My understanding of this structure is horrendously incomplete. Could you please fill in the details?
634 */
[128]635struct s_node {
[1]636 /**
637 * The character this node contains.
638 */
[128]639 char ch;
[1]640
641 /**
642 * The node to the right of this one.
643 */
[128]644 struct s_node *right;
[1]645
646 /**
647 * The node below this one.
648 */
[128]649 struct s_node *down;
[1]650
651 /**
652 * If TRUE, then this node is selected (for restore, for example).
653 */
[128]654 bool selected;
[1]655
656 /**
657 * If TRUE, then we want to see the directories below this one.
658 */
[128]659 bool expanded;
[1]660};
661
662
663
664/**
665 * Information about one file.
666 * This is used as the "zeroth slice" of a biggiefile to be able to recreate
667 * its name, mode, owner, group, mtime, atime, and to be able to verify it in Compare Mode.
668 */
669struct s_filename_and_lstat_info {
[128]670 /**
[1]671 * The filename of the file this structure is describing.
672 */
673 char filename[MAX_STR_LEN];
674
[128]675 /**
[1]676 * The MD5 checksum (32 hex digits) of this file.
677 */
678 char checksum[64];
679
[128]680 /**
[1]681 * Unused; kept for backwards compatibility.
682 */
683 char for_backward_compatibility;
684
[128]685 /**
[1]686 * The stat buffer for this file.
687 * Generated with a call to <tt>lstat(&(struc->properties))</tt> where @p struc
688 * is the @p s_filename_and_lstat_info.
689 */
690 struct stat properties;
[296]691 bool use_ntfsprog;
[1]692};
693
694
695/**
696 * A file with associated severity if it differed in a verify or compare.
697 */
698struct s_filelist_entry {
[128]699 /**
[1]700 * The name of the file.
701 */
702 char filename[MAX_STR_LEN];
[128]703 /**
[1]704 * The severity if the file has changed between the backup and live filesystem.
705 * This is on a scale from 1 to 3, 3 being the most important. File patterns which cause
706 * a severity of 1 are:
707 * - /etc/adjtime
708 * - /etc/mtab
709 * - /var/lib/slocate
710 * - /var/lock
711 * - /var/log
712 * - /var/spool (except /var/spool/mail)
713 * - /var/run
714 * - *~
715 * - *.log
716 * - *cache*
717 * - other temporary or unimportant files
718 *
719 * File patterns which cause a severity of 2 are:
720 * - /var (except /var/lock, /var/log, /var/run, /var/spool)
721 * - /home
722 * - /root/.*
723 * - /var/lib (except /var/lib/slocate, /var/lib/rpm)
724 * - /var/spool/mail
725 *
726 * File patterns which cause a severity of 3 are:
727 * - /etc (except /etc/adjtime, /etc/mtab)
728 * - /root (except /root/.*)
729 * - /usr
730 * - /var/lib/rpm
731 * - Anything else not matched explicitly
732 *
733 * @see severity_of_difference
734 */
[128]735 int severity;
[1]736};
737
738
739/**
740 * A list of @c s_filelist_entry.
741 */
742struct s_filelist {
[128]743 /**
[1]744 * The number of entries in the list.
745 */
[128]746 int entries;
[1]747
[128]748 /**
[1]749 * The entries themselves, all @p entries of them.
750 */
751 struct s_filelist_entry el[ARBITRARY_MAXIMUM];
752};
753
754
755/**
756 * An entry in the tape catalog.
757 */
758struct s_tapecat_entry {
[128]759 /**
[1]760 * The type of archive it is (afioball, slice, or something else).
761 */
762 t_archtype type;
763
[128]764 /**
[1]765 * The filelist number or biggiefile (not slice!) number.
766 */
767 int number;
768
[128]769 /**
[1]770 * The slice number if it's a biggiefile.
771 */
772 long aux;
773
[128]774 /**
[1]775 * The tape position at the point this entry was added.
776 */
777 long long tape_posK;
778
[128]779 /**
[1]780 * The filename of the file cataloged here.
781 */
[128]782 char fname[MAX_TAPECAT_FNAME_LEN + 1];
[1]783};
784
785
786/**
787 * A tape catalog, made of a list of @p s_tapecat_entry.
788 */
789struct s_tapecatalog {
[128]790 /**
[1]791 * The number of entries in the tape catalog.
792 */
793 int entries;
794
[128]795 /**
[1]796 * The entries themselves, all @p entries of them.
797 */
798 struct s_tapecat_entry el[MAX_TAPECATALOG_ENTRIES];
799};
Note: See TracBrowser for help on using the repository browser.