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

Last change on this file since 1769 was 1769, checked in by bruno, 12 years ago

Continue on configuration file items (compression)

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