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

Last change on this file since 1364 was 1364, checked in by Bruno Cornec, 17 years ago

Remove a useless strcture + fix some compile errors in mr_list

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