source: trunk/mondo/mondo/common/mondostructures.h @ 58

Last change on this file since 58 was 58, checked in by bcornec, 14 years ago

Trunk: This version executes correctly mondoarchive
with the new memory management system (r57 didn't)

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