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