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

Last change on this file since 783 was 783, checked in by Bruno Cornec, 18 years ago
  • Massive rewrite continues for memory management.
  • main structure should now have all parameters allocated dynamically
  • new lib libmr.a + dir + build process reviewed to support it.
  • new include subdir to host external definitions of the new lib
  • code now compiles. Still one remaining link issues for mondorestore. This should allow for some tests soon.

(goal is to separate completely reviewed code and functions and provide clean interfaces)

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