source: MondoRescue/branches/stable/mondo/src/common/mondostructures.h@ 1063

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