[1] | 1 | /* libmondo-archive.c
|
---|
[99] | 2 | $Id: libmondo-archive.c 949 2006-11-19 01:11:58Z bruno $
|
---|
[1] | 3 |
|
---|
| 4 | subroutines to handle the archiving of files
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | 07/14
|
---|
| 9 | - moved all ACL, xattr stuff here from libmondo-filelist.c
|
---|
| 10 |
|
---|
| 11 | 07/12
|
---|
| 12 | - when trying to find boot loader, look for /boot's /dev, not just /'s dev
|
---|
| 13 |
|
---|
| 14 | 07/10
|
---|
| 15 | - better detection of changed files
|
---|
| 16 | - added ACL, xattr support for afio
|
---|
| 17 |
|
---|
| 18 | 06/17
|
---|
| 19 | - backup with partimagehack if NTFS device; dd, if non-NTFS device
|
---|
| 20 |
|
---|
| 21 | 06/14
|
---|
| 22 | - use mondorescue.iso instead of mindi.iso
|
---|
| 23 |
|
---|
| 24 | 04/28
|
---|
| 25 | - cleaned up if/then architecture-specific stuff re: CD-R(W)s
|
---|
| 26 |
|
---|
| 27 | 04/03
|
---|
| 28 | - added star support
|
---|
| 29 |
|
---|
| 30 | 03/12
|
---|
| 31 | - modified offer_to_write_floppies() to support dual-disk boot/root thing
|
---|
| 32 |
|
---|
| 33 | 01/20/2004
|
---|
| 34 | - reformat dvd twice if necessary
|
---|
| 35 |
|
---|
| 36 | 12/01/2003
|
---|
| 37 | - added pause_for_N_seconds(5, "Letting DVD drive settle");
|
---|
| 38 |
|
---|
| 39 | 11/23
|
---|
| 40 | - added #define DVDRWFORMAT
|
---|
| 41 |
|
---|
| 42 | 11/20
|
---|
| 43 | - use --no-emul-boot -b isolinux.bin instead of -b mindi-boot.2880.img
|
---|
| 44 |
|
---|
| 45 | 10/23
|
---|
| 46 | - wipe DVD at start, whether or not disk is DVD-RW; this is
|
---|
| 47 | just a test, to see why dvd+rw-format followed by growiosfs
|
---|
| 48 | locks up the drive
|
---|
| 49 | - use the singlethreaded make_afioballs_and_images_OLD()
|
---|
| 50 | instead of the multithreaded make_afioballs_and_images()
|
---|
| 51 | if backing up to tape
|
---|
| 52 |
|
---|
| 53 | 10/21
|
---|
| 54 | - if backing up to dvd, look for relevant tools;
|
---|
| 55 | abort if missing
|
---|
| 56 |
|
---|
| 57 | 10/15
|
---|
| 58 | - UI tweaks
|
---|
| 59 |
|
---|
| 60 | 10/10
|
---|
| 61 | - eject/inject DVD after wiping it
|
---|
| 62 |
|
---|
| 63 | 09/27
|
---|
| 64 | - pause_and_ask_for_cdr() will now blank DVD if necessary
|
---|
| 65 |
|
---|
| 66 | 09/26
|
---|
| 67 | - proper reporting of media type in displayed strings
|
---|
| 68 | (i.e. DVD if DVD, CD if CD, etc.)
|
---|
| 69 |
|
---|
| 70 | 09/25
|
---|
| 71 | - add DVD support
|
---|
| 72 |
|
---|
| 73 | 09/23
|
---|
| 74 | - malloc/free global strings in new subroutines - malloc_libmondo_global_strings()
|
---|
| 75 | and free_libmondo_global_strings() - which are in libmondo-tools.c
|
---|
| 76 |
|
---|
| 77 | 09/15
|
---|
| 78 | - changed a bunch of char[MAX_STR_LEN]'s to char*; malloc; free;
|
---|
| 79 |
|
---|
| 80 | 09/14
|
---|
| 81 | - cosmetic bug re: call to 'which dvdrecord'
|
---|
| 82 |
|
---|
| 83 | 09/09
|
---|
| 84 | - copy `locate isolinux.bin | tail -n1` to CD before calling mkisfso
|
---|
| 85 | if file is missing (in which case, bug in Mindi.pl!)
|
---|
| 86 | - reduced noof_threads from 3 to 2
|
---|
| 87 | - fixed cosmetic bug in make_slices_and_images()
|
---|
| 88 |
|
---|
| 89 | 09/02
|
---|
| 90 | - fixed cosmetic bug in verify_data()
|
---|
| 91 |
|
---|
| 92 | 05/01 - 08/31
|
---|
| 93 | - added partimagehack hooks
|
---|
| 94 | - make twice as many archives at once as before
|
---|
| 95 | - fixed syntax error re: system(xxx,FALSE)
|
---|
| 96 | - unmount CD-ROM before burning (necessary for RH8/9)
|
---|
| 97 | - only ask for new media if sensible
|
---|
| 98 | - fixed mondoarchive -Vi multi-CD verify bug (Tom Mortell)
|
---|
| 99 | - use single-threaded make_afioballs_and_images() if FreeBSD
|
---|
| 100 | - fixed bug on line 476 (Joshua Oreman)
|
---|
| 101 | - re-enabled the pause, for people w/ weird CD-ROM drives
|
---|
| 102 | - added Joshua Oreman's FreeBSD patches
|
---|
| 103 | - don't listen to please_dont_eject_when_restoring
|
---|
| 104 | ...after all, we're not restoring :)
|
---|
| 105 |
|
---|
| 106 | 04/01 - 04/30
|
---|
| 107 | - cleaned up archive_this_fileset()
|
---|
| 108 | - decreased ARCH_THREADS from 3 to 2
|
---|
| 109 | - pause_and_ask_for_cd() --- calls retract_CD_tray_and_defeat_autorun()
|
---|
| 110 | - call assert() and log_OS_error() in various places
|
---|
| 111 | - cleaned up code a bit
|
---|
| 112 | - increased ARCH_THREADS from 2 to 3
|
---|
| 113 | - misc clean-up (Tom Mortell)
|
---|
| 114 |
|
---|
| 115 | 03/15/2003
|
---|
| 116 | - fixed problem w/ multi-ISO verify cycle (Tom Mortell)
|
---|
| 117 |
|
---|
| 118 | 11/01 - 12/31/2002
|
---|
| 119 | - removed references to make_afioballs_and_images_OLD()
|
---|
| 120 | - added some error-checking to make_afioballs_in_background
|
---|
| 121 | - make_iso_and_go_on() now copies Mondo's autorun file to CD
|
---|
| 122 | - set scratchdir dir to 1744 when burning CD
|
---|
| 123 | - cleaned up code a bit
|
---|
| 124 | - in call_mindi_...(), gracefully handle the user's input
|
---|
| 125 | if they specify the boot loader but not the boot device
|
---|
| 126 | - offer to abort if GRUB is boot loader and /dev/md* is
|
---|
| 127 | the boot device (bug in grub-install)
|
---|
| 128 | - if boot loader is R then write RAW as bootloader.name
|
---|
| 129 | - multithreaded make_afioballs_and_images()
|
---|
| 130 | - fixed slice_up_file_etc() for 0-compression users
|
---|
| 131 | - line 1198: added call to is_this_file_compressed() to stop
|
---|
| 132 | slice_up_file_etc() from compressing files which are
|
---|
| 133 | already compressed
|
---|
| 134 | - other hackery related to the above enhancement
|
---|
| 135 | - afio no longer forcibly compresses all files (i.e. I dropped
|
---|
| 136 | the -U following suggestions from users); let's see if
|
---|
| 137 | it works :)
|
---|
| 138 |
|
---|
| 139 | 10/01 - 10/31
|
---|
| 140 | - mondoarchive (with no parameters) wasn't working
|
---|
| 141 | if user said yes when asked if BurnProof drive; FIXED
|
---|
| 142 | - if manual CD tray and writing to ISO's then prompt
|
---|
| 143 | for each & every new CD
|
---|
| 144 | - moved a lot of subroutines here
|
---|
| 145 | from mondo-archive.c and mondo-floppies.c
|
---|
| 146 |
|
---|
| 147 | 09/01 - 09/30
|
---|
| 148 | - if CD not burned OK then don't try to verify
|
---|
| 149 | - change 64k to TAPE_BLOCK_SIZE
|
---|
| 150 | - run_program_and_log_output() now takes boolean operator to specify
|
---|
| 151 | whether it will log its activities in the event of _success_
|
---|
| 152 | - orig_vfy_flag_val added to write_iso_and_go_on, to restore bkpinfo->verify_data's
|
---|
| 153 | value if altered by verify_cd_image()
|
---|
| 154 |
|
---|
| 155 | 08/01 - 08/31
|
---|
| 156 | - use data structure to store the fname, checksum, mods & perms of each bigfile
|
---|
| 157 | ... biggiestruct :)
|
---|
| 158 | - bigger tmp[]'s in a few places
|
---|
| 159 | - cleaned up the (user-friendly) counting of biggiefiles a bit
|
---|
| 160 | - if media_size[N]<=0 then catch it & abort, unless it's tape,
|
---|
| 161 | in which case, allow it
|
---|
| 162 | - cleaned up a lot of log_it() calls
|
---|
| 163 | - fixed NULL filename-related bug in can_we_fit_these_files_on_media()
|
---|
| 164 | - deleted can_we_fit.....() subroutine because it was causing problems
|
---|
| 165 | --- moved its code into the one subroutine which called it
|
---|
| 166 | - created [08/01/2002]
|
---|
| 167 | */
|
---|
| 168 |
|
---|
| 169 | /**
|
---|
| 170 | * @file
|
---|
| 171 | * Functions to handle backing up data.
|
---|
| 172 | * This is the main file (at least the longest one) in libmondo.
|
---|
| 173 | */
|
---|
| 174 |
|
---|
| 175 | #include "../common/my-stuff.h"
|
---|
| 176 | #include "../common/mondostructures.h"
|
---|
| 177 | #include "libmondo-string-EXT.h"
|
---|
| 178 | #include "libmondo-stream-EXT.h"
|
---|
| 179 | #include "libmondo-devices-EXT.h"
|
---|
| 180 | #include "libmondo-tools-EXT.h"
|
---|
[541] | 181 | #include "libmondo-gui-EXT.h"
|
---|
[1] | 182 | #include "libmondo-fork-EXT.h"
|
---|
| 183 | #include "libmondo-files-EXT.h"
|
---|
| 184 | #include "libmondo-filelist-EXT.h"
|
---|
| 185 | #include "libmondo-tools-EXT.h"
|
---|
| 186 | #include "libmondo-verify-EXT.h"
|
---|
| 187 | #include "libmondo-archive.h"
|
---|
[541] | 188 | #include "lib-common-externs.h"
|
---|
[1] | 189 | #include <sys/sem.h>
|
---|
| 190 | #include <sys/types.h>
|
---|
| 191 | #include <sys/ipc.h>
|
---|
| 192 | #include <stdarg.h>
|
---|
| 193 | #define DVDRWFORMAT 1
|
---|
| 194 |
|
---|
| 195 |
|
---|
| 196 |
|
---|
| 197 | /** @def DEFAULT_1722MB_DISK The default 1.722M floppy disk to write images to. */
|
---|
| 198 | /** @def BACKUP_1722MB_DISK The 1.722M floppy disk to try if the default fails. */
|
---|
| 199 |
|
---|
| 200 | #ifdef __FreeBSD__
|
---|
[128] | 201 | #define DEFAULT_1722MB_DISK "/dev/fd0.1722"
|
---|
| 202 | #define BACKUP_1722MB_DISK "/dev/fd0.1722"
|
---|
[1] | 203 | #else
|
---|
[128] | 204 | #define DEFAULT_1722MB_DISK "/dev/fd0u1722"
|
---|
| 205 | #define BACKUP_1722MB_DISK "/dev/fd0H1722"
|
---|
[1] | 206 | #ifndef _SEMUN_H
|
---|
[128] | 207 | #define _SEMUN_H
|
---|
[1] | 208 |
|
---|
| 209 | /**
|
---|
| 210 | * The semaphore union, provided only in case the user's system doesn't.
|
---|
| 211 | */
|
---|
[128] | 212 | union semun {
|
---|
| 213 | int val;
|
---|
| 214 | struct semid_ds *buf;
|
---|
| 215 | unsigned short int *array;
|
---|
| 216 | struct seminfo *__buf;
|
---|
| 217 | };
|
---|
[1] | 218 | #endif
|
---|
[128] | 219 | #endif /* __FreeBSD__ */
|
---|
[1] | 220 |
|
---|
| 221 | /*@unused@*/
|
---|
[99] | 222 | //static char cvsid[] = "$Id: libmondo-archive.c 949 2006-11-19 01:11:58Z bruno $";
|
---|
[1] | 223 |
|
---|
| 224 | /* *************************** external global vars ******************/
|
---|
| 225 | extern int g_current_media_number;
|
---|
| 226 | extern int g_currentY;
|
---|
| 227 | extern bool g_text_mode;
|
---|
| 228 | extern bool g_exiting;
|
---|
| 229 | extern long g_current_progress;
|
---|
[128] | 230 | extern FILE *g_tape_stream;
|
---|
[1] | 231 | extern long long g_tape_posK;
|
---|
| 232 | extern char *g_mondo_home;
|
---|
| 233 | extern char *g_tmpfs_mountpt;
|
---|
| 234 | extern bool g_cd_recovery;
|
---|
| 235 | extern char *g_serial_string;
|
---|
| 236 |
|
---|
[948] | 237 | extern char *g_getfacl;
|
---|
| 238 | extern char *g_getfattr;
|
---|
| 239 |
|
---|
| 240 |
|
---|
| 241 |
|
---|
[1] | 242 | /**
|
---|
| 243 | * @addtogroup globalGroup
|
---|
| 244 | * @{
|
---|
| 245 | */
|
---|
| 246 | /**
|
---|
| 247 | * The current backup media type in use.
|
---|
| 248 | */
|
---|
[128] | 249 | t_bkptype g_backup_media_type = none;
|
---|
[1] | 250 |
|
---|
| 251 | /**
|
---|
| 252 | * Incremented by each archival thread when it starts up. After that,
|
---|
| 253 | * this is the number of threads running.
|
---|
| 254 | */
|
---|
| 255 | int g_current_thread_no = 0;
|
---|
| 256 |
|
---|
| 257 | /* @} - end of globalGroup */
|
---|
| 258 |
|
---|
| 259 | extern int g_noof_rows;
|
---|
| 260 |
|
---|
| 261 | /* Semaphore-related code */
|
---|
| 262 |
|
---|
| 263 | static int set_semvalue(void);
|
---|
| 264 | static void del_semvalue(void);
|
---|
| 265 | static int semaphore_p(void);
|
---|
| 266 | static int semaphore_v(void);
|
---|
| 267 |
|
---|
| 268 | static int g_sem_id;
|
---|
| 269 | static int g_sem_key;
|
---|
| 270 |
|
---|
| 271 |
|
---|
| 272 |
|
---|
| 273 |
|
---|
| 274 | /**
|
---|
| 275 | * Initialize the semaphore.
|
---|
| 276 | * @see del_semvalue
|
---|
| 277 | * @see semaphore_p
|
---|
| 278 | * @see semaphore_v
|
---|
| 279 | * @return 1 for success, 0 for failure.
|
---|
| 280 | */
|
---|
[128] | 281 | static int set_semvalue(void) // initializes semaphore
|
---|
[1] | 282 | {
|
---|
[128] | 283 | union semun sem_union;
|
---|
| 284 | sem_union.val = 1;
|
---|
| 285 | if (semctl(g_sem_id, 0, SETVAL, sem_union) == -1) {
|
---|
| 286 | return (0);
|
---|
| 287 | }
|
---|
| 288 | return (1);
|
---|
[1] | 289 | }
|
---|
| 290 |
|
---|
| 291 | /**
|
---|
| 292 | * Frees (deletes) the semaphore. Failure is indicated by a log
|
---|
| 293 | * message.
|
---|
| 294 | * @see set_semvalue
|
---|
| 295 | */
|
---|
[128] | 296 | static void del_semvalue(void) // deletes semaphore
|
---|
[1] | 297 | {
|
---|
[128] | 298 | union semun sem_union;
|
---|
[1] | 299 |
|
---|
[128] | 300 | if (semctl(g_sem_id, 0, IPC_RMID, sem_union) == -1) {
|
---|
| 301 | log_msg(3, "Failed to delete semaphore");
|
---|
| 302 | }
|
---|
[1] | 303 | }
|
---|
| 304 |
|
---|
| 305 | /**
|
---|
| 306 | * Acquire (increment) the semaphore (change status to P).
|
---|
| 307 | * @return 1 for success, 0 for failure.
|
---|
| 308 | * @see semaphore_v
|
---|
| 309 | */
|
---|
[128] | 310 | static int semaphore_p(void) // changes status to 'P' (waiting)
|
---|
[1] | 311 | {
|
---|
[128] | 312 | struct sembuf sem_b;
|
---|
[1] | 313 |
|
---|
[128] | 314 | sem_b.sem_num = 0;
|
---|
| 315 | sem_b.sem_op = -1; // P()
|
---|
| 316 | sem_b.sem_flg = SEM_UNDO;
|
---|
| 317 | if (semop(g_sem_id, &sem_b, 1) == -1) {
|
---|
| 318 | log_msg(3, "semaphore_p failed");
|
---|
| 319 | return (0);
|
---|
| 320 | }
|
---|
| 321 | return (1);
|
---|
[1] | 322 | }
|
---|
| 323 |
|
---|
| 324 | /**
|
---|
| 325 | * Free (decrement) the semaphore (change status to V).
|
---|
| 326 | * @return 1 for success, 0 for failure.
|
---|
| 327 | */
|
---|
[128] | 328 | static int semaphore_v(void) // changes status to 'V' (free)
|
---|
[1] | 329 | {
|
---|
[128] | 330 | struct sembuf sem_b;
|
---|
[1] | 331 |
|
---|
[128] | 332 | sem_b.sem_num = 0;
|
---|
| 333 | sem_b.sem_op = 1; // V()
|
---|
| 334 | sem_b.sem_flg = SEM_UNDO;
|
---|
| 335 | if (semop(g_sem_id, &sem_b, 1) == -1) {
|
---|
| 336 | log_msg(3, "semaphore_v failed");
|
---|
| 337 | return (0);
|
---|
| 338 | }
|
---|
| 339 | return (1);
|
---|
[1] | 340 | }
|
---|
| 341 |
|
---|
| 342 |
|
---|
| 343 | //------------------------------------------------------
|
---|
| 344 |
|
---|
| 345 |
|
---|
| 346 | /**
|
---|
| 347 | * Size in megabytes of the buffer afforded to the executable "buffer".
|
---|
| 348 | * This figure is used when we calculate how much data we have probably 'lost'
|
---|
| 349 | * when writing off the end of tape N, so that we can then figure out how much
|
---|
| 350 | * data we must recreate & write to the start of tape N+1.
|
---|
| 351 | */
|
---|
| 352 | extern int g_tape_buffer_size_MB;
|
---|
| 353 |
|
---|
| 354 |
|
---|
| 355 |
|
---|
| 356 |
|
---|
| 357 | int
|
---|
[128] | 358 | archive_this_fileset_with_star(struct s_bkpinfo *bkpinfo, char *filelist,
|
---|
| 359 | char *fname, int setno)
|
---|
[1] | 360 | {
|
---|
[128] | 361 | int retval = 0;
|
---|
| 362 | unsigned int res = 0;
|
---|
| 363 | int tries = 0;
|
---|
| 364 | char *command;
|
---|
| 365 | char *zipparams;
|
---|
| 366 | char *tmp;
|
---|
| 367 | char *p;
|
---|
[1] | 368 |
|
---|
[128] | 369 | malloc_string(command);
|
---|
| 370 | malloc_string(zipparams);
|
---|
| 371 | malloc_string(tmp);
|
---|
[1] | 372 |
|
---|
[128] | 373 | if (!does_file_exist(filelist)) {
|
---|
| 374 | sprintf(tmp, "(archive_this_fileset) - filelist %s does not exist",
|
---|
| 375 | filelist);
|
---|
| 376 | log_to_screen(tmp);
|
---|
| 377 | return (1);
|
---|
[1] | 378 | }
|
---|
| 379 |
|
---|
[128] | 380 | sprintf(tmp, "echo hi > %s 2> /dev/null", fname);
|
---|
| 381 | if (system(tmp)) {
|
---|
| 382 | fatal_error("Unable to write tarball to scratchdir");
|
---|
| 383 | }
|
---|
| 384 |
|
---|
| 385 | sprintf(command, "star H=star list=%s -c " STAR_ACL_SZ " file=%s",
|
---|
| 386 | filelist, fname);
|
---|
| 387 | if (bkpinfo->use_lzo) {
|
---|
| 388 | fatal_error("Can't use lzop");
|
---|
| 389 | }
|
---|
| 390 | if (bkpinfo->compression_level > 0) {
|
---|
| 391 | strcat(command, " -bz");
|
---|
| 392 | }
|
---|
| 393 | sprintf(command + strlen(command), " 2>> %s", MONDO_LOGFILE);
|
---|
| 394 | log_msg(4, "command = '%s'", command);
|
---|
| 395 |
|
---|
| 396 | for (res = 99, tries = 0; tries < 3 && res != 0; tries++) {
|
---|
| 397 | log_msg(5, "command='%s'", command);
|
---|
| 398 | res = system(command);
|
---|
| 399 | strcpy(tmp, last_line_of_file(MONDO_LOGFILE));
|
---|
| 400 | log_msg(1, "res=%d; tmp='%s'", res, tmp);
|
---|
| 401 | if (bkpinfo->use_star && (res == 254 || res == 65024)
|
---|
| 402 | && strstr(tmp, "star: Processed all possible files")
|
---|
| 403 | && tries > 0) {
|
---|
| 404 | log_msg(1, "Star returned nonfatal error");
|
---|
| 405 | res = 0;
|
---|
| 406 | }
|
---|
| 407 | if (res) {
|
---|
| 408 | log_OS_error(command);
|
---|
| 409 | p = strstr(command, "-acl ");
|
---|
| 410 | if (p) {
|
---|
| 411 | p[0] = p[1] = p[2] = p[3] = ' ';
|
---|
| 412 | log_msg(1, "new command = '%s'", command);
|
---|
| 413 | } else {
|
---|
| 414 | log_msg(3,
|
---|
| 415 | "Attempt #%d failed. Pausing 3 seconds and retrying...",
|
---|
| 416 | tries + 1);
|
---|
| 417 | sleep(3);
|
---|
| 418 | }
|
---|
| 419 | }
|
---|
| 420 | }
|
---|
| 421 | retval += res;
|
---|
| 422 | if (retval) {
|
---|
| 423 | log_msg(3, "Failed to write set %d", setno);
|
---|
| 424 | } else if (tries > 1) {
|
---|
| 425 | log_msg(3, "Succeeded in writing set %d, on try #%d", setno,
|
---|
| 426 | tries);
|
---|
| 427 | }
|
---|
| 428 |
|
---|
| 429 | paranoid_free(command);
|
---|
| 430 | paranoid_free(zipparams);
|
---|
| 431 | paranoid_free(tmp);
|
---|
| 432 | return (retval);
|
---|
[1] | 433 | }
|
---|
| 434 |
|
---|
| 435 |
|
---|
| 436 | /**
|
---|
| 437 | * Call @c afio to archive the filelist @c filelist to the file @c fname.
|
---|
| 438 | *
|
---|
| 439 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 440 | * - @c compression_level
|
---|
| 441 | * - @c scratchdir (only verifies existence)
|
---|
| 442 | * - @c tmpdir (only verifies existence)
|
---|
| 443 | * - @c zip_exe
|
---|
| 444 | * - @c zip_suffix
|
---|
| 445 | * @param filelist The path to a file containing a list of files to be archived
|
---|
| 446 | * in this fileset.
|
---|
| 447 | * @param fname The output file to archive to.
|
---|
| 448 | * @param setno This fileset number.
|
---|
| 449 | * @return The number of errors encountered (0 for success).
|
---|
| 450 | * @ingroup LLarchiveGroup
|
---|
| 451 | */
|
---|
| 452 | int
|
---|
[128] | 453 | archive_this_fileset(struct s_bkpinfo *bkpinfo, char *filelist,
|
---|
| 454 | char *fname, int setno)
|
---|
[1] | 455 | {
|
---|
| 456 |
|
---|
[128] | 457 | /*@ int *************************************************************** */
|
---|
| 458 | int retval = 0;
|
---|
| 459 | int res = 0;
|
---|
| 460 | int i = 0;
|
---|
| 461 | int tries = 0;
|
---|
| 462 | static int free_ramdisk_space = 9999;
|
---|
[1] | 463 |
|
---|
[128] | 464 | /*@ buffers ************************************************************ */
|
---|
| 465 | char *command;
|
---|
| 466 | char *zipparams;
|
---|
| 467 | char *tmp;
|
---|
[1] | 468 |
|
---|
[128] | 469 | assert(bkpinfo != NULL);
|
---|
| 470 | assert_string_is_neither_NULL_nor_zerolength(filelist);
|
---|
| 471 | assert_string_is_neither_NULL_nor_zerolength(fname);
|
---|
[1] | 472 |
|
---|
[128] | 473 | if (bkpinfo->compression_level > 0 && bkpinfo->use_star) {
|
---|
| 474 | return (archive_this_fileset_with_star
|
---|
| 475 | (bkpinfo, filelist, fname, setno));
|
---|
| 476 | }
|
---|
[1] | 477 |
|
---|
[128] | 478 | malloc_string(command);
|
---|
| 479 | malloc_string(zipparams);
|
---|
| 480 | malloc_string(tmp);
|
---|
| 481 |
|
---|
| 482 | if (!does_file_exist(filelist)) {
|
---|
| 483 | sprintf(tmp, "(archive_this_fileset) - filelist %s does not exist",
|
---|
| 484 | filelist);
|
---|
| 485 | log_to_screen(tmp);
|
---|
| 486 | return (1);
|
---|
| 487 | }
|
---|
| 488 | sprintf(tmp, "echo hi > %s 2> /dev/null", fname);
|
---|
| 489 | if (system(tmp)) {
|
---|
| 490 | fatal_error("Unable to write tarball to scratchdir");
|
---|
| 491 | }
|
---|
| 492 |
|
---|
| 493 |
|
---|
| 494 | if (bkpinfo->compression_level > 0) {
|
---|
| 495 | sprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
|
---|
| 496 | // -b %ld, TAPE_BLOCK_SIZE
|
---|
| 497 | sprintf(zipparams, "-Z -P %s -G %d -T 3k", bkpinfo->zip_exe,
|
---|
| 498 | bkpinfo->compression_level);
|
---|
| 499 | if (does_file_exist(tmp)) {
|
---|
| 500 | strcat(zipparams, " -E ");
|
---|
| 501 | strcat(zipparams, tmp);
|
---|
| 502 | } else {
|
---|
| 503 | log_msg(3, "%s not found. Cannot exclude zipfiles, etc.", tmp);
|
---|
| 504 | }
|
---|
| 505 | } else {
|
---|
| 506 | zipparams[0] = '\0';
|
---|
| 507 | }
|
---|
| 508 |
|
---|
[1] | 509 | // make_hole_for_file(fname);
|
---|
| 510 |
|
---|
[128] | 511 | if (!does_file_exist(bkpinfo->tmpdir)) {
|
---|
| 512 | log_OS_error("tmpdir not found");
|
---|
| 513 | fatal_error("tmpdir not found");
|
---|
| 514 | }
|
---|
| 515 | if (!does_file_exist(bkpinfo->scratchdir)) {
|
---|
| 516 | log_OS_error("scratchdir not found");
|
---|
| 517 | fatal_error("scratchdir not found");
|
---|
| 518 | }
|
---|
| 519 | sprintf(command, "rm -f %s %s. %s.gz %s.%s", fname, fname, fname,
|
---|
| 520 | fname, bkpinfo->zip_suffix);
|
---|
| 521 | paranoid_system(command);
|
---|
[1] | 522 |
|
---|
[128] | 523 | sprintf(command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s",
|
---|
| 524 | TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
|
---|
[1] | 525 |
|
---|
[128] | 526 | sprintf(tmp, "echo hi > %s 2> /dev/null", fname);
|
---|
| 527 | if (system(tmp)) {
|
---|
| 528 | fatal_error("Unable to write tarball to scratchdir");
|
---|
| 529 | }
|
---|
[1] | 530 |
|
---|
[128] | 531 | for (res = 99, tries = 0; tries < 3 && res != 0; tries++) {
|
---|
| 532 | log_msg(5, "command='%s'", command);
|
---|
| 533 | res = system(command);
|
---|
| 534 | if (res) {
|
---|
| 535 | log_OS_error(command);
|
---|
| 536 | log_msg(3,
|
---|
| 537 | "Attempt #%d failed. Pausing 3 seconds and retrying...",
|
---|
| 538 | tries + 1);
|
---|
| 539 | sleep(3);
|
---|
| 540 | }
|
---|
| 541 | }
|
---|
| 542 | retval += res;
|
---|
| 543 | if (retval) {
|
---|
| 544 | log_msg(3, "Failed to write set %d", setno);
|
---|
| 545 | } else if (tries > 1) {
|
---|
| 546 | log_msg(3, "Succeeded in writing set %d, on try #%d", setno,
|
---|
| 547 | tries);
|
---|
| 548 | }
|
---|
[1] | 549 |
|
---|
[128] | 550 | if (g_tmpfs_mountpt[0] != '\0') {
|
---|
| 551 | i = atoi(call_program_and_get_last_line_of_output
|
---|
[305] | 552 | ("df -m -P | grep dev/shm | grep -v none | tr -s ' ' '\t' | cut -f4"));
|
---|
[128] | 553 | if (i > 0) {
|
---|
| 554 | if (free_ramdisk_space > i) {
|
---|
| 555 | free_ramdisk_space = i;
|
---|
| 556 | log_msg(2, "min(free_ramdisk_space) is now %d",
|
---|
| 557 | free_ramdisk_space);
|
---|
| 558 | if (free_ramdisk_space < 10) {
|
---|
| 559 | fatal_error
|
---|
| 560 | ("Please increase PPCFG_RAMDISK_SIZE in my-stuff.h to increase size of ramdisk ");
|
---|
| 561 | }
|
---|
| 562 | }
|
---|
| 563 | }
|
---|
| 564 | }
|
---|
| 565 | paranoid_free(command);
|
---|
| 566 | paranoid_free(zipparams);
|
---|
| 567 | paranoid_free(tmp);
|
---|
| 568 | return (retval);
|
---|
[1] | 569 | }
|
---|
| 570 |
|
---|
| 571 |
|
---|
| 572 |
|
---|
| 573 |
|
---|
| 574 |
|
---|
| 575 |
|
---|
| 576 | /**
|
---|
| 577 | * Wrapper function for all the backup commands.
|
---|
| 578 | * Calls these other functions: @c prepare_filelist(),
|
---|
| 579 | * @c call_filelist_chopper(), @c copy_mondo_and_mindi_stuff_to_scratchdir(),
|
---|
| 580 | * @c call_mindi_to_supply_boot_disks(), @c do_that_initial_phase(),
|
---|
| 581 | * @c make_those_afios_phase(), @c make_those_slices_phase(), and
|
---|
| 582 | * @c do_that_final_phase(). If anything fails before @c do_that_initial_phase(),
|
---|
| 583 | * @c fatal_error is called with a suitable message.
|
---|
| 584 | * @param bkpinfo The backup information structure. Uses most fields.
|
---|
| 585 | * @return The number of non-fatal errors encountered (0 for success).
|
---|
| 586 | * @ingroup archiveGroup
|
---|
| 587 | */
|
---|
[541] | 588 | int backup_data(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 589 | {
|
---|
[128] | 590 | int retval = 0, res = 0;
|
---|
| 591 | char *tmp;
|
---|
[1] | 592 |
|
---|
[128] | 593 | assert(bkpinfo != NULL);
|
---|
| 594 | set_g_cdrom_and_g_dvd_to_bkpinfo_value(bkpinfo);
|
---|
| 595 | malloc_string(tmp);
|
---|
| 596 | if (bkpinfo->backup_media_type == dvd) {
|
---|
[1] | 597 | #ifdef DVDRWFORMAT
|
---|
[128] | 598 | if (!find_home_of_exe("dvd+rw-format")) {
|
---|
| 599 | fatal_error
|
---|
| 600 | ("Cannot find dvd+rw-format. Please install it or fix your PATH.");
|
---|
| 601 | }
|
---|
[1] | 602 | #endif
|
---|
[128] | 603 | if (!find_home_of_exe("growisofs")) {
|
---|
| 604 | fatal_error
|
---|
| 605 | ("Cannot find growisofs. Please install it or fix your PATH.");
|
---|
| 606 | }
|
---|
[1] | 607 | }
|
---|
| 608 |
|
---|
[128] | 609 | if ((res = prepare_filelist(bkpinfo))) { /* generate scratchdir/filelist.full */
|
---|
| 610 | fatal_error("Failed to generate filelist catalog");
|
---|
| 611 | }
|
---|
| 612 | if (call_filelist_chopper(bkpinfo)) {
|
---|
| 613 | fatal_error("Failed to run filelist chopper");
|
---|
| 614 | }
|
---|
[1] | 615 |
|
---|
| 616 | /*
|
---|
| 617 | sprintf(tmp, "wc -l %s/archives/filelist.full > %s/archives/filelist.count",bkpinfo->scratchdir, bkpinfo->scratchdir);
|
---|
| 618 | if (run_program_and_log_output(tmp, 2))
|
---|
| 619 | { fatal_error("Failed to count filelist.full"); }
|
---|
| 620 | */
|
---|
[128] | 621 | sprintf(tmp, "gzip -9 %s/archives/filelist.full", bkpinfo->scratchdir);
|
---|
| 622 | if (run_program_and_log_output(tmp, 2)) {
|
---|
| 623 | fatal_error("Failed to gzip filelist.full");
|
---|
| 624 | }
|
---|
| 625 | sprintf(tmp, "cp -f %s/archives/*list*.gz %s", bkpinfo->scratchdir,
|
---|
| 626 | bkpinfo->tmpdir);
|
---|
| 627 | if (run_program_and_log_output(tmp, 2)) {
|
---|
| 628 | fatal_error("Failed to copy to tmpdir");
|
---|
| 629 | }
|
---|
[1] | 630 |
|
---|
[128] | 631 | copy_mondo_and_mindi_stuff_to_scratchdir(bkpinfo); // payload, too, if it exists
|
---|
[1] | 632 | #if __FreeBSD__ == 5
|
---|
[128] | 633 | strcpy(bkpinfo->kernel_path, "/boot/kernel/kernel");
|
---|
[1] | 634 | #elif __FreeBSD__ == 4
|
---|
[128] | 635 | strcpy(bkpinfo->kernel_path, "/kernel");
|
---|
[1] | 636 | #elif linux
|
---|
[128] | 637 | if (figure_out_kernel_path_interactively_if_necessary
|
---|
| 638 | (bkpinfo->kernel_path)) {
|
---|
| 639 | fatal_error
|
---|
| 640 | ("Kernel not found. Please specify manually with the '-k' switch.");
|
---|
| 641 | }
|
---|
[1] | 642 | #else
|
---|
| 643 | #error "I don't know about this system!"
|
---|
| 644 | #endif
|
---|
[128] | 645 | if ((res = call_mindi_to_supply_boot_disks(bkpinfo))) {
|
---|
| 646 | fatal_error("Failed to generate boot+data disks");
|
---|
| 647 | }
|
---|
| 648 | retval += do_that_initial_phase(bkpinfo); // prepare
|
---|
| 649 | sprintf(tmp, "rm -f %s/images/*.iso", bkpinfo->scratchdir);
|
---|
| 650 | run_program_and_log_output(tmp, 1);
|
---|
[541] | 651 | retval += make_those_afios_phase(bkpinfo); // backup regular files
|
---|
[128] | 652 | retval += make_those_slices_phase(bkpinfo); // backup BIG files
|
---|
| 653 | retval += do_that_final_phase(bkpinfo); // clean up
|
---|
| 654 | log_msg(1, "Creation of archives... complete.");
|
---|
| 655 | if (bkpinfo->verify_data) {
|
---|
| 656 | sleep(2);
|
---|
| 657 | }
|
---|
| 658 | paranoid_free(tmp);
|
---|
| 659 | return (retval);
|
---|
[1] | 660 | }
|
---|
| 661 |
|
---|
| 662 |
|
---|
| 663 |
|
---|
| 664 |
|
---|
| 665 | /**
|
---|
| 666 | * Call Mindi to generate boot and data disks.
|
---|
| 667 | * @note This binds correctly to the new Perl version of mindi.
|
---|
| 668 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 669 | * - @c backup_media_type
|
---|
| 670 | * - @c boot_loader
|
---|
| 671 | * - @c boot_device
|
---|
| 672 | * - @c compression_level
|
---|
| 673 | * - @c differential
|
---|
| 674 | * - @c exclude_paths
|
---|
| 675 | * - @c image_devs
|
---|
| 676 | * - @c kernel_path
|
---|
| 677 | * - @c make_cd_use_lilo
|
---|
| 678 | * - @c media_device
|
---|
| 679 | * - @c media_size
|
---|
| 680 | * - @c nonbootable_backup
|
---|
| 681 | * - @c scratchdir
|
---|
| 682 | * - @c tmpdir
|
---|
| 683 | * - @c use_lzo
|
---|
| 684 | *
|
---|
| 685 | * @return The number of errors encountered (0 for success)
|
---|
| 686 | * @bug The code to automagically determine the boot drive
|
---|
| 687 | * is messy and system-dependent. In particular, it breaks
|
---|
| 688 | * for Linux RAID and LVM users.
|
---|
| 689 | * @ingroup MLarchiveGroup
|
---|
| 690 | */
|
---|
[128] | 691 | int call_mindi_to_supply_boot_disks(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 692 | {
|
---|
[128] | 693 | /*@ buffer ************************************************************ */
|
---|
| 694 | char *tmp;
|
---|
[949] | 695 | char *tmp1 = NULL;
|
---|
[128] | 696 | char *scratchdir;
|
---|
[1] | 697 | char *command;
|
---|
| 698 | char *use_lzo_sz;
|
---|
[128] | 699 | char *use_comp_sz;
|
---|
[1] | 700 | char *use_star_sz;
|
---|
| 701 | char *bootldr_str;
|
---|
| 702 | char *tape_device;
|
---|
| 703 | char *last_filelist_number;
|
---|
| 704 | char *broken_bios_sz;
|
---|
| 705 | char *cd_recovery_sz;
|
---|
| 706 | char *tape_size_sz;
|
---|
| 707 | char *devs_to_exclude;
|
---|
[128] | 708 | char *use_lilo_sz;
|
---|
| 709 | char *value;
|
---|
[1] | 710 | char *bootdev;
|
---|
| 711 |
|
---|
| 712 |
|
---|
| 713 |
|
---|
[128] | 714 | /*@ char ************************************************************** */
|
---|
[1] | 715 | char ch = '\0';
|
---|
| 716 |
|
---|
[128] | 717 | /*@ long ********************************************************** */
|
---|
| 718 | long lines_in_filelist = 0;
|
---|
[1] | 719 |
|
---|
[128] | 720 | /*@ int ************************************************************* */
|
---|
| 721 | int res = 0;
|
---|
| 722 | long estimated_total_noof_slices = 0;
|
---|
[1] | 723 |
|
---|
[128] | 724 | assert(bkpinfo != NULL);
|
---|
| 725 | command = malloc(1200);
|
---|
| 726 | malloc_string(tmp);
|
---|
| 727 | malloc_string(scratchdir);
|
---|
| 728 | malloc_string(use_lzo_sz);
|
---|
| 729 | malloc_string(use_star_sz);
|
---|
| 730 | malloc_string(use_comp_sz);
|
---|
| 731 | malloc_string(bootldr_str);
|
---|
| 732 | malloc_string(tape_device);
|
---|
| 733 | malloc_string(last_filelist_number);
|
---|
| 734 | malloc_string(broken_bios_sz);
|
---|
| 735 | malloc_string(cd_recovery_sz);
|
---|
| 736 | malloc_string(tape_size_sz);
|
---|
| 737 | malloc_string(devs_to_exclude);
|
---|
| 738 | malloc_string(use_lilo_sz); /* BCO: shared between LILO/ELILO */
|
---|
| 739 | malloc_string(value);
|
---|
| 740 | malloc_string(bootdev);
|
---|
[1] | 741 |
|
---|
[128] | 742 | strcpy(scratchdir, bkpinfo->scratchdir);
|
---|
| 743 | sprintf(tmp,
|
---|
[911] | 744 | "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'",
|
---|
[128] | 745 | bkpinfo->exclude_paths);
|
---|
| 746 | strcpy(devs_to_exclude, call_program_and_get_last_line_of_output(tmp));
|
---|
| 747 | sprintf(tmp, "devs_to_exclude = '%s'", devs_to_exclude);
|
---|
| 748 | log_msg(2, tmp);
|
---|
| 749 | mvaddstr_and_log_it(g_currentY, 0,
|
---|
| 750 | "Calling MINDI to create boot+data disks");
|
---|
| 751 | sprintf(tmp, "%s/filelist.full", bkpinfo->tmpdir);
|
---|
| 752 | if (!does_file_exist(tmp)) {
|
---|
| 753 | sprintf(tmp, "%s/tmpfs/filelist.full", bkpinfo->tmpdir);
|
---|
| 754 | if (!does_file_exist(tmp)) {
|
---|
| 755 | fatal_error
|
---|
| 756 | ("Cannot find filelist.full, so I cannot count its lines");
|
---|
| 757 | }
|
---|
| 758 | }
|
---|
| 759 | lines_in_filelist = count_lines_in_file(tmp);
|
---|
| 760 | sprintf(tmp, "%s/LAST-FILELIST-NUMBER", bkpinfo->tmpdir);
|
---|
| 761 | strcpy(last_filelist_number, last_line_of_file(tmp));
|
---|
| 762 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 763 | sprintf(tape_size_sz, "%ld", bkpinfo->media_size[1]);
|
---|
| 764 | strcpy(tape_device, bkpinfo->media_device);
|
---|
| 765 | } else {
|
---|
| 766 | tape_size_sz[0] = '\0';
|
---|
| 767 | tape_device[0] = '\0';
|
---|
| 768 | }
|
---|
| 769 | if (bkpinfo->use_lzo) {
|
---|
| 770 | strcpy(use_lzo_sz, "yes");
|
---|
| 771 | } else {
|
---|
| 772 | strcpy(use_lzo_sz, "no");
|
---|
| 773 | }
|
---|
| 774 | if (bkpinfo->use_star) {
|
---|
| 775 | strcpy(use_star_sz, "yes");
|
---|
| 776 | } else {
|
---|
| 777 | strcpy(use_star_sz, "no");
|
---|
| 778 | }
|
---|
[1] | 779 |
|
---|
[128] | 780 | if (bkpinfo->compression_level > 0) {
|
---|
| 781 | strcpy(use_comp_sz, "yes");
|
---|
| 782 | } else {
|
---|
| 783 | strcpy(use_comp_sz, "no");
|
---|
| 784 | }
|
---|
[1] | 785 |
|
---|
[128] | 786 | strcpy(broken_bios_sz, "yes"); /* assume so */
|
---|
| 787 | if (g_cd_recovery) {
|
---|
| 788 | strcpy(cd_recovery_sz, "yes");
|
---|
| 789 | } else {
|
---|
| 790 | strcpy(cd_recovery_sz, "no");
|
---|
| 791 | }
|
---|
| 792 | if (bkpinfo->make_cd_use_lilo) {
|
---|
| 793 | strcpy(use_lilo_sz, "yes");
|
---|
| 794 | } else {
|
---|
| 795 | strcpy(use_lilo_sz, "no");
|
---|
| 796 | }
|
---|
| 797 |
|
---|
| 798 | if (!bkpinfo->nonbootable_backup
|
---|
| 799 | && (bkpinfo->boot_loader == '\0'
|
---|
| 800 | || bkpinfo->boot_device[0] == '\0')) {
|
---|
| 801 |
|
---|
[1] | 802 | #ifdef __FreeBSD__
|
---|
[128] | 803 | strcpy(bootdev, call_program_and_get_last_line_of_output
|
---|
| 804 | ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
|
---|
| 805 | if (!bootdev[0]) {
|
---|
| 806 | strcpy(bootdev, call_program_and_get_last_line_of_output
|
---|
| 807 | ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
|
---|
| 808 | }
|
---|
[1] | 809 | #else
|
---|
[128] | 810 | strcpy(bootdev, call_program_and_get_last_line_of_output
|
---|
| 811 | ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
|
---|
| 812 | if (strstr(bootdev, "/dev/cciss/")) {
|
---|
| 813 | strcpy(bootdev, call_program_and_get_last_line_of_output
|
---|
| 814 | ("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
|
---|
| 815 | }
|
---|
| 816 | if (!bootdev[0]) {
|
---|
| 817 | strcpy(bootdev, call_program_and_get_last_line_of_output
|
---|
| 818 | ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
|
---|
| 819 | if (strstr(bootdev, "/dev/cciss/")) {
|
---|
| 820 | strcpy(bootdev, call_program_and_get_last_line_of_output
|
---|
| 821 | ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
|
---|
| 822 | }
|
---|
| 823 | }
|
---|
[1] | 824 | #endif
|
---|
[128] | 825 | if (bootdev[0])
|
---|
| 826 | ch = which_boot_loader(bootdev);
|
---|
| 827 | else
|
---|
| 828 | ch = 'U';
|
---|
| 829 | if (bkpinfo->boot_loader != '\0') {
|
---|
| 830 | sprintf(tmp, "User specified boot loader. It is '%c'.",
|
---|
| 831 | bkpinfo->boot_loader);
|
---|
| 832 | log_msg(2, tmp);
|
---|
| 833 | } else {
|
---|
| 834 | bkpinfo->boot_loader = ch;
|
---|
| 835 | }
|
---|
| 836 | if (bkpinfo->boot_device[0] != '\0') {
|
---|
| 837 | sprintf(tmp, "User specified boot device. It is '%s'.",
|
---|
| 838 | bkpinfo->boot_device);
|
---|
| 839 | log_msg(2, tmp);
|
---|
| 840 | } else {
|
---|
| 841 | strcpy(bkpinfo->boot_device, bootdev);
|
---|
| 842 | }
|
---|
| 843 | }
|
---|
[1] | 844 |
|
---|
[128] | 845 | if (
|
---|
[1] | 846 | #ifdef __FreeBSD__
|
---|
[128] | 847 | bkpinfo->boot_loader != 'B' && bkpinfo->boot_loader != 'D' &&
|
---|
[1] | 848 | #endif
|
---|
| 849 | #ifdef __IA64__
|
---|
[128] | 850 | bkpinfo->boot_loader != 'E' &&
|
---|
[1] | 851 | #endif
|
---|
[128] | 852 | bkpinfo->boot_loader != 'L' && bkpinfo->boot_loader != 'G'
|
---|
| 853 | && bkpinfo->boot_loader != 'R'
|
---|
| 854 | && !bkpinfo->nonbootable_backup) {
|
---|
| 855 | fatal_error
|
---|
| 856 | ("Please specify your boot loader and device, e.g. -l GRUB -f /dev/hda. Type 'man mondoarchive' to read the manual.");
|
---|
[1] | 857 | }
|
---|
[128] | 858 | if (bkpinfo->boot_loader == 'L') {
|
---|
| 859 | strcpy(bootldr_str, "LILO");
|
---|
| 860 | if (!does_file_exist("/etc/lilo.conf")) {
|
---|
| 861 | fatal_error
|
---|
| 862 | ("The de facto standard location for your boot loader's config file is /etc/lilo.conf but I cannot find it there. What is wrong with your Linux distribution?");
|
---|
| 863 | }
|
---|
| 864 | } else if (bkpinfo->boot_loader == 'G') {
|
---|
| 865 | strcpy(bootldr_str, "GRUB");
|
---|
| 866 | if (!does_file_exist("/etc/grub.conf")
|
---|
| 867 | && does_file_exist("/boot/grub/grub.conf")) {
|
---|
| 868 | run_program_and_log_output
|
---|
| 869 | ("ln -sf /boot/grub/grub.conf /etc/grub.conf", 5);
|
---|
| 870 | }
|
---|
| 871 | /* Detect Debian's grub config file */
|
---|
| 872 | else if (!does_file_exist("/etc/grub.conf")
|
---|
| 873 | && does_file_exist("/boot/grub/menu.lst")) {
|
---|
| 874 | run_program_and_log_output
|
---|
| 875 | ("ln -s /boot/grub/menu.lst /etc/grub.conf", 5);
|
---|
| 876 | }
|
---|
| 877 | if (!does_file_exist("/etc/grub.conf")) {
|
---|
| 878 | fatal_error
|
---|
| 879 | ("The de facto standard location for your boot loader's config file is /etc/grub.conf but I cannot find it there. What is wrong with your Linux distribution? Try 'ln -s /boot/grub/menu.lst /etc/grub.conf'...");
|
---|
| 880 | }
|
---|
| 881 | } else if (bkpinfo->boot_loader == 'E') {
|
---|
| 882 | strcpy(bootldr_str, "ELILO");
|
---|
| 883 | /* BCO: fix it for SuSE, Debian, Mandrake, ... */
|
---|
| 884 | if (!does_file_exist("/etc/elilo.conf")
|
---|
| 885 | && does_file_exist("/boot/efi/efi/redhat/elilo.conf")) {
|
---|
| 886 | run_program_and_log_output
|
---|
| 887 | ("ln -sf /boot/efi/efi/redhat/elilo.conf /etc/elilo.conf",
|
---|
| 888 | 5);
|
---|
| 889 | }
|
---|
| 890 | if (!does_file_exist("/etc/elilo.conf")) {
|
---|
| 891 | fatal_error
|
---|
| 892 | ("The de facto mondo standard location for your boot loader's config file is /etc/elilo.conf but I cannot find it there. What is wrong with your Linux distribution? Try finding it under /boot/efi and do 'ln -s /boot/efi/..../elilo.conf /etc/elilo.conf'");
|
---|
| 893 | }
|
---|
| 894 | } else if (bkpinfo->boot_loader == 'R') {
|
---|
| 895 | strcpy(bootldr_str, "RAW");
|
---|
[1] | 896 | }
|
---|
| 897 | #ifdef __FreeBSD__
|
---|
[128] | 898 | else if (bkpinfo->boot_loader == 'D') {
|
---|
| 899 | strcpy(bootldr_str, "DD");
|
---|
| 900 | }
|
---|
[1] | 901 |
|
---|
[128] | 902 | else if (bkpinfo->boot_loader == 'B') {
|
---|
| 903 | strcpy(bootldr_str, "BOOT0");
|
---|
| 904 | }
|
---|
[1] | 905 | #endif
|
---|
[128] | 906 | else {
|
---|
| 907 | strcpy(bootldr_str, "unknown");
|
---|
| 908 | }
|
---|
| 909 | sprintf(tmp, "Your boot loader is %s and it boots from %s",
|
---|
| 910 | bootldr_str, bkpinfo->boot_device);
|
---|
| 911 | log_to_screen(tmp);
|
---|
| 912 | sprintf(tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir);
|
---|
| 913 | if (write_one_liner_data_file(tmp, bkpinfo->boot_device)) {
|
---|
| 914 | log_msg(1, "%ld: Unable to write one-liner boot device", __LINE__);
|
---|
| 915 | }
|
---|
| 916 | switch (bkpinfo->backup_media_type) {
|
---|
| 917 | case cdr:
|
---|
| 918 | strcpy(value, "cdr");
|
---|
| 919 | break;
|
---|
| 920 | case cdrw:
|
---|
| 921 | strcpy(value, "cdrw");
|
---|
| 922 | break;
|
---|
| 923 | case cdstream:
|
---|
| 924 | strcpy(value, "cdstream");
|
---|
| 925 | break;
|
---|
| 926 | case tape:
|
---|
| 927 | strcpy(value, "tape");
|
---|
| 928 | break;
|
---|
| 929 | case udev:
|
---|
| 930 | strcpy(value, "udev");
|
---|
| 931 | break;
|
---|
| 932 | case iso:
|
---|
| 933 | strcpy(value, "iso");
|
---|
| 934 | break;
|
---|
| 935 | case nfs:
|
---|
| 936 | strcpy(value, "nfs");
|
---|
| 937 | break;
|
---|
| 938 | case dvd:
|
---|
| 939 | strcpy(value, "dvd");
|
---|
| 940 | break;
|
---|
| 941 | default:
|
---|
| 942 | fatal_error("Unknown backup_media_type");
|
---|
| 943 | }
|
---|
| 944 | sprintf(tmp, "%s/BACKUP-MEDIA-TYPE", bkpinfo->tmpdir);
|
---|
| 945 | if (write_one_liner_data_file(tmp, value)) {
|
---|
| 946 | res++;
|
---|
| 947 | log_msg(1, "%ld: Unable to write one-liner backup-media-type",
|
---|
| 948 | __LINE__);
|
---|
| 949 | }
|
---|
| 950 | log_to_screen(bkpinfo->tmpdir);
|
---|
| 951 | sprintf(tmp, "%s/BOOTLOADER.NAME", bkpinfo->tmpdir);
|
---|
| 952 | if (write_one_liner_data_file(tmp, bootldr_str)) {
|
---|
| 953 | res++;
|
---|
| 954 | log_msg(1, "%ld: Unable to write one-liner bootloader.name",
|
---|
| 955 | __LINE__);
|
---|
| 956 | }
|
---|
| 957 | sprintf(tmp, "%s/DIFFERENTIAL", bkpinfo->tmpdir);
|
---|
| 958 | if (bkpinfo->differential) {
|
---|
| 959 | res += write_one_liner_data_file(tmp, "1");
|
---|
| 960 | } else {
|
---|
| 961 | res += write_one_liner_data_file(tmp, "0");
|
---|
| 962 | }
|
---|
[1] | 963 |
|
---|
[949] | 964 | if (g_getfattr) {
|
---|
| 965 | asprintf(&tmp1, "%s/XATTR", bkpinfo->tmpdir);
|
---|
| 966 | if (write_one_liner_data_file(tmp1, "TRUE")) {
|
---|
| 967 | log_msg(1, "%ld: Unable to write one-liner XATTR",
|
---|
| 968 | __LINE__);
|
---|
| 969 | }
|
---|
| 970 | paranoid_free(tmp1);
|
---|
| 971 | }
|
---|
| 972 | if (g_getfacl) {
|
---|
| 973 | asprintf(&tmp1, "%s/ACL", bkpinfo->tmpdir);
|
---|
| 974 | if (write_one_liner_data_file(tmp1, "TRUE")) {
|
---|
| 975 | log_msg(1, "%ld: Unable to write one-liner ACL",
|
---|
| 976 | __LINE__);
|
---|
| 977 | }
|
---|
| 978 | paranoid_free(tmp1);
|
---|
| 979 | }
|
---|
| 980 |
|
---|
[128] | 981 | estimated_total_noof_slices =
|
---|
| 982 | size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
|
---|
[1] | 983 | /* add nfs stuff here? */
|
---|
[128] | 984 | sprintf(command, "mkdir -p %s/images", bkpinfo->scratchdir);
|
---|
| 985 | if (system(command)) {
|
---|
| 986 | res++;
|
---|
| 987 | log_OS_error("Unable to make images directory");
|
---|
| 988 | }
|
---|
| 989 | sprintf(command, "mkdir -p %s%s", bkpinfo->scratchdir, MNT_FLOPPY);
|
---|
| 990 | if (system(command)) {
|
---|
| 991 | res++;
|
---|
| 992 | log_OS_error("Unable to make mnt floppy directory");
|
---|
| 993 | }
|
---|
| 994 | sprintf(tmp, "BTW, I'm telling Mindi your kernel is '%s'",
|
---|
| 995 | bkpinfo->kernel_path);
|
---|
[1] | 996 |
|
---|
[128] | 997 | log_msg(1, "lines_in_filelist = %ld", lines_in_filelist);
|
---|
[1] | 998 |
|
---|
[128] | 999 | sprintf(command,
|
---|
[1] | 1000 | /* "mindi --custom 2=%s 3=%s/images 4=\"%s\" 5=\"%s\" \
|
---|
| 1001 | 6=\"%s\" 7=%ld 8=\"%s\" 9=\"%s\" 10=\"%s\" \
|
---|
| 1002 | 11=\"%s\" 12=%s 13=%ld 14=\"%s\" 15=\"%s\" 16=\"%s\" 17=\"%s\" 18=%ld 19=%d",*/
|
---|
[128] | 1003 | "mindi --custom %s %s/images '%s' '%s' \
|
---|
[126] | 1004 | '%s' %ld '%s' '%s' '%s' \
|
---|
[128] | 1005 | '%s' %s %ld '%s' '%s' '%s' '%s' %ld %d", bkpinfo->tmpdir, // parameter #2
|
---|
| 1006 | bkpinfo->scratchdir, // parameter #3
|
---|
| 1007 | bkpinfo->kernel_path, // parameter #4
|
---|
| 1008 | tape_device, // parameter #5
|
---|
| 1009 | tape_size_sz, // parameter #6
|
---|
| 1010 | lines_in_filelist, // parameter #7 (INT)
|
---|
| 1011 | use_lzo_sz, // parameter #8
|
---|
| 1012 | cd_recovery_sz, // parameter #9
|
---|
| 1013 | bkpinfo->image_devs, // parameter #10
|
---|
| 1014 | broken_bios_sz, // parameter #11
|
---|
| 1015 | last_filelist_number, // parameter #12 (STRING)
|
---|
| 1016 | estimated_total_noof_slices, // parameter #13 (INT)
|
---|
| 1017 | devs_to_exclude, // parameter #14
|
---|
| 1018 | use_comp_sz, // parameter #15
|
---|
| 1019 | use_lilo_sz, // parameter #16
|
---|
| 1020 | use_star_sz, // parameter #17
|
---|
| 1021 | bkpinfo->internal_tape_block_size, // parameter #18 (LONG)
|
---|
| 1022 | bkpinfo->differential); // parameter #19 (INT)
|
---|
[1] | 1023 |
|
---|
| 1024 | // Watch it! This next line adds a parameter...
|
---|
[128] | 1025 | if (bkpinfo->nonbootable_backup) {
|
---|
| 1026 | strcat(command, " NONBOOTABLE");
|
---|
| 1027 | }
|
---|
| 1028 | log_msg(2, command);
|
---|
[1] | 1029 |
|
---|
| 1030 | // popup_and_OK("Pausing");
|
---|
[128] | 1031 |
|
---|
| 1032 | res =
|
---|
| 1033 | run_program_and_log_to_screen(command,
|
---|
| 1034 | "Generating boot+data disks");
|
---|
| 1035 | if (bkpinfo->nonbootable_backup) {
|
---|
| 1036 | res = 0;
|
---|
| 1037 | } // hack
|
---|
| 1038 | if (!res) {
|
---|
| 1039 | log_to_screen("Boot+data disks were created OK");
|
---|
[541] | 1040 | sprintf(command, "mkdir -p /root/images/mindi/");
|
---|
[128] | 1041 | log_msg(2, command);
|
---|
| 1042 | run_program_and_log_output(command, FALSE);
|
---|
| 1043 | sprintf(command,
|
---|
[541] | 1044 | "cp -f %s/images/mindi.iso /root/images/mindi/mondorescue.iso",
|
---|
[128] | 1045 | bkpinfo->scratchdir);
|
---|
| 1046 | log_msg(2, command);
|
---|
| 1047 | run_program_and_log_output(command, FALSE);
|
---|
| 1048 | if (bkpinfo->nonbootable_backup) {
|
---|
| 1049 | sprintf(command, "cp -f %s/all.tar.gz %s/images",
|
---|
| 1050 | bkpinfo->tmpdir, bkpinfo->scratchdir);
|
---|
| 1051 | if (system(command)) {
|
---|
| 1052 | fatal_error("Unable to create temporary duff tarball");
|
---|
| 1053 | }
|
---|
| 1054 | }
|
---|
| 1055 | sprintf(command, "cp -f %s/mindi-*oot*.img %s/images",
|
---|
| 1056 | bkpinfo->tmpdir, bkpinfo->scratchdir);
|
---|
| 1057 | sprintf(tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir,
|
---|
| 1058 | bkpinfo->tmpdir);
|
---|
| 1059 | if (system(tmp)) {
|
---|
| 1060 | fatal_error("Cannot find all.tar.gz in tmpdir");
|
---|
| 1061 | }
|
---|
| 1062 | if (res) {
|
---|
| 1063 | mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
|
---|
| 1064 | } else {
|
---|
| 1065 | mvaddstr_and_log_it(g_currentY++, 74, "Done.");
|
---|
| 1066 | }
|
---|
| 1067 | } else {
|
---|
| 1068 | log_to_screen("Mindi failed to create your boot+data disks.");
|
---|
[143] | 1069 | strcpy(command, "grep 'Fatal error' /var/log/mindi.log");
|
---|
[128] | 1070 | strcpy(tmp, call_program_and_get_last_line_of_output(command));
|
---|
| 1071 | if (strlen(tmp) > 1) {
|
---|
[155] | 1072 | popup_and_OK(tmp);
|
---|
[128] | 1073 | }
|
---|
| 1074 | }
|
---|
| 1075 | paranoid_free(tmp);
|
---|
| 1076 | paranoid_free(use_lzo_sz);
|
---|
| 1077 | paranoid_free(scratchdir);
|
---|
| 1078 | paranoid_free(use_comp_sz);
|
---|
| 1079 | paranoid_free(bootldr_str);
|
---|
| 1080 | paranoid_free(tape_device);
|
---|
| 1081 | paranoid_free(last_filelist_number);
|
---|
| 1082 | paranoid_free(broken_bios_sz);
|
---|
| 1083 | paranoid_free(cd_recovery_sz);
|
---|
| 1084 | paranoid_free(tape_size_sz);
|
---|
| 1085 | paranoid_free(devs_to_exclude);
|
---|
| 1086 | paranoid_free(use_lilo_sz);
|
---|
| 1087 | paranoid_free(value);
|
---|
| 1088 | paranoid_free(bootdev);
|
---|
| 1089 | paranoid_free(command);
|
---|
| 1090 | paranoid_free(use_star_sz);
|
---|
| 1091 | return (res);
|
---|
[1] | 1092 | }
|
---|
| 1093 |
|
---|
| 1094 |
|
---|
| 1095 |
|
---|
| 1096 | /**
|
---|
| 1097 | * Maximum number of filesets allowed in this function.
|
---|
| 1098 | */
|
---|
| 1099 | #define MAX_NOOF_SETS_HERE 32767
|
---|
| 1100 |
|
---|
| 1101 | /**
|
---|
| 1102 | * Offset of the bkpinfo pointer (in bytes) from the
|
---|
| 1103 | * buffer passed to create_afio_files_in_background.
|
---|
| 1104 | */
|
---|
| 1105 | #define BKPINFO_LOC_OFFSET (16+MAX_NOOF_SETS_HERE/8+16)
|
---|
| 1106 |
|
---|
| 1107 | /**
|
---|
| 1108 | * Main function for each @c afio thread.
|
---|
| 1109 | * @param inbuf A transfer block containing:
|
---|
| 1110 | * - @c p_last_set_archived: [offset 0] pointer to an @c int
|
---|
| 1111 | * containing the last set archived.
|
---|
| 1112 | * - @c p_archival_threads_running: [offset 4] pointer to an @c int
|
---|
| 1113 | * containing the number of archival threads currently running.
|
---|
| 1114 | * - @c p_next_set_to_archive: [offset 8] pointer to an @c int containing
|
---|
| 1115 | * the next set that should be archived.
|
---|
| 1116 | * - @c p_list_of_fileset_flags: [offset 12] @c char pointer pointing to a
|
---|
| 1117 | * bit array, where each bit corresponds to a filelist (1=needs
|
---|
| 1118 | * to be archived, 0=archived).
|
---|
| 1119 | * - @c bkpinfo: [offset BKPINFO_LOC_OFFSET] pointer to backup information
|
---|
| 1120 | * structure. Fields used:
|
---|
| 1121 | * - @c tmpdir
|
---|
| 1122 | * - @c zip_suffix
|
---|
| 1123 | *
|
---|
| 1124 | * Any of the above may be modified by the caller at any time.
|
---|
| 1125 | *
|
---|
| 1126 | * @bug Assumes @c int pointers are 4 bytes.
|
---|
| 1127 | * @see archive_this_fileset
|
---|
| 1128 | * @see make_afioballs_and_images
|
---|
| 1129 | * @return NULL, always.
|
---|
| 1130 | * @ingroup LLarchiveGroup
|
---|
| 1131 | */
|
---|
[128] | 1132 | void *create_afio_files_in_background(void *inbuf)
|
---|
[1] | 1133 | {
|
---|
[128] | 1134 | long int archiving_set_no;
|
---|
| 1135 | char *archiving_filelist_fname;
|
---|
| 1136 | char *archiving_afioball_fname;
|
---|
[948] | 1137 | char *curr_xattr_list_fname = NULL;
|
---|
[128] | 1138 | char *curr_acl_list_fname;
|
---|
[1] | 1139 |
|
---|
[128] | 1140 | struct s_bkpinfo *bkpinfo;
|
---|
| 1141 | char *tmp;
|
---|
| 1142 | int res = 0, retval = 0;
|
---|
| 1143 | int *p_archival_threads_running;
|
---|
| 1144 | int *p_last_set_archived;
|
---|
| 1145 | int *p_next_set_to_archive;
|
---|
| 1146 | char *p_list_of_fileset_flags;
|
---|
| 1147 | int this_thread_no = g_current_thread_no++;
|
---|
[1] | 1148 |
|
---|
[128] | 1149 | malloc_string(curr_xattr_list_fname);
|
---|
| 1150 | malloc_string(curr_acl_list_fname);
|
---|
| 1151 | malloc_string(archiving_filelist_fname);
|
---|
| 1152 | malloc_string(archiving_afioball_fname);
|
---|
| 1153 | malloc_string(tmp);
|
---|
| 1154 | p_last_set_archived = (int *) inbuf;
|
---|
| 1155 | p_archival_threads_running = (int *) (inbuf + 4);
|
---|
| 1156 | p_next_set_to_archive = (int *) (inbuf + 8);
|
---|
| 1157 | p_list_of_fileset_flags = (char *) (inbuf + 12);
|
---|
| 1158 | bkpinfo = (struct s_bkpinfo *) (inbuf + BKPINFO_LOC_OFFSET);
|
---|
[1] | 1159 |
|
---|
[128] | 1160 | sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
|
---|
| 1161 | bkpinfo->tmpdir, 0L);
|
---|
| 1162 | for (archiving_set_no = 0; does_file_exist(archiving_filelist_fname);
|
---|
| 1163 | sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
|
---|
| 1164 | bkpinfo->tmpdir, archiving_set_no)) {
|
---|
| 1165 | if (g_exiting) {
|
---|
| 1166 | fatal_error("Execution run aborted (pthread)");
|
---|
| 1167 | }
|
---|
| 1168 | if (archiving_set_no >= MAX_NOOF_SETS_HERE) {
|
---|
| 1169 | fatal_error
|
---|
| 1170 | ("Maximum number of filesets exceeded. Adjust MAX_NOOF_SETS_HERE, please.");
|
---|
| 1171 | }
|
---|
| 1172 | if (!semaphore_p()) {
|
---|
| 1173 | log_msg(3, "P sem failed (pid=%d)", (int) getpid());
|
---|
| 1174 | fatal_error("Cannot get semaphore P");
|
---|
| 1175 | }
|
---|
| 1176 | if (archiving_set_no < *p_next_set_to_archive) {
|
---|
| 1177 | archiving_set_no = *p_next_set_to_archive;
|
---|
| 1178 | }
|
---|
| 1179 | *p_next_set_to_archive = *p_next_set_to_archive + 1;
|
---|
| 1180 | if (!semaphore_v()) {
|
---|
| 1181 | fatal_error("Cannot get semaphore V");
|
---|
| 1182 | }
|
---|
[1] | 1183 |
|
---|
[128] | 1184 | /* backup this set of files */
|
---|
| 1185 | sprintf(archiving_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
|
---|
| 1186 | bkpinfo->tmpdir, archiving_set_no, bkpinfo->zip_suffix);
|
---|
| 1187 | sprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ,
|
---|
| 1188 | bkpinfo->tmpdir, archiving_set_no);
|
---|
| 1189 | if (!does_file_exist(archiving_filelist_fname)) {
|
---|
| 1190 | log_msg(3,
|
---|
| 1191 | "%s[%d:%d] - well, I would archive %d, except that it doesn't exist. I'll stop now.",
|
---|
| 1192 | FORTY_SPACES, getpid(), this_thread_no,
|
---|
| 1193 | archiving_set_no);
|
---|
| 1194 | break;
|
---|
| 1195 | }
|
---|
[1] | 1196 |
|
---|
[128] | 1197 | sprintf(tmp, AFIOBALL_FNAME_RAW_SZ, bkpinfo->tmpdir,
|
---|
| 1198 | archiving_set_no - ARCH_BUFFER_NUM, bkpinfo->zip_suffix);
|
---|
| 1199 | if (does_file_exist(tmp)) {
|
---|
| 1200 | log_msg(4, "%s[%d:%d] - waiting for storer", FORTY_SPACES,
|
---|
| 1201 | getpid(), this_thread_no);
|
---|
| 1202 | while (does_file_exist(tmp)) {
|
---|
| 1203 | sleep(1);
|
---|
| 1204 | }
|
---|
| 1205 | log_msg(4, "[%d] - continuing", getpid());
|
---|
| 1206 | }
|
---|
[1] | 1207 |
|
---|
[128] | 1208 | log_msg(4, "%s[%d:%d] - EXATing %d...", FORTY_SPACES, getpid(),
|
---|
| 1209 | this_thread_no, archiving_set_no);
|
---|
[948] | 1210 | if (g_getfattr) {
|
---|
| 1211 | sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
|
---|
[128] | 1212 | bkpinfo->tmpdir, archiving_set_no);
|
---|
[948] | 1213 | get_fattr_list(archiving_filelist_fname, curr_xattr_list_fname);
|
---|
| 1214 | }
|
---|
| 1215 | if (g_getfacl) {
|
---|
| 1216 | sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
|
---|
[128] | 1217 | bkpinfo->tmpdir, archiving_set_no);
|
---|
[948] | 1218 | get_acl_list(archiving_filelist_fname, curr_acl_list_fname);
|
---|
| 1219 | }
|
---|
[1] | 1220 |
|
---|
[128] | 1221 | log_msg(4, "%s[%d:%d] - archiving %d...", FORTY_SPACES, getpid(),
|
---|
| 1222 | this_thread_no, archiving_set_no);
|
---|
| 1223 | res =
|
---|
| 1224 | archive_this_fileset(bkpinfo, archiving_filelist_fname,
|
---|
| 1225 | archiving_afioball_fname,
|
---|
| 1226 | archiving_set_no);
|
---|
| 1227 | retval += res;
|
---|
[1] | 1228 |
|
---|
[128] | 1229 | if (res) {
|
---|
| 1230 | sprintf(tmp,
|
---|
| 1231 | "Errors occurred while archiving set %ld. Please review logs.",
|
---|
| 1232 | archiving_set_no);
|
---|
| 1233 | log_to_screen(tmp);
|
---|
| 1234 | }
|
---|
| 1235 | if (!semaphore_p()) {
|
---|
| 1236 | fatal_error("Cannot get semaphore P");
|
---|
| 1237 | }
|
---|
| 1238 |
|
---|
| 1239 | set_bit_N_of_array(p_list_of_fileset_flags, archiving_set_no, 5);
|
---|
| 1240 |
|
---|
| 1241 | if (*p_last_set_archived < archiving_set_no) {
|
---|
| 1242 | *p_last_set_archived = archiving_set_no;
|
---|
| 1243 | } // finished archiving this one
|
---|
| 1244 |
|
---|
| 1245 | if (!semaphore_v()) {
|
---|
| 1246 | fatal_error("Cannot get semaphore V");
|
---|
| 1247 | }
|
---|
| 1248 | log_msg(4, "%s[%d:%d] - archived %d OK", FORTY_SPACES, getpid(),
|
---|
| 1249 | this_thread_no, archiving_set_no);
|
---|
| 1250 | archiving_set_no++;
|
---|
| 1251 | }
|
---|
| 1252 | if (!semaphore_p()) {
|
---|
| 1253 | fatal_error("Cannot get semaphore P");
|
---|
| 1254 | }
|
---|
| 1255 | (*p_archival_threads_running)--;
|
---|
| 1256 | if (!semaphore_v()) {
|
---|
| 1257 | fatal_error("Cannot get semaphore V");
|
---|
| 1258 | }
|
---|
| 1259 | log_msg(3, "%s[%d:%d] - exiting", FORTY_SPACES, getpid(),
|
---|
| 1260 | this_thread_no);
|
---|
| 1261 | paranoid_free(archiving_filelist_fname);
|
---|
| 1262 | paranoid_free(archiving_afioball_fname);
|
---|
| 1263 | paranoid_free(curr_xattr_list_fname);
|
---|
| 1264 | paranoid_free(curr_acl_list_fname);
|
---|
| 1265 | paranoid_free(tmp);
|
---|
| 1266 | pthread_exit(NULL);
|
---|
[1] | 1267 | }
|
---|
| 1268 |
|
---|
| 1269 |
|
---|
| 1270 |
|
---|
| 1271 |
|
---|
| 1272 |
|
---|
| 1273 | /**
|
---|
| 1274 | * Finalize the backup.
|
---|
| 1275 | * For streaming backups, this writes the closing block
|
---|
| 1276 | * to the stream. For CD-based backups, this creates
|
---|
| 1277 | * the final ISO image.
|
---|
| 1278 | * @param bkpinfo The backup information structure, used only
|
---|
| 1279 | * for the @c backup_media_type.
|
---|
| 1280 | * @ingroup MLarchiveGroup
|
---|
| 1281 | */
|
---|
[541] | 1282 | int do_that_final_phase(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 1283 | {
|
---|
| 1284 |
|
---|
[128] | 1285 | /*@ int ************************************** */
|
---|
| 1286 | int res = 0;
|
---|
| 1287 | int retval = 0;
|
---|
[1] | 1288 |
|
---|
[128] | 1289 | /*@ buffers ********************************** */
|
---|
[1] | 1290 |
|
---|
[128] | 1291 | assert(bkpinfo != NULL);
|
---|
| 1292 | mvaddstr_and_log_it(g_currentY, 0,
|
---|
| 1293 | "Writing any remaining data to media ");
|
---|
[1] | 1294 |
|
---|
[128] | 1295 | log_msg(1, "Closing tape/CD ... ");
|
---|
| 1296 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type))
|
---|
| 1297 | /* write tape/cdstream */
|
---|
[1] | 1298 | {
|
---|
[128] | 1299 | closeout_tape(bkpinfo);
|
---|
| 1300 | } else
|
---|
| 1301 | /* write final ISO */
|
---|
| 1302 | {
|
---|
[541] | 1303 | res = write_final_iso_if_necessary(bkpinfo);
|
---|
[128] | 1304 | retval += res;
|
---|
| 1305 | if (res) {
|
---|
| 1306 | log_msg(1, "write_final_iso_if_necessary returned an error");
|
---|
| 1307 | }
|
---|
[1] | 1308 | }
|
---|
[128] | 1309 | log_msg(2, "Fork is exiting ... ");
|
---|
[1] | 1310 |
|
---|
[128] | 1311 | mvaddstr_and_log_it(g_currentY++, 74, "Done.");
|
---|
[1] | 1312 |
|
---|
[128] | 1313 | /* final stuff */
|
---|
| 1314 | if (retval) {
|
---|
| 1315 | mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
|
---|
| 1316 | } else {
|
---|
| 1317 | mvaddstr_and_log_it(g_currentY++, 74, "Done.");
|
---|
| 1318 | }
|
---|
[1] | 1319 |
|
---|
[128] | 1320 | return (retval);
|
---|
[1] | 1321 | }
|
---|
| 1322 |
|
---|
| 1323 |
|
---|
| 1324 | /**
|
---|
| 1325 | * Initialize the backup.
|
---|
| 1326 | * Does the following:
|
---|
| 1327 | * - Sets up the serial number.
|
---|
| 1328 | * - For streaming backups, opens the tape stream and writes the data disks
|
---|
| 1329 | * and backup headers.
|
---|
| 1330 | * - For CD-based backups, wipes the ISOs in the target directory.
|
---|
| 1331 | *
|
---|
| 1332 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 1333 | * - @c backup_media_type
|
---|
| 1334 | * - @c cdrw_speed
|
---|
[20] | 1335 | * - @c prefix
|
---|
[1] | 1336 | * - @c isodir
|
---|
| 1337 | * - @c media_device
|
---|
| 1338 | * - @c scratchdir
|
---|
| 1339 | * - @c tmpdir
|
---|
| 1340 | * @return The number of errors encountered (0 for success).
|
---|
| 1341 | * @ingroup MLarchiveGroup
|
---|
| 1342 | */
|
---|
[128] | 1343 | int do_that_initial_phase(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 1344 | {
|
---|
[128] | 1345 | /*@ int *************************************** */
|
---|
| 1346 | int retval = 0;
|
---|
[1] | 1347 |
|
---|
[128] | 1348 | /*@ buffers *********************************** */
|
---|
| 1349 | char *command, *tmpfile, *data_disks_file;
|
---|
[1] | 1350 |
|
---|
[128] | 1351 | assert(bkpinfo != NULL);
|
---|
| 1352 | malloc_string(command);
|
---|
| 1353 | malloc_string(tmpfile);
|
---|
| 1354 | malloc_string(data_disks_file);
|
---|
| 1355 | sprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
|
---|
| 1356 |
|
---|
| 1357 | snprintf(g_serial_string, MAX_STR_LEN - 1,
|
---|
| 1358 | call_program_and_get_last_line_of_output("dd \
|
---|
[1] | 1359 | if=/dev/urandom bs=16 count=1 2> /dev/null | \
|
---|
| 1360 | hexdump | tr -s ' ' '0' | head -n1"));
|
---|
[128] | 1361 | strip_spaces(g_serial_string);
|
---|
| 1362 | strcat(g_serial_string, "...word.");
|
---|
| 1363 | log_msg(2, "g_serial_string = '%s'", g_serial_string);
|
---|
| 1364 | assert(strlen(g_serial_string) < MAX_STR_LEN);
|
---|
[1] | 1365 |
|
---|
[128] | 1366 | sprintf(tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
|
---|
| 1367 | if (write_one_liner_data_file(tmpfile, g_serial_string)) {
|
---|
| 1368 | log_msg(1, "%ld: Failed to write serial string", __LINE__);
|
---|
| 1369 | }
|
---|
[1] | 1370 |
|
---|
[128] | 1371 | mvaddstr_and_log_it(g_currentY, 0, "Preparing to archive your data");
|
---|
| 1372 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 1373 | if (bkpinfo->backup_media_type == cdstream) {
|
---|
| 1374 | openout_cdstream(bkpinfo->media_device, bkpinfo->cdrw_speed);
|
---|
| 1375 | } else {
|
---|
| 1376 | openout_tape(bkpinfo->media_device, bkpinfo->internal_tape_block_size); /* sets g_tape_stream */
|
---|
| 1377 | }
|
---|
| 1378 | if (!g_tape_stream) {
|
---|
| 1379 | fatal_error("Cannot open backup (streaming) device");
|
---|
| 1380 | }
|
---|
| 1381 | log_msg(1, "Backup (stream) opened OK");
|
---|
| 1382 | write_data_disks_to_stream(data_disks_file);
|
---|
| 1383 | } else {
|
---|
| 1384 | log_msg(1, "Backing up to CD's");
|
---|
[1] | 1385 | }
|
---|
| 1386 |
|
---|
[128] | 1387 | sprintf(command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir,
|
---|
| 1388 | bkpinfo->nfs_remote_dir, bkpinfo->prefix);
|
---|
| 1389 | paranoid_system(command);
|
---|
| 1390 | wipe_archives(bkpinfo->scratchdir);
|
---|
| 1391 | mvaddstr_and_log_it(g_currentY++, 74, "Done.");
|
---|
| 1392 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
[684] | 1393 | write_header_block_to_stream((off_t)0, "start-of-tape",
|
---|
[128] | 1394 | BLK_START_OF_TAPE);
|
---|
[684] | 1395 | write_header_block_to_stream((off_t)0, "start-of-backup",
|
---|
[128] | 1396 | BLK_START_OF_BACKUP);
|
---|
| 1397 | }
|
---|
| 1398 | paranoid_free(command);
|
---|
| 1399 | paranoid_free(tmpfile);
|
---|
| 1400 | paranoid_free(data_disks_file);
|
---|
| 1401 | return (retval);
|
---|
[1] | 1402 | }
|
---|
| 1403 |
|
---|
| 1404 |
|
---|
| 1405 | /**
|
---|
| 1406 | * Calls floppy-formatting @c cmd and tracks its progress if possible.
|
---|
| 1407 | *
|
---|
| 1408 | * @param cmd The command to run (e.g. @c fdformat @c /dev/fd0).
|
---|
| 1409 | * @param title The human-friendly description of the floppy you are writing.
|
---|
| 1410 | * This will be used as the title in the progress bar window. Example:
|
---|
| 1411 | * "Formatting disk /dev/fd0".
|
---|
| 1412 | * @see format_disk
|
---|
| 1413 | * @return The exit code of fdformat/superformat.
|
---|
| 1414 | */
|
---|
[128] | 1415 | int format_disk_SUB(char *cmd, char *title)
|
---|
[1] | 1416 | {
|
---|
| 1417 |
|
---|
[128] | 1418 | /*@ int *************************************************************** */
|
---|
| 1419 | int res = 0;
|
---|
[1] | 1420 | int percentage = 0;
|
---|
| 1421 | int maxtracks = 0;
|
---|
| 1422 | int trackno = 0;
|
---|
| 1423 | int last_trkno = 0;
|
---|
| 1424 |
|
---|
[128] | 1425 | /*@ buffers *********************************************************** */
|
---|
| 1426 | char *command;
|
---|
| 1427 | char *tempfile;
|
---|
[1] | 1428 |
|
---|
[128] | 1429 | /*@ pointers ********************************************************** */
|
---|
| 1430 | FILE *pin;
|
---|
[1] | 1431 |
|
---|
[128] | 1432 | assert_string_is_neither_NULL_nor_zerolength(cmd);
|
---|
| 1433 | assert_string_is_neither_NULL_nor_zerolength(title);
|
---|
[1] | 1434 |
|
---|
[128] | 1435 | malloc_string(command);
|
---|
| 1436 | malloc_string(tempfile);
|
---|
[1] | 1437 | #ifdef __FreeBSD__
|
---|
| 1438 | /* Ugh. FreeBSD fdformat prints out this pretty progress indicator that's
|
---|
| 1439 | impossible to parse. It looks like
|
---|
| 1440 | VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVF-------------------
|
---|
| 1441 | where V means verified, E means error, F means formatted, and - means
|
---|
| 1442 | not done yet.
|
---|
| 1443 | */
|
---|
[128] | 1444 | return (run_program_and_log_to_screen(cmd, title));
|
---|
[1] | 1445 | #endif
|
---|
| 1446 |
|
---|
| 1447 | /* if Debian then do bog-standard superformat; don't be pretty */
|
---|
[128] | 1448 | if (strstr(cmd, "superformat")) {
|
---|
| 1449 | return (run_program_and_log_to_screen(cmd, title));
|
---|
| 1450 | }
|
---|
[1] | 1451 | /* if not Debian then go ahead & use fdformat */
|
---|
[128] | 1452 | strcpy(tempfile,
|
---|
| 1453 | call_program_and_get_last_line_of_output
|
---|
| 1454 | ("mktemp -q /tmp/mondo.XXXXXXXX"));
|
---|
| 1455 | sprintf(command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile,
|
---|
| 1456 | tempfile);
|
---|
| 1457 | log_msg(3, command);
|
---|
| 1458 | open_evalcall_form(title);
|
---|
| 1459 | if (!(pin = popen(command, "r"))) {
|
---|
| 1460 | log_OS_error("fmt err");
|
---|
| 1461 | return (1);
|
---|
[1] | 1462 | }
|
---|
[128] | 1463 | if (strstr(command, "1722")) {
|
---|
| 1464 | maxtracks = 82;
|
---|
| 1465 | } else {
|
---|
| 1466 | maxtracks = 80;
|
---|
[1] | 1467 | }
|
---|
[128] | 1468 | for (sleep(1); does_file_exist(tempfile); sleep(1)) {
|
---|
| 1469 | trackno = get_trackno_from_logfile(tempfile);
|
---|
| 1470 | if (trackno < 0 || trackno > 80) {
|
---|
| 1471 | log_msg(1, "Weird track#");
|
---|
| 1472 | continue;
|
---|
| 1473 | }
|
---|
| 1474 | percentage = trackno * 100 / maxtracks;
|
---|
| 1475 | if (trackno <= 5 && last_trkno > 40) {
|
---|
| 1476 | close_evalcall_form();
|
---|
| 1477 | strcpy(title, "Verifying format");
|
---|
| 1478 | open_evalcall_form(title);
|
---|
| 1479 | }
|
---|
| 1480 | last_trkno = trackno;
|
---|
| 1481 | update_evalcall_form(percentage);
|
---|
| 1482 | }
|
---|
| 1483 | close_evalcall_form();
|
---|
| 1484 | if (pclose(pin)) {
|
---|
| 1485 | res++;
|
---|
| 1486 | log_OS_error("Unable to pclose");
|
---|
| 1487 | }
|
---|
| 1488 | unlink(tempfile);
|
---|
| 1489 | paranoid_free(command);
|
---|
| 1490 | paranoid_free(tempfile);
|
---|
| 1491 | return (res);
|
---|
[1] | 1492 | }
|
---|
| 1493 |
|
---|
| 1494 | /**
|
---|
| 1495 | * Wrapper around @c format_disk_SUB().
|
---|
| 1496 | * This function calls @c format_disk_SUB() with a @c device of its @c device
|
---|
| 1497 | * parameter and a @c title of Formatting disk @c device. If the format
|
---|
| 1498 | * fails, the user will be given the option of retrying.
|
---|
| 1499 | *
|
---|
| 1500 | * @param device The floppy drive to write to.
|
---|
| 1501 | * @see format_disk_SUB
|
---|
| 1502 | * @return The exit code of fdformat/superformat.
|
---|
| 1503 | * @ingroup deviceGroup
|
---|
| 1504 | */
|
---|
[128] | 1505 | int format_disk(char *device)
|
---|
[1] | 1506 | {
|
---|
| 1507 |
|
---|
[128] | 1508 | /*@ int ************************************************************** */
|
---|
| 1509 | int res = 0;
|
---|
[1] | 1510 |
|
---|
[128] | 1511 | /*@ buffer *********************************************************** */
|
---|
| 1512 | char *command;
|
---|
| 1513 | char *title;
|
---|
| 1514 |
|
---|
| 1515 |
|
---|
| 1516 | assert_string_is_neither_NULL_nor_zerolength(device);
|
---|
| 1517 | malloc_string(title);
|
---|
| 1518 | command = malloc(1000);
|
---|
| 1519 | if (!system("which superformat > /dev/null 2> /dev/null")) {
|
---|
| 1520 | sprintf(command, "superformat %s", device);
|
---|
| 1521 | } else {
|
---|
[1] | 1522 | #ifdef __FreeBSD__
|
---|
[128] | 1523 | sprintf(command, "fdformat -y %s", device);
|
---|
[1] | 1524 | #else
|
---|
[128] | 1525 | sprintf(command, "fdformat %s", device);
|
---|
[1] | 1526 | #endif
|
---|
| 1527 | }
|
---|
[128] | 1528 | sprintf(title, "Formatting disk %s", device);
|
---|
| 1529 | while ((res = format_disk_SUB(command, title))) {
|
---|
| 1530 | if (!ask_me_yes_or_no("Failed to format disk. Retry?")) {
|
---|
| 1531 | return (res);
|
---|
| 1532 | }
|
---|
| 1533 | }
|
---|
| 1534 | paranoid_free(title);
|
---|
| 1535 | paranoid_free(command);
|
---|
| 1536 | return (res);
|
---|
[1] | 1537 | }
|
---|
| 1538 |
|
---|
| 1539 | /**
|
---|
| 1540 | * Get the <tt>N</tt>th bit of @c array.
|
---|
| 1541 | * @param array The bit-array (as a @c char pointer).
|
---|
| 1542 | * @param N The number of the bit you want.
|
---|
| 1543 | * @return TRUE (bit is set) or FALSE (bit is not set).
|
---|
| 1544 | * @see set_bit_N_of_array
|
---|
| 1545 | * @ingroup utilityGroup
|
---|
| 1546 | */
|
---|
[128] | 1547 | bool get_bit_N_of_array(char *array, int N)
|
---|
[1] | 1548 | {
|
---|
[128] | 1549 | int element_number;
|
---|
| 1550 | int bit_number;
|
---|
| 1551 | int mask;
|
---|
| 1552 |
|
---|
| 1553 | element_number = N / 8;
|
---|
| 1554 | bit_number = N % 8;
|
---|
| 1555 | mask = 1 << bit_number;
|
---|
| 1556 | if (array[element_number] & mask) {
|
---|
| 1557 | return (TRUE);
|
---|
| 1558 | } else {
|
---|
| 1559 | return (FALSE);
|
---|
| 1560 | }
|
---|
[1] | 1561 | }
|
---|
| 1562 |
|
---|
| 1563 |
|
---|
| 1564 |
|
---|
| 1565 |
|
---|
| 1566 |
|
---|
| 1567 |
|
---|
| 1568 |
|
---|
| 1569 |
|
---|
| 1570 |
|
---|
| 1571 | /**
|
---|
| 1572 | * @addtogroup LLarchiveGroup
|
---|
| 1573 | * @{
|
---|
| 1574 | */
|
---|
| 1575 | /**
|
---|
| 1576 | * Start up threads to archive your files.
|
---|
| 1577 | *
|
---|
| 1578 | * This function starts @c ARCH_THREADS threads,
|
---|
| 1579 | * each starting execution in @c create_afio_files_in_background().
|
---|
| 1580 | * Each thread will archive individual filesets, based on the
|
---|
| 1581 | * pointers passed to it and continually updated, until all files
|
---|
| 1582 | * have been backed up. This function coordinates the threads
|
---|
| 1583 | * and copies their output to the @c scratchdir.
|
---|
| 1584 | *
|
---|
| 1585 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 1586 | * - @c backup_media_type
|
---|
| 1587 | * - @c scratchdir
|
---|
| 1588 | * - @c tmpdir
|
---|
| 1589 | * - @c zip_suffix
|
---|
| 1590 | *
|
---|
| 1591 | * @return The number of errors encountered (0 for success)
|
---|
| 1592 | */
|
---|
[541] | 1593 | int make_afioballs_and_images(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 1594 | {
|
---|
| 1595 |
|
---|
[128] | 1596 | /*@ int ************************************************** */
|
---|
| 1597 | int retval = 0;
|
---|
| 1598 | long int storing_set_no = 0;
|
---|
| 1599 | int res = 0;
|
---|
| 1600 | bool done_storing = FALSE;
|
---|
| 1601 | char *result_str;
|
---|
| 1602 | char *transfer_block;
|
---|
| 1603 | void *vp;
|
---|
| 1604 | void **pvp;
|
---|
[1] | 1605 |
|
---|
[128] | 1606 | /*@ buffers ********************************************** */
|
---|
| 1607 | char *storing_filelist_fname;
|
---|
| 1608 | char *storing_afioball_fname;
|
---|
| 1609 | char *tmp;
|
---|
| 1610 | char *media_usage_comment;
|
---|
| 1611 | pthread_t archival_thread[ARCH_THREADS];
|
---|
| 1612 | char *p_list_of_fileset_flags;
|
---|
| 1613 | int *p_archival_threads_running;
|
---|
| 1614 | int *p_last_set_archived;
|
---|
| 1615 | int *p_next_set_to_archive;
|
---|
| 1616 | int noof_threads;
|
---|
| 1617 | int i;
|
---|
[948] | 1618 | char *curr_xattr_list_fname = NULL;
|
---|
[128] | 1619 | char *curr_acl_list_fname;
|
---|
| 1620 | int misc_counter_that_is_not_important = 0;
|
---|
[1] | 1621 |
|
---|
[128] | 1622 | log_msg(8, "here");
|
---|
| 1623 | assert(bkpinfo != NULL);
|
---|
| 1624 | tmp = malloc(MAX_STR_LEN * 2);
|
---|
| 1625 | malloc_string(result_str);
|
---|
| 1626 | malloc_string(curr_xattr_list_fname);
|
---|
| 1627 | malloc_string(curr_acl_list_fname);
|
---|
| 1628 | malloc_string(storing_filelist_fname);
|
---|
| 1629 | malloc_string(media_usage_comment);
|
---|
| 1630 | malloc_string(storing_afioball_fname);
|
---|
| 1631 | transfer_block =
|
---|
| 1632 | malloc(sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
|
---|
| 1633 | memset((void *) transfer_block, 0,
|
---|
| 1634 | sizeof(struct s_bkpinfo) + BKPINFO_LOC_OFFSET + 64);
|
---|
| 1635 | p_last_set_archived = (int *) transfer_block;
|
---|
| 1636 | p_archival_threads_running = (int *) (transfer_block + 4);
|
---|
| 1637 | p_next_set_to_archive = (int *) (transfer_block + 8);
|
---|
| 1638 | p_list_of_fileset_flags = (char *) (transfer_block + 12);
|
---|
| 1639 | memcpy((void *) (transfer_block + BKPINFO_LOC_OFFSET),
|
---|
| 1640 | (void *) bkpinfo, sizeof(struct s_bkpinfo));
|
---|
| 1641 | pvp = &vp;
|
---|
| 1642 | vp = (void *) result_str;
|
---|
| 1643 | *p_archival_threads_running = 0;
|
---|
| 1644 | *p_last_set_archived = -1;
|
---|
| 1645 | *p_next_set_to_archive = 0;
|
---|
| 1646 | sprintf(tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);
|
---|
| 1647 | log_to_screen("Archiving regular files");
|
---|
| 1648 | log_msg(5, "Go, Shorty. It's your birthday.");
|
---|
[541] | 1649 | open_progress_form("Backing up filesystem",
|
---|
| 1650 | "I am backing up your live filesystem now.",
|
---|
| 1651 | "Please wait. This may take a couple of hours.",
|
---|
| 1652 | "Working...",
|
---|
[128] | 1653 | get_last_filelist_number(bkpinfo) + 1);
|
---|
[1] | 1654 |
|
---|
[128] | 1655 | log_msg(5, "We're gonna party like it's your birthday.");
|
---|
[1] | 1656 |
|
---|
[128] | 1657 | srand((unsigned int) getpid());
|
---|
| 1658 | g_sem_key = 1234 + random() % 30000;
|
---|
| 1659 | if ((g_sem_id =
|
---|
| 1660 | semget((key_t) g_sem_key, 1,
|
---|
| 1661 | IPC_CREAT | S_IREAD | S_IWRITE)) == -1) {
|
---|
| 1662 | fatal_error("MABAI - unable to semget");
|
---|
[1] | 1663 | }
|
---|
[128] | 1664 | if (!set_semvalue()) {
|
---|
| 1665 | fatal_error("Unable to init semaphore");
|
---|
| 1666 | } // initialize semaphore
|
---|
| 1667 | for (noof_threads = 0; noof_threads < ARCH_THREADS; noof_threads++) {
|
---|
| 1668 | log_msg(8, "Creating thread #%d", noof_threads);
|
---|
| 1669 | (*p_archival_threads_running)++;
|
---|
| 1670 | if ((res =
|
---|
| 1671 | pthread_create(&archival_thread[noof_threads], NULL,
|
---|
| 1672 | create_afio_files_in_background,
|
---|
| 1673 | (void *) transfer_block))) {
|
---|
| 1674 | fatal_error("Unable to create an archival thread");
|
---|
| 1675 | }
|
---|
[1] | 1676 | }
|
---|
| 1677 |
|
---|
[128] | 1678 | log_msg(8, "About to enter while() loop");
|
---|
| 1679 | while (!done_storing) {
|
---|
| 1680 | if (g_exiting) {
|
---|
| 1681 | fatal_error("Execution run aborted (main loop)");
|
---|
| 1682 | }
|
---|
| 1683 | if (*p_archival_threads_running == 0
|
---|
| 1684 | && *p_last_set_archived == storing_set_no - 1) {
|
---|
| 1685 | log_msg(2,
|
---|
| 1686 | "No archival threads are running. The last stored set was %d and I'm looking for %d. Take off your make-up; the party's over... :-)",
|
---|
| 1687 | *p_last_set_archived, storing_set_no);
|
---|
| 1688 | done_storing = TRUE;
|
---|
| 1689 | } else
|
---|
| 1690 | if (!get_bit_N_of_array
|
---|
| 1691 | (p_list_of_fileset_flags, storing_set_no)) {
|
---|
| 1692 | misc_counter_that_is_not_important =
|
---|
| 1693 | (misc_counter_that_is_not_important + 1) % 5;
|
---|
| 1694 | if (!misc_counter_that_is_not_important) {
|
---|
| 1695 | update_progress_form(media_usage_comment);
|
---|
| 1696 | }
|
---|
| 1697 | sleep(1);
|
---|
| 1698 | } else
|
---|
| 1699 | // store set N
|
---|
| 1700 | {
|
---|
| 1701 | sprintf(storing_filelist_fname, FILELIST_FNAME_RAW_SZ,
|
---|
| 1702 | bkpinfo->tmpdir, storing_set_no);
|
---|
| 1703 | sprintf(storing_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
|
---|
| 1704 | bkpinfo->tmpdir, storing_set_no, bkpinfo->zip_suffix);
|
---|
[948] | 1705 | if (g_getfattr) {
|
---|
| 1706 | sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
|
---|
[128] | 1707 | bkpinfo->tmpdir, storing_set_no);
|
---|
[948] | 1708 | }
|
---|
| 1709 | if (g_getfacl) {
|
---|
| 1710 | sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
|
---|
[128] | 1711 | bkpinfo->tmpdir, storing_set_no);
|
---|
[948] | 1712 | }
|
---|
[128] | 1713 |
|
---|
| 1714 | log_msg(2, "Storing set %d", storing_set_no);
|
---|
| 1715 | while (!does_file_exist(storing_filelist_fname)
|
---|
| 1716 | || !does_file_exist(storing_afioball_fname)) {
|
---|
| 1717 | log_msg(2,
|
---|
| 1718 | "Warning - either %s or %s doesn't exist yet. I'll pause 5 secs.",
|
---|
| 1719 | storing_filelist_fname, storing_afioball_fname);
|
---|
| 1720 | sleep(5);
|
---|
| 1721 | }
|
---|
| 1722 | strcpy(media_usage_comment,
|
---|
| 1723 | percent_media_full_comment(bkpinfo));
|
---|
| 1724 | /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
|
---|
| 1725 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 1726 | register_in_tape_catalog(fileset, storing_set_no, -1,
|
---|
| 1727 | storing_afioball_fname);
|
---|
| 1728 | maintain_collection_of_recent_archives(bkpinfo->tmpdir,
|
---|
| 1729 | storing_afioball_fname);
|
---|
| 1730 | iamhere("Writing EXAT files");
|
---|
| 1731 | res +=
|
---|
| 1732 | write_EXAT_files_to_tape(bkpinfo,
|
---|
| 1733 | curr_xattr_list_fname,
|
---|
| 1734 | curr_acl_list_fname);
|
---|
[1] | 1735 | // archives themselves
|
---|
[128] | 1736 | res +=
|
---|
| 1737 | move_files_to_stream(bkpinfo, storing_afioball_fname,
|
---|
| 1738 | NULL);
|
---|
| 1739 | } else {
|
---|
[948] | 1740 | if (g_getfacl) {
|
---|
| 1741 | if (g_getfattr) {
|
---|
| 1742 | res = move_files_to_cd(bkpinfo, storing_filelist_fname,
|
---|
[128] | 1743 | curr_xattr_list_fname,
|
---|
| 1744 | curr_acl_list_fname,
|
---|
| 1745 | storing_afioball_fname, NULL);
|
---|
[948] | 1746 | } else {
|
---|
| 1747 | res = move_files_to_cd(bkpinfo, storing_filelist_fname,
|
---|
| 1748 | curr_acl_list_fname,
|
---|
| 1749 | storing_afioball_fname, NULL);
|
---|
| 1750 | }
|
---|
| 1751 | } else {
|
---|
| 1752 | if (g_getfattr) {
|
---|
| 1753 | res = move_files_to_cd(bkpinfo, storing_filelist_fname,
|
---|
| 1754 | curr_xattr_list_fname,
|
---|
| 1755 | storing_afioball_fname, NULL);
|
---|
| 1756 | } else {
|
---|
| 1757 | res = move_files_to_cd(bkpinfo, storing_filelist_fname,
|
---|
| 1758 | storing_afioball_fname, NULL);
|
---|
| 1759 | }
|
---|
| 1760 | }
|
---|
[128] | 1761 | }
|
---|
| 1762 | retval += res;
|
---|
| 1763 | g_current_progress++;
|
---|
| 1764 | update_progress_form(media_usage_comment);
|
---|
| 1765 | if (res) {
|
---|
| 1766 | sprintf(tmp,
|
---|
| 1767 | "Failed to add archive %ld's files to CD dir\n",
|
---|
| 1768 | storing_set_no);
|
---|
| 1769 | log_to_screen(tmp);
|
---|
| 1770 | fatal_error
|
---|
| 1771 | ("Is your hard disk full? If not, please send the author the logfile.");
|
---|
| 1772 | }
|
---|
| 1773 | storing_set_no++;
|
---|
| 1774 | // sleep(2);
|
---|
[1] | 1775 | }
|
---|
| 1776 | }
|
---|
[128] | 1777 | close_progress_form();
|
---|
[1] | 1778 |
|
---|
[128] | 1779 | sprintf(tmp, "Your regular files have been archived ");
|
---|
| 1780 | log_msg(2, "Joining background threads to foreground thread");
|
---|
| 1781 | for (i = 0; i < noof_threads; i++) {
|
---|
| 1782 | pthread_join(archival_thread[i], pvp);
|
---|
| 1783 | log_msg(3, "Thread %d of %d: closed OK", i + 1, noof_threads);
|
---|
| 1784 | }
|
---|
| 1785 | del_semvalue();
|
---|
| 1786 | log_msg(2, "Done.");
|
---|
| 1787 | if (retval) {
|
---|
| 1788 | strcat(tmp, "(with errors).");
|
---|
| 1789 | } else {
|
---|
| 1790 | strcat(tmp, "successfully.");
|
---|
| 1791 | }
|
---|
| 1792 | log_to_screen(tmp);
|
---|
| 1793 | paranoid_free(transfer_block);
|
---|
| 1794 | paranoid_free(result_str);
|
---|
| 1795 | paranoid_free(storing_filelist_fname);
|
---|
| 1796 | paranoid_free(media_usage_comment);
|
---|
| 1797 | paranoid_free(storing_afioball_fname);
|
---|
| 1798 | paranoid_free(curr_xattr_list_fname);
|
---|
| 1799 | paranoid_free(curr_acl_list_fname);
|
---|
| 1800 | return (retval);
|
---|
[1] | 1801 | }
|
---|
| 1802 |
|
---|
| 1803 |
|
---|
[128] | 1804 | void pause_for_N_seconds(int how_long, char *msg)
|
---|
[1] | 1805 | {
|
---|
[128] | 1806 | int i;
|
---|
| 1807 | open_evalcall_form(msg);
|
---|
| 1808 | for (i = 0; i < how_long; i++) {
|
---|
| 1809 | update_evalcall_form((int) ((100.0 / (float) (how_long) * i)));
|
---|
| 1810 | sleep(1);
|
---|
| 1811 | }
|
---|
| 1812 | close_evalcall_form();
|
---|
[1] | 1813 | }
|
---|
| 1814 |
|
---|
| 1815 |
|
---|
| 1816 |
|
---|
| 1817 |
|
---|
| 1818 | /**
|
---|
| 1819 | * Create an ISO image in @c destfile, from files in @c bkpinfo->scratchdir.
|
---|
| 1820 | *
|
---|
| 1821 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 1822 | * - @c backup_media_type
|
---|
| 1823 | * - @c call_after_iso
|
---|
| 1824 | * - @c call_before_iso
|
---|
| 1825 | * - @c call_burn_iso
|
---|
| 1826 | * - @c call_make_iso
|
---|
| 1827 | * - @c make_cd_use_lilo
|
---|
| 1828 | * - @c manual_cd_tray
|
---|
| 1829 | * - @c nonbootable_backup
|
---|
| 1830 | * - @c scratchdir
|
---|
| 1831 | *
|
---|
| 1832 | * @param destfile Where to put the generated ISO image.
|
---|
| 1833 | * @return The number of errors encountered (0 for success)
|
---|
| 1834 | */
|
---|
[541] | 1835 | int make_iso_fs(struct s_bkpinfo *bkpinfo, char *destfile)
|
---|
[1] | 1836 | {
|
---|
[128] | 1837 | /*@ int ********************************************** */
|
---|
| 1838 | int retval = 0;
|
---|
| 1839 | int res;
|
---|
[1] | 1840 |
|
---|
[128] | 1841 | /*@ buffers ****************************************** */
|
---|
| 1842 | char *tmp;
|
---|
| 1843 | char *old_pwd;
|
---|
| 1844 | char *result_sz;
|
---|
| 1845 | char *message_to_screen;
|
---|
| 1846 | char *sz_blank_disk;
|
---|
| 1847 | char *fnam;
|
---|
| 1848 | char *tmp2;
|
---|
| 1849 | char *tmp3;
|
---|
| 1850 | bool cd_is_mountable;
|
---|
[1] | 1851 |
|
---|
[128] | 1852 | malloc_string(old_pwd);
|
---|
| 1853 | malloc_string(result_sz);
|
---|
| 1854 | malloc_string(message_to_screen);
|
---|
| 1855 | malloc_string(sz_blank_disk);
|
---|
| 1856 | malloc_string(fnam);
|
---|
| 1857 | tmp = malloc(1200);
|
---|
| 1858 | tmp2 = malloc(1200);
|
---|
| 1859 | tmp3 = malloc(1200);
|
---|
| 1860 | assert(bkpinfo != NULL);
|
---|
| 1861 | assert_string_is_neither_NULL_nor_zerolength(destfile);
|
---|
[1] | 1862 |
|
---|
[128] | 1863 | sprintf(tmp, "%s/isolinux.bin", bkpinfo->scratchdir);
|
---|
| 1864 | sprintf(tmp2, "%s/isolinux.bin", bkpinfo->tmpdir);
|
---|
| 1865 | if (does_file_exist(tmp)) {
|
---|
| 1866 | sprintf(tmp3, "cp -f %s %s", tmp, tmp2);
|
---|
| 1867 | paranoid_system(tmp3);
|
---|
[1] | 1868 | }
|
---|
[128] | 1869 | if (!does_file_exist(tmp) && does_file_exist(tmp2)) {
|
---|
| 1870 | sprintf(tmp3, "cp -f %s %s", tmp2, tmp);
|
---|
| 1871 | paranoid_system(tmp3);
|
---|
[1] | 1872 | }
|
---|
[128] | 1873 | /*
|
---|
| 1874 | if (!does_file_exist(tmp))
|
---|
| 1875 | {
|
---|
| 1876 | log_msg (2, "Silly bug in Mindi.pl; workaround in progress...");
|
---|
| 1877 | strcpy(fnam, call_program_and_get_last_line_of_output("locate isolinux.bin | tail -n1"));
|
---|
| 1878 | if (strlen(fnam)>0 && does_file_exist(fnam))
|
---|
| 1879 | {
|
---|
| 1880 | sprintf(tmp, "cp -f %s %s", fnam, bkpinfo->scratchdir);
|
---|
| 1881 | res = run_program_and_log_output(tmp, FALSE);
|
---|
| 1882 | }
|
---|
| 1883 | else
|
---|
| 1884 | {
|
---|
| 1885 | res = 1;
|
---|
| 1886 | }
|
---|
| 1887 | if (res)
|
---|
| 1888 | {
|
---|
| 1889 | log_msg (2, "Could not work around silly bug in Mindi.pl - sorry! Isolinux.bin missing");
|
---|
| 1890 | }
|
---|
| 1891 | }
|
---|
| 1892 | */
|
---|
| 1893 | free(tmp2);
|
---|
| 1894 | free(tmp3);
|
---|
| 1895 | tmp2 = NULL;
|
---|
| 1896 | tmp3 = NULL;
|
---|
| 1897 | if (bkpinfo->backup_media_type == iso && bkpinfo->manual_cd_tray) {
|
---|
[541] | 1898 | popup_and_OK("Please insert new media and press Enter.");
|
---|
[128] | 1899 | }
|
---|
[1] | 1900 |
|
---|
[128] | 1901 | log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s",
|
---|
| 1902 | bkpinfo->scratchdir, destfile);
|
---|
| 1903 | (void) getcwd(old_pwd, MAX_STR_LEN - 1);
|
---|
| 1904 | sprintf(tmp, "chmod 744 %s", bkpinfo->scratchdir);
|
---|
| 1905 | run_program_and_log_output(tmp, FALSE);
|
---|
| 1906 | chdir(bkpinfo->scratchdir);
|
---|
[1] | 1907 |
|
---|
[128] | 1908 | if (bkpinfo->call_before_iso[0] != '\0') {
|
---|
| 1909 | sprintf(message_to_screen, "Running pre-ISO call for CD#%d",
|
---|
| 1910 | g_current_media_number);
|
---|
| 1911 | res =
|
---|
| 1912 | eval_call_to_make_ISO(bkpinfo, bkpinfo->call_before_iso,
|
---|
| 1913 | destfile, g_current_media_number,
|
---|
| 1914 | MONDO_LOGFILE, message_to_screen);
|
---|
| 1915 | if (res) {
|
---|
| 1916 | strcat(message_to_screen, "...failed");
|
---|
| 1917 | } else {
|
---|
| 1918 | strcat(message_to_screen, "...OK");
|
---|
| 1919 | }
|
---|
| 1920 | log_to_screen(message_to_screen);
|
---|
| 1921 | retval += res;
|
---|
[1] | 1922 | }
|
---|
| 1923 |
|
---|
[128] | 1924 | if (bkpinfo->call_make_iso[0] != '\0') {
|
---|
| 1925 | log_msg(2, "bkpinfo->call_make_iso = %s", bkpinfo->call_make_iso);
|
---|
| 1926 | sprintf(tmp, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
|
---|
| 1927 | sprintf(message_to_screen, "Making an ISO (%s #%d)",
|
---|
| 1928 | media_descriptor_string(bkpinfo->backup_media_type),
|
---|
| 1929 | g_current_media_number);
|
---|
[1] | 1930 |
|
---|
[128] | 1931 | pause_and_ask_for_cdr(2, &cd_is_mountable); /* if g_current_media_number >= 2 then pause & ask */
|
---|
| 1932 | if (retval) {
|
---|
| 1933 | log_to_screen
|
---|
| 1934 | ("Serious error(s) occurred already. I shan't try to write to media.");
|
---|
| 1935 | } else {
|
---|
| 1936 | res =
|
---|
| 1937 | eval_call_to_make_ISO(bkpinfo, bkpinfo->call_make_iso,
|
---|
| 1938 | bkpinfo->scratchdir,
|
---|
| 1939 | g_current_media_number,
|
---|
| 1940 | MONDO_LOGFILE, message_to_screen);
|
---|
| 1941 | if (res) {
|
---|
| 1942 | log_to_screen("%s...failed to write", message_to_screen);
|
---|
| 1943 | } else {
|
---|
| 1944 | log_to_screen("%s...OK", message_to_screen);
|
---|
| 1945 | if (!run_program_and_log_output
|
---|
[681] | 1946 | ("tail -n10 /var/log/mondo-archive.log | grep -F ':-('",
|
---|
[128] | 1947 | 1)) {
|
---|
| 1948 | log_to_screen
|
---|
| 1949 | ("Despite nonfatal errors, growisofs confirms the write was successful.");
|
---|
| 1950 | }
|
---|
| 1951 | }
|
---|
| 1952 | retval += res;
|
---|
[1] | 1953 | #ifdef DVDRWFORMAT
|
---|
[128] | 1954 | sprintf(tmp,
|
---|
| 1955 | "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'",
|
---|
| 1956 | MONDO_LOGFILE);
|
---|
| 1957 | if (g_backup_media_type == dvd
|
---|
| 1958 | && (res || !run_program_and_log_output(tmp, 1))) {
|
---|
| 1959 | log_to_screen
|
---|
| 1960 | ("Failed to write to disk. I shall blank it and then try again.");
|
---|
| 1961 | sleep(5);
|
---|
| 1962 | system("sync");
|
---|
| 1963 | pause_for_N_seconds(5, "Letting DVD drive settle");
|
---|
[1] | 1964 |
|
---|
| 1965 | // dvd+rw-format --- OPTION 2
|
---|
[128] | 1966 | if (!bkpinfo->please_dont_eject) {
|
---|
| 1967 | log_to_screen("Ejecting media to clear drive status.");
|
---|
| 1968 | eject_device(bkpinfo->media_device);
|
---|
| 1969 | inject_device(bkpinfo->media_device);
|
---|
| 1970 | }
|
---|
| 1971 | pause_for_N_seconds(5, "Letting DVD drive settle");
|
---|
[908] | 1972 | sprintf(sz_blank_disk, "dvd+rw-format -force %s",
|
---|
[128] | 1973 | bkpinfo->media_device);
|
---|
| 1974 | log_msg(3, "sz_blank_disk = '%s'", sz_blank_disk);
|
---|
| 1975 | res =
|
---|
| 1976 | run_external_binary_with_percentage_indicator_NEW
|
---|
| 1977 | ("Blanking DVD disk", sz_blank_disk);
|
---|
| 1978 | if (res) {
|
---|
| 1979 | log_to_screen
|
---|
| 1980 | ("Warning - format failed. (Was it a DVD-R?) Sleeping for 5 seconds to take a breath...");
|
---|
| 1981 | pause_for_N_seconds(5,
|
---|
| 1982 | "Letting DVD drive settle... and trying again.");
|
---|
| 1983 | res =
|
---|
| 1984 | run_external_binary_with_percentage_indicator_NEW
|
---|
| 1985 | ("Blanking DVD disk", sz_blank_disk);
|
---|
| 1986 | if (res) {
|
---|
| 1987 | log_to_screen("Format failed a second time.");
|
---|
| 1988 | }
|
---|
| 1989 | } else {
|
---|
| 1990 | log_to_screen
|
---|
| 1991 | ("Format succeeded. Sleeping for 5 seconds to take a breath...");
|
---|
| 1992 | }
|
---|
| 1993 | pause_for_N_seconds(5, "Letting DVD drive settle");
|
---|
| 1994 | if (!bkpinfo->please_dont_eject) {
|
---|
| 1995 | log_to_screen("Ejecting media to clear drive status.");
|
---|
| 1996 | eject_device(bkpinfo->media_device);
|
---|
| 1997 | inject_device(bkpinfo->media_device);
|
---|
| 1998 | }
|
---|
| 1999 | pause_for_N_seconds(5, "Letting DVD drive settle");
|
---|
| 2000 | res =
|
---|
| 2001 | eval_call_to_make_ISO(bkpinfo, bkpinfo->call_make_iso,
|
---|
| 2002 | bkpinfo->scratchdir,
|
---|
| 2003 | g_current_media_number,
|
---|
| 2004 | MONDO_LOGFILE,
|
---|
| 2005 | message_to_screen);
|
---|
| 2006 | retval += res;
|
---|
| 2007 | if (!bkpinfo->please_dont_eject) {
|
---|
| 2008 | log_to_screen("Ejecting media.");
|
---|
| 2009 | eject_device(bkpinfo->media_device);
|
---|
| 2010 | }
|
---|
| 2011 | if (res) {
|
---|
| 2012 | log_to_screen("Dagnabbit. It still failed.");
|
---|
| 2013 | } else {
|
---|
| 2014 | log_to_screen
|
---|
| 2015 | ("OK, this time I successfully backed up to DVD.");
|
---|
| 2016 | }
|
---|
| 2017 | }
|
---|
| 2018 | #endif
|
---|
| 2019 | if (g_backup_media_type == dvd && !bkpinfo->please_dont_eject) {
|
---|
| 2020 | eject_device(bkpinfo->media_device);
|
---|
| 2021 | }
|
---|
[1] | 2022 | }
|
---|
[128] | 2023 | } else {
|
---|
| 2024 | sprintf(message_to_screen, "Running mkisofs to make %s #%d",
|
---|
| 2025 | media_descriptor_string(bkpinfo->backup_media_type),
|
---|
| 2026 | g_current_media_number);
|
---|
| 2027 | log_msg(1, message_to_screen);
|
---|
| 2028 | sprintf(result_sz, "Call to mkisofs to make ISO (%s #%d) ",
|
---|
| 2029 | media_descriptor_string(bkpinfo->backup_media_type),
|
---|
| 2030 | g_current_media_number);
|
---|
| 2031 | if (bkpinfo->nonbootable_backup) {
|
---|
| 2032 | log_msg(1, "Making nonbootable backup");
|
---|
[1] | 2033 | // FIXME --- change mkisofs string to MONDO_MKISOFS_NONBOOTABLE and add ' .' at end
|
---|
[128] | 2034 | res =
|
---|
| 2035 | eval_call_to_make_ISO(bkpinfo,
|
---|
[906] | 2036 | "mkisofs -o '_ISO_' -r -p MondoRescue -publisher www.mondorescue.org -A MondoRescue_GPL -V _CD#_ .",
|
---|
[128] | 2037 | destfile, g_current_media_number,
|
---|
| 2038 | MONDO_LOGFILE, message_to_screen);
|
---|
| 2039 | } else {
|
---|
| 2040 | log_msg(1, "Making bootable backup");
|
---|
[1] | 2041 |
|
---|
| 2042 | #ifdef __FreeBSD__
|
---|
[128] | 2043 | bkpinfo->make_cd_use_lilo = TRUE;
|
---|
[1] | 2044 | #endif
|
---|
| 2045 |
|
---|
| 2046 |
|
---|
[128] | 2047 | log_msg(1, "make_cd_use_lilo is actually %d",
|
---|
| 2048 | bkpinfo->make_cd_use_lilo);
|
---|
| 2049 | if (bkpinfo->make_cd_use_lilo) {
|
---|
| 2050 | log_msg(1, "make_cd_use_lilo = TRUE");
|
---|
[1] | 2051 | // FIXME --- change mkisofs string to MONDO_MKISOFS_REGULAR_SYSLINUX/LILO depending on bkpinfo->make_cd_usE_lilo
|
---|
| 2052 | // and add ' .' at end
|
---|
| 2053 | #ifdef __IA64__
|
---|
[128] | 2054 | log_msg(1, "IA64 --> elilo");
|
---|
| 2055 | res = eval_call_to_make_ISO(bkpinfo,
|
---|
| 2056 | //-b images/mindi-boot.2880.img
|
---|
[541] | 2057 | "mkisofs -no-emul-boot -b images/mindi-bootroot."
|
---|
| 2058 | IA64_BOOT_SIZE
|
---|
[906] | 2059 | ".img -c boot.cat -o '_ISO_' -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .",
|
---|
[128] | 2060 | destfile,
|
---|
| 2061 | g_current_media_number,
|
---|
| 2062 | MONDO_LOGFILE,
|
---|
| 2063 | message_to_screen);
|
---|
[1] | 2064 | #else
|
---|
| 2065 | // FIXME --- change mkisofs string to MONDO_MKISOFS_REGULAR_SYSLINUX/LILO depending on bkpinfo->make_cd_usE_lilo
|
---|
| 2066 | // and add ' .' at end
|
---|
[128] | 2067 | log_msg(1, "Non-ia64 --> lilo");
|
---|
| 2068 | res =
|
---|
| 2069 | eval_call_to_make_ISO(bkpinfo,
|
---|
[906] | 2070 | "mkisofs -b images/mindi-bootroot.2880.img -c boot.cat -o '_ISO_' -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .",
|
---|
[128] | 2071 | destfile, g_current_media_number,
|
---|
| 2072 | MONDO_LOGFILE,
|
---|
| 2073 | message_to_screen);
|
---|
[1] | 2074 | #endif
|
---|
[128] | 2075 | } else {
|
---|
| 2076 | log_msg(1, "make_cd_use_lilo = FALSE");
|
---|
| 2077 | log_msg(1, "Isolinux");
|
---|
| 2078 | res =
|
---|
| 2079 | eval_call_to_make_ISO(bkpinfo,
|
---|
[906] | 2080 | "mkisofs -no-emul-boot -b isolinux.bin -boot-load-size 4 -boot-info-table -c boot.cat -o '_ISO_' -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ .",
|
---|
[128] | 2081 | destfile, g_current_media_number,
|
---|
| 2082 | MONDO_LOGFILE,
|
---|
| 2083 | message_to_screen);
|
---|
| 2084 | }
|
---|
| 2085 | }
|
---|
| 2086 | if (res) {
|
---|
| 2087 | strcat(result_sz, "...failed");
|
---|
| 2088 | } else {
|
---|
| 2089 | strcat(result_sz, "...OK");
|
---|
| 2090 | }
|
---|
| 2091 | log_to_screen(result_sz);
|
---|
| 2092 | retval += res;
|
---|
[1] | 2093 | }
|
---|
[128] | 2094 |
|
---|
| 2095 | if (bkpinfo->backup_media_type == cdr
|
---|
| 2096 | || bkpinfo->backup_media_type == cdrw) {
|
---|
| 2097 | if (is_this_device_mounted(bkpinfo->media_device)) {
|
---|
| 2098 | log_msg(2,
|
---|
| 2099 | "Warning - %s mounted. I'm unmounting it before I burn to it.",
|
---|
| 2100 | bkpinfo->media_device);
|
---|
| 2101 | sprintf(tmp, "umount %s", bkpinfo->media_device);
|
---|
| 2102 | run_program_and_log_output(tmp, FALSE);
|
---|
| 2103 | }
|
---|
[1] | 2104 | }
|
---|
| 2105 |
|
---|
[128] | 2106 | if (bkpinfo->call_burn_iso[0] != '\0') {
|
---|
| 2107 | log_msg(2, "bkpinfo->call_burn_iso = %s", bkpinfo->call_burn_iso);
|
---|
| 2108 | sprintf(message_to_screen, "Burning %s #%d",
|
---|
| 2109 | media_descriptor_string(bkpinfo->backup_media_type),
|
---|
| 2110 | g_current_media_number);
|
---|
| 2111 | pause_and_ask_for_cdr(2, &cd_is_mountable);
|
---|
| 2112 | res =
|
---|
| 2113 | eval_call_to_make_ISO(bkpinfo, bkpinfo->call_burn_iso,
|
---|
| 2114 | destfile, g_current_media_number,
|
---|
| 2115 | MONDO_LOGFILE, message_to_screen);
|
---|
| 2116 | if (res) {
|
---|
| 2117 | strcat(message_to_screen, "...failed");
|
---|
| 2118 | } else {
|
---|
| 2119 | strcat(message_to_screen, "...OK");
|
---|
| 2120 | }
|
---|
| 2121 | log_to_screen(message_to_screen);
|
---|
| 2122 | retval += res;
|
---|
| 2123 | }
|
---|
[1] | 2124 |
|
---|
[128] | 2125 | if (bkpinfo->call_after_iso[0] != '\0') {
|
---|
| 2126 | sprintf(message_to_screen, "Running post-ISO call (%s #%d)",
|
---|
| 2127 | media_descriptor_string(bkpinfo->backup_media_type),
|
---|
| 2128 | g_current_media_number);
|
---|
| 2129 | res =
|
---|
| 2130 | eval_call_to_make_ISO(bkpinfo, bkpinfo->call_after_iso,
|
---|
| 2131 | destfile, g_current_media_number,
|
---|
| 2132 | MONDO_LOGFILE, message_to_screen);
|
---|
| 2133 | if (res) {
|
---|
| 2134 | strcat(message_to_screen, "...failed");
|
---|
| 2135 | } else {
|
---|
| 2136 | strcat(message_to_screen, "...OK");
|
---|
| 2137 | }
|
---|
| 2138 | log_to_screen(message_to_screen);
|
---|
| 2139 | retval += res;
|
---|
[1] | 2140 | }
|
---|
| 2141 |
|
---|
[128] | 2142 | chdir(old_pwd);
|
---|
| 2143 | if (retval) {
|
---|
| 2144 | log_msg(1, "WARNING - make_iso_fs returned an error");
|
---|
[1] | 2145 | }
|
---|
[128] | 2146 | paranoid_free(old_pwd);
|
---|
| 2147 | paranoid_free(result_sz);
|
---|
| 2148 | paranoid_free(message_to_screen);
|
---|
| 2149 | paranoid_free(sz_blank_disk);
|
---|
| 2150 | paranoid_free(fnam);
|
---|
| 2151 | paranoid_free(tmp);
|
---|
| 2152 | return (retval);
|
---|
[1] | 2153 | }
|
---|
| 2154 |
|
---|
| 2155 |
|
---|
| 2156 |
|
---|
| 2157 |
|
---|
| 2158 |
|
---|
| 2159 |
|
---|
| 2160 |
|
---|
| 2161 |
|
---|
| 2162 |
|
---|
| 2163 | bool is_dev_an_NTFS_dev(char *bigfile_fname)
|
---|
| 2164 | {
|
---|
[128] | 2165 | char *tmp;
|
---|
| 2166 | char *command;
|
---|
| 2167 | malloc_string(tmp);
|
---|
| 2168 | malloc_string(command);
|
---|
| 2169 | sprintf(command,
|
---|
| 2170 | "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1",
|
---|
| 2171 | bigfile_fname);
|
---|
| 2172 | log_msg(1, "command = '%s'", command);
|
---|
| 2173 | strcpy(tmp, call_program_and_get_last_line_of_output(command));
|
---|
| 2174 | log_msg(1, "--> tmp = '%s'", tmp);
|
---|
| 2175 | if (strstr(tmp, "NTFS")) {
|
---|
| 2176 | iamhere("TRUE");
|
---|
| 2177 | return (TRUE);
|
---|
| 2178 | } else {
|
---|
| 2179 | iamhere("FALSE");
|
---|
| 2180 | return (FALSE);
|
---|
| 2181 | }
|
---|
[1] | 2182 | }
|
---|
| 2183 |
|
---|
| 2184 |
|
---|
| 2185 | /**
|
---|
| 2186 | * Back up big files by chopping them up.
|
---|
| 2187 | * This function backs up all "big" files (where "big" depends
|
---|
| 2188 | * on your backup media) in "chunks" (whose size again depends
|
---|
| 2189 | * on your media).
|
---|
| 2190 | *
|
---|
| 2191 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 2192 | * - @c backup_media_type
|
---|
| 2193 | * - @c optimal_set_size
|
---|
| 2194 | * @param biggielist_fname The path to a file containing a list of
|
---|
| 2195 | * all "big" files.
|
---|
| 2196 | * @return The number of errors encountered (0 for success)
|
---|
| 2197 | * @see slice_up_file_etc
|
---|
| 2198 | */
|
---|
| 2199 | int
|
---|
[541] | 2200 | make_slices_and_images(struct s_bkpinfo *bkpinfo, char *biggielist_fname)
|
---|
[1] | 2201 | {
|
---|
| 2202 |
|
---|
[128] | 2203 | /*@ pointers ******************************************* */
|
---|
| 2204 | FILE *fin;
|
---|
| 2205 | char *p;
|
---|
[1] | 2206 |
|
---|
[128] | 2207 | /*@ buffers ******************************************** */
|
---|
| 2208 | char *tmp;
|
---|
| 2209 | char *bigfile_fname;
|
---|
| 2210 | char *sz_devfile;
|
---|
[296] | 2211 | char *ntfsprog_fifo = NULL;
|
---|
[128] | 2212 | /*@ long *********************************************** */
|
---|
| 2213 | long biggie_file_number = 0;
|
---|
| 2214 | long noof_biggie_files = 0;
|
---|
| 2215 | long estimated_total_noof_slices = 0;
|
---|
[1] | 2216 |
|
---|
[128] | 2217 | /*@ int ************************************************ */
|
---|
| 2218 | int retval = 0;
|
---|
| 2219 | int res = 0;
|
---|
| 2220 | pid_t pid;
|
---|
| 2221 | FILE *ftmp = NULL;
|
---|
| 2222 | bool delete_when_done;
|
---|
[296] | 2223 | bool use_ntfsprog;
|
---|
[684] | 2224 | off_t biggie_fsize;
|
---|
[1] | 2225 |
|
---|
[128] | 2226 | assert(bkpinfo != NULL);
|
---|
| 2227 | assert_string_is_neither_NULL_nor_zerolength(biggielist_fname);
|
---|
[1] | 2228 |
|
---|
[128] | 2229 | malloc_string(tmp);
|
---|
| 2230 | malloc_string(bigfile_fname);
|
---|
| 2231 | malloc_string(sz_devfile);
|
---|
| 2232 | estimated_total_noof_slices =
|
---|
| 2233 | size_of_all_biggiefiles_K(bkpinfo) / bkpinfo->optimal_set_size + 1;
|
---|
[1] | 2234 |
|
---|
[128] | 2235 | log_msg(1, "size of all biggiefiles = %ld",
|
---|
| 2236 | size_of_all_biggiefiles_K(bkpinfo));
|
---|
| 2237 | log_msg(1, "estimated_total_noof_slices = %ld KB / %ld KB = %ld",
|
---|
| 2238 | size_of_all_biggiefiles_K(bkpinfo), bkpinfo->optimal_set_size,
|
---|
| 2239 | estimated_total_noof_slices);
|
---|
[1] | 2240 |
|
---|
[128] | 2241 | if (length_of_file(biggielist_fname) < 6) {
|
---|
| 2242 | log_msg(1, "No biggiefiles; fair enough...");
|
---|
| 2243 | return (0);
|
---|
[1] | 2244 | }
|
---|
[128] | 2245 | sprintf(tmp, "I am now backing up all large files.");
|
---|
| 2246 | log_to_screen(tmp);
|
---|
| 2247 | noof_biggie_files = count_lines_in_file(biggielist_fname);
|
---|
| 2248 | open_progress_form("Backing up big files", tmp,
|
---|
| 2249 | "Please wait. This may take some time.", "",
|
---|
| 2250 | estimated_total_noof_slices);
|
---|
| 2251 | if (!(fin = fopen(biggielist_fname, "r"))) {
|
---|
| 2252 | log_OS_error("Unable to openin biggielist");
|
---|
| 2253 | return (1);
|
---|
[1] | 2254 | }
|
---|
[128] | 2255 | for (fgets(bigfile_fname, MAX_STR_LEN, fin); !feof(fin);
|
---|
| 2256 | fgets(bigfile_fname, MAX_STR_LEN, fin), biggie_file_number++) {
|
---|
[296] | 2257 | use_ntfsprog = FALSE;
|
---|
[128] | 2258 | if (bigfile_fname[strlen(bigfile_fname) - 1] < 32) {
|
---|
| 2259 | bigfile_fname[strlen(bigfile_fname) - 1] = '\0';
|
---|
| 2260 | }
|
---|
| 2261 | biggie_fsize = length_of_file(bigfile_fname);
|
---|
| 2262 | delete_when_done = FALSE;
|
---|
| 2263 |
|
---|
| 2264 | if (!does_file_exist(bigfile_fname)) {
|
---|
| 2265 | ftmp = fopen(bigfile_fname, "w");
|
---|
| 2266 | paranoid_fclose(ftmp);
|
---|
| 2267 | sprintf(tmp, "bigfile %s was deleted - creating a dummy",
|
---|
| 2268 | bigfile_fname);
|
---|
| 2269 | delete_when_done = TRUE;
|
---|
| 2270 | } else {
|
---|
[812] | 2271 | // Call ntfsclone (formerly partimagehack) if it's a /dev entry
|
---|
| 2272 | // (i.e. a partition to be imaged)
|
---|
[541] | 2273 | log_msg(2, "bigfile_fname = %s", bigfile_fname);
|
---|
[296] | 2274 | use_ntfsprog = FALSE;
|
---|
[128] | 2275 | if (!strncmp(bigfile_fname, "/dev/", 5)
|
---|
| 2276 | && is_dev_an_NTFS_dev(bigfile_fname)) {
|
---|
[296] | 2277 | use_ntfsprog = TRUE;
|
---|
[128] | 2278 | log_msg(2,
|
---|
[296] | 2279 | "Calling ntfsclone in background because %s is an NTFS partition",
|
---|
[128] | 2280 | bigfile_fname);
|
---|
[812] | 2281 | sprintf(sz_devfile, "%s/%d.%d.000",
|
---|
| 2282 | bkpinfo->tmpdir,
|
---|
[128] | 2283 | (int) (random() % 32768),
|
---|
| 2284 | (int) (random() % 32768));
|
---|
| 2285 | mkfifo(sz_devfile, 0x770);
|
---|
[296] | 2286 | ntfsprog_fifo = sz_devfile;
|
---|
[128] | 2287 | switch (pid = fork()) {
|
---|
| 2288 | case -1:
|
---|
| 2289 | fatal_error("Fork failure");
|
---|
| 2290 | case 0:
|
---|
| 2291 | log_msg(2,
|
---|
[296] | 2292 | "CHILD - fip - calling feed_into_ntfsprog(%s, %s)",
|
---|
[128] | 2293 | bigfile_fname, sz_devfile);
|
---|
[296] | 2294 | res = feed_into_ntfsprog(bigfile_fname, sz_devfile);
|
---|
[128] | 2295 | exit(res);
|
---|
| 2296 | break;
|
---|
| 2297 | default:
|
---|
| 2298 | log_msg(2,
|
---|
[296] | 2299 | "feed_into_ntfsprog() called in background --- pid=%ld",
|
---|
[128] | 2300 | (long int) (pid));
|
---|
| 2301 | }
|
---|
| 2302 | }
|
---|
[1] | 2303 | // Otherwise, use good old 'dd' and 'bzip2'
|
---|
[128] | 2304 | else {
|
---|
| 2305 | sz_devfile[0] = '\0';
|
---|
[296] | 2306 | ntfsprog_fifo = NULL;
|
---|
[128] | 2307 | }
|
---|
[1] | 2308 |
|
---|
| 2309 | // Whether partition or biggiefile, just do your thang :-)
|
---|
[128] | 2310 | sprintf(tmp, "Bigfile #%ld is '%s' (%ld KB)",
|
---|
| 2311 | biggie_file_number + 1, bigfile_fname,
|
---|
| 2312 | (long) biggie_fsize >> 10);
|
---|
| 2313 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 2314 | write_header_block_to_stream(biggie_fsize, bigfile_fname,
|
---|
[296] | 2315 | use_ntfsprog ?
|
---|
[128] | 2316 | BLK_START_A_PIHBIGGIE :
|
---|
| 2317 | BLK_START_A_NORMBIGGIE);
|
---|
| 2318 | }
|
---|
| 2319 | res =
|
---|
[541] | 2320 | slice_up_file_etc(bkpinfo, bigfile_fname,
|
---|
[296] | 2321 | ntfsprog_fifo, biggie_file_number,
|
---|
| 2322 | noof_biggie_files, use_ntfsprog);
|
---|
[128] | 2323 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
[684] | 2324 | write_header_block_to_stream((off_t)0,
|
---|
[128] | 2325 | calc_checksum_of_file
|
---|
| 2326 | (bigfile_fname),
|
---|
| 2327 | BLK_STOP_A_BIGGIE);
|
---|
| 2328 | }
|
---|
| 2329 | retval += res;
|
---|
| 2330 | p = strrchr(bigfile_fname, '/');
|
---|
| 2331 | if (p) {
|
---|
| 2332 | p++;
|
---|
| 2333 | } else {
|
---|
| 2334 | p = bigfile_fname;
|
---|
| 2335 | }
|
---|
| 2336 | sprintf(tmp, "Archiving %s ... ", bigfile_fname);
|
---|
| 2337 | if (res) {
|
---|
| 2338 | strcat(tmp, "Failed!");
|
---|
| 2339 | } else {
|
---|
| 2340 | strcat(tmp, "OK");
|
---|
| 2341 | }
|
---|
| 2342 | if (delete_when_done) {
|
---|
| 2343 | unlink(bigfile_fname);
|
---|
| 2344 | delete_when_done = FALSE;
|
---|
| 2345 | }
|
---|
| 2346 | }
|
---|
[1] | 2347 | #ifndef _XWIN
|
---|
[128] | 2348 | if (!g_text_mode) {
|
---|
| 2349 | newtDrawRootText(0, g_noof_rows - 2, tmp);
|
---|
| 2350 | newtRefresh();
|
---|
| 2351 | }
|
---|
[1] | 2352 | #endif
|
---|
[128] | 2353 | }
|
---|
| 2354 | log_msg(1, "Finished backing up bigfiles");
|
---|
| 2355 | log_msg(1, "estimated slices = %ld; actual slices = %ld",
|
---|
| 2356 | estimated_total_noof_slices, g_current_progress);
|
---|
| 2357 | close_progress_form();
|
---|
| 2358 | paranoid_fclose(fin);
|
---|
| 2359 | paranoid_free(tmp);
|
---|
| 2360 | paranoid_free(bigfile_fname);
|
---|
| 2361 | paranoid_free(sz_devfile);
|
---|
| 2362 | return (retval);
|
---|
[1] | 2363 | }
|
---|
| 2364 |
|
---|
| 2365 |
|
---|
| 2366 |
|
---|
| 2367 |
|
---|
| 2368 | /**
|
---|
| 2369 | * Single-threaded version of @c make_afioballs_and_images().
|
---|
| 2370 | * @see make_afioballs_and_images
|
---|
| 2371 | */
|
---|
[541] | 2372 | int make_afioballs_and_images_OLD(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 2373 | {
|
---|
| 2374 |
|
---|
[128] | 2375 | /*@ int ************************************************** */
|
---|
| 2376 | int retval = 0;
|
---|
| 2377 | long int curr_set_no = 0;
|
---|
| 2378 | int res = 0;
|
---|
[1] | 2379 |
|
---|
[128] | 2380 | /*@ buffers ********************************************** */
|
---|
| 2381 | char *curr_filelist_fname;
|
---|
| 2382 | char *curr_afioball_fname;
|
---|
| 2383 | char *curr_xattr_list_fname;
|
---|
| 2384 | char *curr_acl_list_fname;
|
---|
| 2385 | char *tmp;
|
---|
| 2386 | char *media_usage_comment;
|
---|
[1] | 2387 |
|
---|
[128] | 2388 | malloc_string(curr_afioball_fname);
|
---|
| 2389 | malloc_string(media_usage_comment);
|
---|
| 2390 | malloc_string(curr_filelist_fname);
|
---|
| 2391 | malloc_string(curr_xattr_list_fname);
|
---|
| 2392 | malloc_string(curr_acl_list_fname);
|
---|
[1] | 2393 |
|
---|
[128] | 2394 | tmp = malloc(MAX_STR_LEN * 2);
|
---|
[1] | 2395 |
|
---|
[128] | 2396 | sprintf(tmp, "%s/archives/filelist.full", bkpinfo->scratchdir);
|
---|
[1] | 2397 |
|
---|
[128] | 2398 | log_to_screen("Archiving regular files");
|
---|
[1] | 2399 |
|
---|
[541] | 2400 | open_progress_form("Backing up filesystem",
|
---|
| 2401 | "I am backing up your live filesystem now.",
|
---|
| 2402 | "Please wait. This may take a couple of hours.",
|
---|
| 2403 | "Working...",
|
---|
[128] | 2404 | get_last_filelist_number(bkpinfo) + 1);
|
---|
| 2405 |
|
---|
| 2406 | sprintf(curr_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir,
|
---|
| 2407 | 0L);
|
---|
| 2408 |
|
---|
| 2409 | for (curr_set_no = 0; does_file_exist(curr_filelist_fname);
|
---|
| 2410 | sprintf(curr_filelist_fname, FILELIST_FNAME_RAW_SZ,
|
---|
| 2411 | bkpinfo->tmpdir, ++curr_set_no)) {
|
---|
| 2412 | /* backup this set of files */
|
---|
| 2413 | sprintf(curr_filelist_fname, FILELIST_FNAME_RAW_SZ,
|
---|
| 2414 | bkpinfo->tmpdir, curr_set_no);
|
---|
| 2415 | sprintf(curr_afioball_fname, AFIOBALL_FNAME_RAW_SZ,
|
---|
| 2416 | bkpinfo->tmpdir, curr_set_no, bkpinfo->zip_suffix);
|
---|
| 2417 |
|
---|
| 2418 | log_msg(1, "EXAT'g set %ld", curr_set_no);
|
---|
[948] | 2419 | if (g_getfattr) {
|
---|
| 2420 | sprintf(curr_xattr_list_fname, XATTR_LIST_FNAME_RAW_SZ,
|
---|
[128] | 2421 | bkpinfo->tmpdir, curr_set_no);
|
---|
[948] | 2422 | get_fattr_list(curr_filelist_fname, curr_xattr_list_fname);
|
---|
| 2423 | }
|
---|
| 2424 | if (g_getfacl) {
|
---|
| 2425 | sprintf(curr_acl_list_fname, ACL_LIST_FNAME_RAW_SZ,
|
---|
[128] | 2426 | bkpinfo->tmpdir, curr_set_no);
|
---|
[948] | 2427 | get_acl_list(curr_filelist_fname, curr_acl_list_fname);
|
---|
| 2428 | }
|
---|
[128] | 2429 |
|
---|
| 2430 | log_msg(1, "Archiving set %ld", curr_set_no);
|
---|
| 2431 | res =
|
---|
| 2432 | archive_this_fileset(bkpinfo, curr_filelist_fname,
|
---|
| 2433 | curr_afioball_fname, curr_set_no);
|
---|
| 2434 | retval += res;
|
---|
| 2435 | if (res) {
|
---|
| 2436 | sprintf(tmp,
|
---|
| 2437 | "Errors occurred while archiving set %ld. Perhaps your live filesystem changed?",
|
---|
| 2438 | curr_set_no);
|
---|
| 2439 | log_to_screen(tmp);
|
---|
| 2440 | }
|
---|
| 2441 |
|
---|
| 2442 | strcpy(media_usage_comment, percent_media_full_comment(bkpinfo));
|
---|
| 2443 |
|
---|
| 2444 | /* copy to CD (scratchdir) ... and an actual CD-R if necessary */
|
---|
| 2445 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 2446 | register_in_tape_catalog(fileset, curr_set_no, -1,
|
---|
| 2447 | curr_afioball_fname);
|
---|
| 2448 | maintain_collection_of_recent_archives(bkpinfo->tmpdir,
|
---|
| 2449 | curr_afioball_fname);
|
---|
| 2450 | iamhere("Writing EXAT files");
|
---|
| 2451 | res +=
|
---|
| 2452 | write_EXAT_files_to_tape(bkpinfo, curr_xattr_list_fname,
|
---|
| 2453 | curr_acl_list_fname);
|
---|
[1] | 2454 | // archives themselves
|
---|
[128] | 2455 | res = move_files_to_stream(bkpinfo, curr_afioball_fname, NULL);
|
---|
| 2456 | } else {
|
---|
[948] | 2457 | if (g_getfacl) {
|
---|
| 2458 | if (g_getfattr) {
|
---|
| 2459 | res = move_files_to_cd(bkpinfo, curr_filelist_fname,
|
---|
| 2460 | curr_xattr_list_fname,
|
---|
| 2461 | curr_acl_list_fname,
|
---|
| 2462 | curr_afioball_fname, NULL);
|
---|
| 2463 | } else {
|
---|
| 2464 | res = move_files_to_cd(bkpinfo, curr_filelist_fname,
|
---|
| 2465 | curr_acl_list_fname,
|
---|
| 2466 | curr_afioball_fname, NULL);
|
---|
| 2467 | }
|
---|
| 2468 | } else {
|
---|
| 2469 | if (g_getfattr) {
|
---|
| 2470 | res = move_files_to_cd(bkpinfo, curr_filelist_fname,
|
---|
| 2471 | curr_xattr_list_fname,
|
---|
| 2472 | curr_afioball_fname, NULL);
|
---|
| 2473 | } else {
|
---|
| 2474 | res = move_files_to_cd(bkpinfo, curr_filelist_fname,
|
---|
| 2475 | curr_afioball_fname, NULL);
|
---|
| 2476 | }
|
---|
| 2477 | }
|
---|
[128] | 2478 | }
|
---|
| 2479 | retval += res;
|
---|
| 2480 | g_current_progress++;
|
---|
| 2481 | update_progress_form(media_usage_comment);
|
---|
[1] | 2482 |
|
---|
[128] | 2483 | if (res) {
|
---|
| 2484 | sprintf(tmp, "Failed to add archive %ld's files to CD dir\n",
|
---|
| 2485 | curr_set_no);
|
---|
| 2486 | log_to_screen(tmp);
|
---|
| 2487 | fatal_error
|
---|
| 2488 | ("Is your hard disk is full? If not, please send the author the logfile.");
|
---|
| 2489 | }
|
---|
[1] | 2490 | }
|
---|
[128] | 2491 | close_progress_form();
|
---|
| 2492 | sprintf(tmp, "Your regular files have been archived ");
|
---|
| 2493 | if (retval) {
|
---|
| 2494 | strcat(tmp, "(with errors).");
|
---|
| 2495 | } else {
|
---|
| 2496 | strcat(tmp, "successfully.");
|
---|
| 2497 | }
|
---|
| 2498 | log_to_screen(tmp);
|
---|
| 2499 | paranoid_free(tmp);
|
---|
| 2500 | paranoid_free(curr_filelist_fname);
|
---|
| 2501 | paranoid_free(curr_afioball_fname);
|
---|
| 2502 | paranoid_free(media_usage_comment);
|
---|
| 2503 | paranoid_free(curr_xattr_list_fname);
|
---|
| 2504 | paranoid_free(curr_acl_list_fname);
|
---|
| 2505 | return (retval);
|
---|
[1] | 2506 | }
|
---|
| 2507 |
|
---|
[128] | 2508 | /* @} - end of LLarchiveGroup */
|
---|
| 2509 |
|
---|
| 2510 |
|
---|
[1] | 2511 | /**
|
---|
| 2512 | * Wrapper around @c make_afioballs_and_images().
|
---|
| 2513 | * @param bkpinfo the backup information structure. Only the
|
---|
| 2514 | * @c backup_media_type field is used within this function.
|
---|
| 2515 | * @return return code of make_afioballs_and_images
|
---|
| 2516 | * @see make_afioballs_and_images
|
---|
| 2517 | * @ingroup MLarchiveGroup
|
---|
| 2518 | */
|
---|
[541] | 2519 | int make_those_afios_phase(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 2520 | {
|
---|
[128] | 2521 | /*@ int ******************************************* */
|
---|
| 2522 | int res = 0;
|
---|
| 2523 | int retval = 0;
|
---|
[1] | 2524 |
|
---|
[128] | 2525 | assert(bkpinfo != NULL);
|
---|
[1] | 2526 |
|
---|
[128] | 2527 | mvaddstr_and_log_it(g_currentY, 0,
|
---|
| 2528 | "Archiving regular files to media ");
|
---|
[1] | 2529 |
|
---|
[128] | 2530 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
[684] | 2531 | write_header_block_to_stream((off_t)0, "start-of-afioballs",
|
---|
[128] | 2532 | BLK_START_AFIOBALLS);
|
---|
[1] | 2533 | #if __FreeBSD__ == 5
|
---|
[128] | 2534 | log_msg(1,
|
---|
| 2535 | "Using single-threaded make_afioballs_and_images() to suit b0rken FreeBSD 5.0");
|
---|
[541] | 2536 | res = make_afioballs_and_images_OLD(bkpinfo);
|
---|
[1] | 2537 | #else
|
---|
[541] | 2538 | res = make_afioballs_and_images_OLD(bkpinfo);
|
---|
[1] | 2539 | #endif
|
---|
[684] | 2540 | write_header_block_to_stream((off_t)0, "stop-afioballs",
|
---|
[128] | 2541 | BLK_STOP_AFIOBALLS);
|
---|
| 2542 | } else {
|
---|
[541] | 2543 | res = make_afioballs_and_images(bkpinfo);
|
---|
[128] | 2544 | }
|
---|
[1] | 2545 |
|
---|
[128] | 2546 | retval += res;
|
---|
| 2547 | if (res) {
|
---|
| 2548 | mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
|
---|
| 2549 | log_msg(1, "make_afioballs_and_images returned an error");
|
---|
| 2550 | } else {
|
---|
| 2551 | mvaddstr_and_log_it(g_currentY++, 74, "Done.");
|
---|
| 2552 | }
|
---|
| 2553 | return (retval);
|
---|
[1] | 2554 | }
|
---|
| 2555 |
|
---|
| 2556 | /**
|
---|
| 2557 | * Wrapper around @c make_slices_and_images().
|
---|
| 2558 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 2559 | * - @c backup_media_type
|
---|
| 2560 | * - @c scratchdir
|
---|
| 2561 | * - @c tmpdir
|
---|
| 2562 | * @return The number of errors encountered (0 for success)
|
---|
| 2563 | * @ingroup MLarchiveGroup
|
---|
| 2564 | */
|
---|
[128] | 2565 | int make_those_slices_phase(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 2566 | {
|
---|
| 2567 |
|
---|
[128] | 2568 | /*@ int ***************************************************** */
|
---|
| 2569 | int res = 0;
|
---|
| 2570 | int retval = 0;
|
---|
[1] | 2571 |
|
---|
[128] | 2572 | /*@ buffers ************************************************** */
|
---|
| 2573 | char *biggielist;
|
---|
| 2574 | char *command;
|
---|
| 2575 | char *blah;
|
---|
| 2576 | char *xattr_fname;
|
---|
| 2577 | char *acl_fname;
|
---|
[1] | 2578 |
|
---|
[128] | 2579 | assert(bkpinfo != NULL);
|
---|
| 2580 | /* slice big files */
|
---|
| 2581 | malloc_string(blah);
|
---|
| 2582 | malloc_string(biggielist);
|
---|
| 2583 | malloc_string(xattr_fname);
|
---|
| 2584 | malloc_string(acl_fname);
|
---|
| 2585 | command = malloc(1200);
|
---|
| 2586 | mvaddstr_and_log_it(g_currentY, 0,
|
---|
| 2587 | "Archiving large files to media ");
|
---|
| 2588 | sprintf(biggielist, "%s/archives/biggielist.txt", bkpinfo->scratchdir);
|
---|
[948] | 2589 | if (g_getfattr) {
|
---|
| 2590 | sprintf(xattr_fname, XATTR_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
|
---|
| 2591 | }
|
---|
| 2592 | if (g_getfacl) {
|
---|
| 2593 | sprintf(acl_fname, ACL_BIGGLST_FNAME_RAW_SZ, bkpinfo->tmpdir);
|
---|
| 2594 | }
|
---|
[1] | 2595 |
|
---|
[128] | 2596 | sprintf(command, "cp %s/biggielist.txt %s", bkpinfo->tmpdir,
|
---|
| 2597 | biggielist);
|
---|
| 2598 | paranoid_system(command);
|
---|
| 2599 | sprintf(blah, "biggielist = %s", biggielist);
|
---|
| 2600 | log_msg(2, blah);
|
---|
| 2601 |
|
---|
| 2602 | if (!does_file_exist(biggielist)) {
|
---|
| 2603 | log_msg(1, "BTW, the biggielist does not exist");
|
---|
| 2604 | }
|
---|
| 2605 |
|
---|
[948] | 2606 | if (g_getfattr) {
|
---|
| 2607 | get_fattr_list(biggielist, xattr_fname);
|
---|
| 2608 | sprintf(command, "cp %s %s/archives/", xattr_fname,
|
---|
[128] | 2609 | bkpinfo->scratchdir);
|
---|
[948] | 2610 | paranoid_system(command);
|
---|
| 2611 | }
|
---|
| 2612 | if (g_getfacl) {
|
---|
| 2613 | get_acl_list(biggielist, acl_fname);
|
---|
| 2614 | sprintf(command, "cp %s %s/archives/", acl_fname, bkpinfo->scratchdir);
|
---|
| 2615 | paranoid_system(command);
|
---|
| 2616 | }
|
---|
[128] | 2617 |
|
---|
| 2618 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 2619 | res += write_EXAT_files_to_tape(bkpinfo, xattr_fname, acl_fname);
|
---|
| 2620 | sprintf(blah, "%ld", count_lines_in_file(biggielist));
|
---|
[684] | 2621 | write_header_block_to_stream((off_t)0, blah, BLK_START_BIGGIEFILES);
|
---|
[128] | 2622 | }
|
---|
| 2623 | res = make_slices_and_images(bkpinfo, biggielist);
|
---|
| 2624 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
[684] | 2625 | write_header_block_to_stream((off_t)0, "end-of-biggiefiles",
|
---|
[128] | 2626 | BLK_STOP_BIGGIEFILES);
|
---|
| 2627 | }
|
---|
| 2628 | retval += res;
|
---|
| 2629 | if (res) {
|
---|
| 2630 | log_msg(1, "make_slices_and_images returned an error");
|
---|
| 2631 | mvaddstr_and_log_it(g_currentY++, 74, "Errors.");
|
---|
| 2632 | } else {
|
---|
| 2633 | mvaddstr_and_log_it(g_currentY++, 74, "Done.");
|
---|
| 2634 | }
|
---|
| 2635 | paranoid_free(blah);
|
---|
| 2636 | paranoid_free(biggielist);
|
---|
| 2637 | paranoid_free(command);
|
---|
| 2638 | paranoid_free(xattr_fname);
|
---|
| 2639 | paranoid_free(acl_fname);
|
---|
| 2640 | return (retval);
|
---|
[1] | 2641 | }
|
---|
| 2642 |
|
---|
| 2643 |
|
---|
| 2644 |
|
---|
| 2645 | /**
|
---|
| 2646 | * @addtogroup LLarchiveGroup
|
---|
| 2647 | * @{
|
---|
| 2648 | */
|
---|
| 2649 | /**
|
---|
| 2650 | * Function pointer to an appropriate @c move_files_to_cd routine.
|
---|
| 2651 | * You can set this to your own function (for example, one to
|
---|
| 2652 | * transfer files over the network) or leave it as is.
|
---|
| 2653 | */
|
---|
[541] | 2654 | int (*move_files_to_cd) (struct s_bkpinfo *, char *, ...) =
|
---|
[128] | 2655 | _move_files_to_cd;
|
---|
[1] | 2656 |
|
---|
| 2657 | /**
|
---|
| 2658 | * Move some files to the ISO scratch directory.
|
---|
| 2659 | * This function moves files specified as parameters, into the directory
|
---|
| 2660 | * @c bkpinfo->scratchdir, where the files that will be stored on the next
|
---|
| 2661 | * CD are waiting.
|
---|
| 2662 | *
|
---|
| 2663 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 2664 | * - @c media_size
|
---|
| 2665 | * - @c scratchdir
|
---|
| 2666 | * @param files_to_add The files to add to the scratchdir.
|
---|
| 2667 | * @warning The list of @c files_to_add must be terminated with @c NULL.
|
---|
| 2668 | * @note If and when the space occupied by the scratchdir would exceed
|
---|
| 2669 | * the capacity of the current CD,
|
---|
| 2670 | * <tt>write_iso_and_go_on(bkpinfo, FALSE)</tt> is called and the
|
---|
| 2671 | * scratchdir is emptied.
|
---|
| 2672 | *
|
---|
| 2673 | * @return The number of errors encountered (0 for success)
|
---|
| 2674 | */
|
---|
[541] | 2675 | int _move_files_to_cd(struct s_bkpinfo *bkpinfo, char *files_to_add, ...)
|
---|
[1] | 2676 | {
|
---|
| 2677 |
|
---|
[128] | 2678 | /*@ int ************************************************************ */
|
---|
| 2679 | int retval = 0;
|
---|
[1] | 2680 | int res = 0;
|
---|
| 2681 |
|
---|
[128] | 2682 | /*@ buffers ******************************************************** */
|
---|
| 2683 | char *tmp, *curr_file, *cf;
|
---|
[1] | 2684 |
|
---|
[128] | 2685 | /*@ long ************************************************************ */
|
---|
| 2686 | va_list ap;
|
---|
| 2687 | long long would_occupy;
|
---|
[1] | 2688 |
|
---|
[128] | 2689 | assert(bkpinfo != NULL);
|
---|
| 2690 | malloc_string(curr_file);
|
---|
| 2691 | tmp = malloc(1200);
|
---|
| 2692 | would_occupy = space_occupied_by_cd(bkpinfo->scratchdir);
|
---|
| 2693 | va_start(ap, files_to_add); // initialize the variable arguments
|
---|
| 2694 | for (cf = files_to_add; cf != NULL; cf = va_arg(ap, char *)) {
|
---|
| 2695 | if (!cf) {
|
---|
| 2696 | continue;
|
---|
| 2697 | }
|
---|
| 2698 | strcpy(curr_file, cf);
|
---|
| 2699 | if (!does_file_exist(curr_file)) {
|
---|
| 2700 | log_msg(1,
|
---|
| 2701 | "Warning - you're trying to add a non-existent file - '%s' to the CD",
|
---|
| 2702 | curr_file);
|
---|
| 2703 | } else {
|
---|
| 2704 | log_msg(8, "Trying to add file %s to CD", curr_file);
|
---|
| 2705 | would_occupy += length_of_file(curr_file) / 1024;
|
---|
| 2706 | }
|
---|
[1] | 2707 | }
|
---|
[128] | 2708 | va_end(ap);
|
---|
[1] | 2709 |
|
---|
[128] | 2710 | if (bkpinfo->media_size[g_current_media_number] <= 0) {
|
---|
| 2711 | fatal_error("move_files_to_cd() - unknown media size");
|
---|
[1] | 2712 | }
|
---|
[128] | 2713 | if (would_occupy / 1024 > bkpinfo->media_size[g_current_media_number]) {
|
---|
[541] | 2714 | res = write_iso_and_go_on(bkpinfo, FALSE); /* FALSE because this is not the last CD we'll write */
|
---|
[128] | 2715 | retval += res;
|
---|
| 2716 | if (res) {
|
---|
| 2717 | log_msg(1, "WARNING - write_iso_and_go_on returned an error");
|
---|
| 2718 | }
|
---|
| 2719 | }
|
---|
[1] | 2720 |
|
---|
[128] | 2721 | va_start(ap, files_to_add); // initialize the variable arguments
|
---|
| 2722 | for (cf = files_to_add; cf != NULL; cf = va_arg(ap, char *)) {
|
---|
| 2723 | if (!cf) {
|
---|
| 2724 | continue;
|
---|
| 2725 | }
|
---|
| 2726 | strcpy(curr_file, cf);
|
---|
[1] | 2727 |
|
---|
[128] | 2728 | sprintf(tmp, "mv -f %s %s/archives/", curr_file,
|
---|
| 2729 | bkpinfo->scratchdir);
|
---|
| 2730 | res = run_program_and_log_output(tmp, 5);
|
---|
| 2731 | retval += res;
|
---|
| 2732 | if (res) {
|
---|
| 2733 | log_msg(1, "(move_files_to_cd) '%s' failed", tmp);
|
---|
| 2734 | } else {
|
---|
| 2735 | log_msg(8, "Moved %s to CD OK", tmp);
|
---|
| 2736 | }
|
---|
| 2737 | // unlink (curr_file);
|
---|
[1] | 2738 | }
|
---|
[128] | 2739 | va_end(ap);
|
---|
| 2740 |
|
---|
| 2741 | if (retval) {
|
---|
| 2742 | log_msg(1,
|
---|
| 2743 | "Warning - errors occurred while I was adding files to CD dir");
|
---|
[1] | 2744 | }
|
---|
[128] | 2745 | paranoid_free(tmp);
|
---|
| 2746 | paranoid_free(curr_file);
|
---|
| 2747 | return (retval);
|
---|
[1] | 2748 | }
|
---|
| 2749 |
|
---|
| 2750 | /* @} - end of LLarchiveGroup */
|
---|
| 2751 |
|
---|
| 2752 |
|
---|
| 2753 |
|
---|
| 2754 |
|
---|
| 2755 |
|
---|
| 2756 |
|
---|
| 2757 |
|
---|
| 2758 |
|
---|
| 2759 | /**
|
---|
| 2760 | * Offer to write boot and data disk images to 3.5" floppy disks.
|
---|
| 2761 | * @param bkpinfo The backup information structure. Only the
|
---|
| 2762 | * @c backup_media_type field is used in this function.
|
---|
| 2763 | * @param imagesdir The directory containing the floppy images (usually
|
---|
[541] | 2764 | * /root/images/mindi).
|
---|
[1] | 2765 | *
|
---|
| 2766 | * @return The number of errors encountered (0 for success)
|
---|
| 2767 | * @see write_image_to_floppy
|
---|
| 2768 | * @see format_disk
|
---|
| 2769 | * @ingroup MLarchiveGroup
|
---|
| 2770 | */
|
---|
[128] | 2771 | int offer_to_write_floppies(struct s_bkpinfo *bkpinfo, char *imagesdir)
|
---|
[1] | 2772 | {
|
---|
[128] | 2773 | /*@ buffer ************************************************************ */
|
---|
| 2774 | char *tmp;
|
---|
[1] | 2775 | char *comment;
|
---|
| 2776 | char *bootdisk_dev;
|
---|
| 2777 | char *datadisk_dev;
|
---|
| 2778 | char *bootdisk_file;
|
---|
| 2779 | char *rootdisk_file;
|
---|
| 2780 |
|
---|
[128] | 2781 | /*@ int *************************************************************** */
|
---|
| 2782 | int i = 0;
|
---|
[1] | 2783 | int res = 0;
|
---|
| 2784 |
|
---|
[128] | 2785 | /*@ bool ************************************************************** */
|
---|
| 2786 | bool format_first;
|
---|
| 2787 | bool root_disk_exists = FALSE;
|
---|
[1] | 2788 |
|
---|
[128] | 2789 | malloc_string(tmp);
|
---|
| 2790 | malloc_string(comment);
|
---|
| 2791 | malloc_string(bootdisk_dev);
|
---|
| 2792 | malloc_string(datadisk_dev);
|
---|
| 2793 | malloc_string(rootdisk_file);
|
---|
| 2794 | malloc_string(bootdisk_file);
|
---|
| 2795 | assert(bkpinfo != NULL);
|
---|
| 2796 | assert_string_is_neither_NULL_nor_zerolength(imagesdir);
|
---|
[1] | 2797 |
|
---|
| 2798 |
|
---|
[128] | 2799 | if (!ask_me_yes_or_no
|
---|
| 2800 | ("Write boot and data disk images to 3.5\" floppy disks?")) {
|
---|
| 2801 | return (0);
|
---|
| 2802 | }
|
---|
| 2803 | if (does_device_exist(DEFAULT_1722MB_DISK)) {
|
---|
[1] | 2804 | #ifdef __FreeBSD__
|
---|
[128] | 2805 | // tell the system that this is a 1.72m floppy
|
---|
| 2806 | system("/usr/sbin/fdcontrol -F 1722 /dev/fd0.1722");
|
---|
[1] | 2807 | #endif
|
---|
[128] | 2808 | strcpy(bootdisk_dev, DEFAULT_1722MB_DISK);
|
---|
| 2809 | } else if (does_device_exist(BACKUP_1722MB_DISK)) {
|
---|
| 2810 | sprintf(bootdisk_dev, "/dev/fd0H1722");
|
---|
| 2811 | } else {
|
---|
| 2812 | log_msg(1, "Warning - can't find a 1.72MB floppy device *sigh*");
|
---|
| 2813 | strcpy(bootdisk_dev, DEFAULT_1722MB_DISK);
|
---|
[1] | 2814 | // return (1);
|
---|
[128] | 2815 | }
|
---|
| 2816 | strcpy(datadisk_dev, "/dev/fd0");
|
---|
| 2817 | if (!does_device_exist(datadisk_dev)) {
|
---|
| 2818 | log_msg(1, "Warning - can't find a 1.44MB floppy device *sigh*");
|
---|
| 2819 | strcpy(datadisk_dev, "/dev/fd0");
|
---|
[1] | 2820 | // return (1);
|
---|
[128] | 2821 | }
|
---|
| 2822 | format_first =
|
---|
| 2823 | ask_me_yes_or_no
|
---|
| 2824 | ("Do you want me to format the disks before I write to them?");
|
---|
[1] | 2825 |
|
---|
| 2826 | /* boot disk */
|
---|
[128] | 2827 | if (ask_me_OK_or_cancel("About to write boot disk")) {
|
---|
| 2828 | log_to_screen("Writing boot floppy");
|
---|
[1] | 2829 | #ifdef __FreeBSD__
|
---|
[128] | 2830 | sprintf(tmp, "%s/mindi-kern.1722.img", imagesdir);
|
---|
| 2831 | if (format_first) {
|
---|
| 2832 | format_disk(bootdisk_dev);
|
---|
| 2833 | }
|
---|
| 2834 | res += write_image_to_floppy(bootdisk_dev, tmp);
|
---|
| 2835 | if (ask_me_OK_or_cancel("About to write 1.44MB mfsroot disk")) {
|
---|
| 2836 | log_to_screen("Writing mfsroot floppy");
|
---|
| 2837 | if (format_first) {
|
---|
| 2838 | format_disk(datadisk_dev);
|
---|
| 2839 | }
|
---|
| 2840 | sprintf(tmp, "%s/mindi-mfsroot.1440.img", imagesdir);
|
---|
| 2841 | write_image_to_floppy(datadisk_dev, tmp);
|
---|
| 2842 | }
|
---|
[1] | 2843 | #else
|
---|
[128] | 2844 | sprintf(bootdisk_file, "%s/mindi-bootroot.1722.img", imagesdir);
|
---|
| 2845 | if (does_file_exist(bootdisk_file)) {
|
---|
| 2846 | if (format_first) {
|
---|
| 2847 | format_disk(bootdisk_dev);
|
---|
| 2848 | }
|
---|
| 2849 | res += write_image_to_floppy(bootdisk_dev, bootdisk_file);
|
---|
| 2850 | } else {
|
---|
| 2851 | sprintf(bootdisk_file, "%s/mindi-boot.1440.img", imagesdir);
|
---|
| 2852 | sprintf(rootdisk_file, "%s/mindi-root.1440.img", imagesdir);
|
---|
| 2853 | root_disk_exists = TRUE;
|
---|
| 2854 | if (!does_file_exist(rootdisk_file)
|
---|
| 2855 | || !does_file_exist(bootdisk_file)) {
|
---|
| 2856 | popup_and_OK
|
---|
| 2857 | ("Cannot write boot/root floppies. Files not found.");
|
---|
| 2858 | log_to_screen
|
---|
| 2859 | ("Failed to find boot/root floppy images. Oh dear.");
|
---|
| 2860 | return (1);
|
---|
| 2861 | }
|
---|
| 2862 | if (format_first) {
|
---|
| 2863 | format_disk(datadisk_dev);
|
---|
| 2864 | }
|
---|
| 2865 | /*
|
---|
| 2866 | sprintf(tmp, "cat %s > %s", bootdisk_file, datadisk_dev);
|
---|
| 2867 | res += run_external_binary_with_percentage_indicator_NEW("Writing boot floppy", tmp);
|
---|
| 2868 | */
|
---|
| 2869 | res += write_image_to_floppy(datadisk_dev, bootdisk_file);
|
---|
| 2870 | if (ask_me_OK_or_cancel("About to write root disk")) {
|
---|
| 2871 | log_to_screen("Writing root floppy");
|
---|
| 2872 | if (format_first) {
|
---|
| 2873 | format_disk(datadisk_dev);
|
---|
| 2874 | }
|
---|
| 2875 | sprintf(tmp, "cat %s > %s", rootdisk_file, datadisk_dev);
|
---|
| 2876 | log_msg(1, "tmp = '%s'", tmp);
|
---|
| 2877 | res +=
|
---|
| 2878 | run_external_binary_with_percentage_indicator_NEW
|
---|
| 2879 | ("Writing root floppy", tmp);
|
---|
[1] | 2880 | // res += write_image_to_floppy (datadisk_dev, rootdisk_file);
|
---|
[128] | 2881 | }
|
---|
| 2882 | }
|
---|
[1] | 2883 | #endif
|
---|
| 2884 | }
|
---|
[128] | 2885 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 2886 | log_to_screen
|
---|
| 2887 | ("FYI, the data disks are stored on tape/CD for your convenience.");
|
---|
| 2888 | return (0);
|
---|
[1] | 2889 | }
|
---|
[128] | 2890 | for (i = 1; i < 99; i++) {
|
---|
| 2891 | sprintf(tmp, "%s/mindi-data-%d.img", imagesdir, i);
|
---|
| 2892 | log_msg(3, tmp);
|
---|
| 2893 | if (!does_file_exist(tmp)) {
|
---|
| 2894 | log_msg(3, "...not found");
|
---|
| 2895 | break;
|
---|
| 2896 | }
|
---|
| 2897 | sprintf(comment, "About to write data disk #%d", i);
|
---|
| 2898 | if (ask_me_OK_or_cancel(comment)) {
|
---|
| 2899 | sprintf(comment, "Writing data disk #%3d", i);
|
---|
| 2900 | log_to_screen(comment);
|
---|
| 2901 | if (format_first) {
|
---|
| 2902 | res += format_disk(datadisk_dev);
|
---|
| 2903 | }
|
---|
| 2904 | res += write_image_to_floppy(datadisk_dev, tmp);
|
---|
| 2905 | }
|
---|
| 2906 | }
|
---|
| 2907 | paranoid_free(tmp);
|
---|
| 2908 | paranoid_free(comment);
|
---|
| 2909 | paranoid_free(bootdisk_dev);
|
---|
| 2910 | paranoid_free(datadisk_dev);
|
---|
| 2911 | return (res);
|
---|
[1] | 2912 | }
|
---|
| 2913 |
|
---|
| 2914 |
|
---|
| 2915 |
|
---|
| 2916 |
|
---|
| 2917 |
|
---|
| 2918 |
|
---|
| 2919 |
|
---|
| 2920 |
|
---|
| 2921 | /**
|
---|
| 2922 | * Wrapper around @c offer_to_write_floppies().
|
---|
| 2923 | * @param bkpinfo The backup information structure. Used only
|
---|
| 2924 | * in the call to @c offer_to_write_floppies().
|
---|
| 2925 | * @return 0 if the boot floppies were found (not necessarily written OK),
|
---|
| 2926 | * 1 otherwise.
|
---|
| 2927 | * @see offer_to_write_floppies
|
---|
| 2928 | * @ingroup MLarchiveGroup
|
---|
| 2929 | */
|
---|
| 2930 |
|
---|
[128] | 2931 | int offer_to_write_boot_floppies_to_physical_disks(struct s_bkpinfo
|
---|
| 2932 | *bkpinfo)
|
---|
[1] | 2933 | {
|
---|
[128] | 2934 | int res = 0;
|
---|
[1] | 2935 |
|
---|
[128] | 2936 | assert(bkpinfo != NULL);
|
---|
[1] | 2937 |
|
---|
[128] | 2938 | mvaddstr_and_log_it(g_currentY, 0,
|
---|
| 2939 | "Writing boot+data floppy images to disk");
|
---|
[1] | 2940 |
|
---|
[128] | 2941 | if (!bkpinfo->nonbootable_backup) {
|
---|
[1] | 2942 | #ifdef __FreeBSD__
|
---|
[541] | 2943 | if (!does_file_exist("/root/images/mindi/mindi-kern.1722.img"))
|
---|
[1] | 2944 | #else
|
---|
[541] | 2945 | if (!does_file_exist("/root/images/mindi/mindi-bootroot.1722.img")
|
---|
| 2946 | && !does_file_exist("/root/images/mindi/mindi-boot.1440.img"))
|
---|
[1] | 2947 | #endif
|
---|
[128] | 2948 | {
|
---|
| 2949 | mvaddstr_and_log_it(g_currentY++, 74, "No Imgs");
|
---|
[541] | 2950 | if (does_file_exist("/root/images/mindi/mondorescue.iso")) {
|
---|
[128] | 2951 | popup_and_OK
|
---|
[541] | 2952 | ("Boot+data floppy creation failed. However, FYI, you may burn /root/images/mindi/mondorescue.iso to a CD and boot from that instead if you wish.");
|
---|
[128] | 2953 | res++;
|
---|
| 2954 | }
|
---|
| 2955 | } else {
|
---|
[541] | 2956 | offer_to_write_floppies(bkpinfo, "/root/images/mindi");
|
---|
[128] | 2957 | mvaddstr_and_log_it(g_currentY++, 74, "Done.");
|
---|
| 2958 | }
|
---|
| 2959 | } else {
|
---|
| 2960 | popup_and_OK
|
---|
| 2961 | ("Since you opted for a nonbootable backup, no boot floppies were created.");
|
---|
| 2962 | }
|
---|
| 2963 |
|
---|
| 2964 | return (res);
|
---|
[1] | 2965 | }
|
---|
| 2966 |
|
---|
| 2967 |
|
---|
| 2968 |
|
---|
| 2969 |
|
---|
| 2970 | /**
|
---|
| 2971 | * @addtogroup LLarchiveGroup
|
---|
| 2972 | * @{
|
---|
| 2973 | */
|
---|
| 2974 | /**
|
---|
| 2975 | * Function pointer to an appropriate @c move_files_to_stream routine.
|
---|
| 2976 | * You can set this to your own function (for example, one to
|
---|
| 2977 | * transfer files over the network) or leave it as is.
|
---|
| 2978 | */
|
---|
[128] | 2979 | int (*move_files_to_stream) (struct s_bkpinfo *, char *, ...) =
|
---|
| 2980 | _move_files_to_stream;
|
---|
[1] | 2981 |
|
---|
| 2982 | /**
|
---|
| 2983 | * Copy some files to tape.
|
---|
| 2984 | * This function copies the files specified as parameters into the tape stream.
|
---|
| 2985 | *
|
---|
| 2986 | * @param bkpinfo The backup information structure. Used only in the call to
|
---|
| 2987 | * @c write_file_to_stream_from_file().
|
---|
| 2988 | *
|
---|
| 2989 | * @param files_to_add The files to copy to the tape stream.
|
---|
| 2990 | * @warning The list of @c files_to_add must be terminated with @c NULL.
|
---|
| 2991 | * @note Files may be split across multiple tapes if necessary.
|
---|
| 2992 | *
|
---|
| 2993 | * @return The number of errors encountered (0 for success)
|
---|
| 2994 | */
|
---|
| 2995 | int
|
---|
[128] | 2996 | _move_files_to_stream(struct s_bkpinfo *bkpinfo, char *files_to_add, ...)
|
---|
[1] | 2997 | {
|
---|
| 2998 |
|
---|
[128] | 2999 | /*@ int ************************************************************ */
|
---|
| 3000 | int retval = 0;
|
---|
[1] | 3001 | int res = 0;
|
---|
[128] | 3002 | /*@ buffers ******************************************************** */
|
---|
[1] | 3003 |
|
---|
[128] | 3004 | /*@ char *********************************************************** */
|
---|
[1] | 3005 | char start_chr;
|
---|
| 3006 | char stop_chr;
|
---|
[128] | 3007 | char *curr_file, *cf;
|
---|
| 3008 | /*@ long long ****************************************************** */
|
---|
[684] | 3009 | off_t length_of_incoming_file = (off_t)0;
|
---|
[128] | 3010 | t_archtype type;
|
---|
| 3011 | va_list ap;
|
---|
[1] | 3012 |
|
---|
[128] | 3013 | assert(bkpinfo != NULL);
|
---|
| 3014 | malloc_string(curr_file);
|
---|
| 3015 | va_start(ap, files_to_add);
|
---|
| 3016 | for (cf = files_to_add; cf != NULL; cf = va_arg(ap, char *)) {
|
---|
| 3017 | if (!cf) {
|
---|
| 3018 | continue;
|
---|
| 3019 | }
|
---|
| 3020 | strcpy(curr_file, cf);
|
---|
| 3021 | if (!does_file_exist(curr_file)) {
|
---|
| 3022 | log_msg(1,
|
---|
| 3023 | "Warning - you're trying to add a non-existent file - '%s' to the tape",
|
---|
| 3024 | curr_file);
|
---|
| 3025 | }
|
---|
[1] | 3026 | /* create header chars */
|
---|
[128] | 3027 | start_chr = BLK_START_AN_AFIO_OR_SLICE;
|
---|
| 3028 | stop_chr = BLK_STOP_AN_AFIO_OR_SLICE;
|
---|
[1] | 3029 | /* ask for new tape if necessary */
|
---|
[128] | 3030 | length_of_incoming_file = length_of_file(curr_file);
|
---|
| 3031 | write_header_block_to_stream(length_of_incoming_file, curr_file,
|
---|
| 3032 | start_chr);
|
---|
| 3033 | if (strstr(curr_file, ".afio.") || strstr(curr_file, ".star.")) {
|
---|
| 3034 | type = fileset;
|
---|
| 3035 | } else if (strstr(curr_file, "slice")) {
|
---|
| 3036 | type = biggieslice;
|
---|
| 3037 | } else {
|
---|
| 3038 | type = other;
|
---|
| 3039 | }
|
---|
| 3040 | res = write_file_to_stream_from_file(bkpinfo, curr_file);
|
---|
| 3041 | retval += res;
|
---|
| 3042 | unlink(curr_file);
|
---|
[1] | 3043 | /* write closing header */
|
---|
[684] | 3044 | write_header_block_to_stream((off_t)0, "finished-writing-file", stop_chr);
|
---|
[128] | 3045 | }
|
---|
| 3046 | va_end(ap);
|
---|
[1] | 3047 |
|
---|
[128] | 3048 | if (retval) {
|
---|
| 3049 | log_msg(1,
|
---|
| 3050 | "Warning - errors occurred while I was adding file to tape");
|
---|
| 3051 | }
|
---|
| 3052 | paranoid_free(curr_file);
|
---|
| 3053 | return (retval);
|
---|
[1] | 3054 | }
|
---|
| 3055 |
|
---|
| 3056 | /* @} - end of LLarchiveGroup */
|
---|
| 3057 |
|
---|
| 3058 |
|
---|
| 3059 |
|
---|
| 3060 | /**
|
---|
| 3061 | * @addtogroup utilityGroup
|
---|
| 3062 | * @{
|
---|
| 3063 | */
|
---|
| 3064 | /**
|
---|
| 3065 | * Make sure the user has a valid CD-R(W) in the CD drive.
|
---|
| 3066 | * @param cdrw_dev Set to the CD-R(W) device checked.
|
---|
| 3067 | * @param keep_looping If TRUE, keep pestering user until they insist
|
---|
| 3068 | * or insert a correct CD; if FALSE, only check once.
|
---|
| 3069 | * @return 0 (there was an OK CD in the drive) or 1 (there wasn't).
|
---|
| 3070 | */
|
---|
[128] | 3071 | int interrogate_disk_currently_in_cdrw_drive(char *cdrw_dev,
|
---|
| 3072 | bool keep_looping)
|
---|
[1] | 3073 | {
|
---|
[128] | 3074 | char *tmp;
|
---|
| 3075 | int res = 0;
|
---|
| 3076 | char *bkp;
|
---|
| 3077 | char *cdrecord;
|
---|
[1] | 3078 |
|
---|
[128] | 3079 | malloc_string(tmp);
|
---|
| 3080 | malloc_string(bkp);
|
---|
| 3081 | malloc_string(cdrecord);
|
---|
| 3082 | strcpy(bkp, cdrw_dev);
|
---|
| 3083 | if (find_cdrw_device(cdrw_dev)) {
|
---|
| 3084 | strcpy(cdrw_dev, bkp);
|
---|
| 3085 | } else {
|
---|
| 3086 | if (!system("which cdrecord > /dev/null 2> /dev/null")) {
|
---|
| 3087 | sprintf(cdrecord, "cdrecord dev=%s -atip", cdrw_dev);
|
---|
| 3088 | } else if (!system("which dvdrecord > /dev/null 2> /dev/null")) {
|
---|
| 3089 | sprintf(cdrecord, "cdrecord dev=%s -atip", cdrw_dev);
|
---|
| 3090 | } else {
|
---|
| 3091 | cdrecord[0] = '\0';
|
---|
| 3092 | log_msg(2, "Oh well. I guess I'll just pray then.");
|
---|
| 3093 | }
|
---|
| 3094 | if (cdrecord[0]) {
|
---|
| 3095 | if (!keep_looping) {
|
---|
| 3096 | retract_CD_tray_and_defeat_autorun();
|
---|
| 3097 | res = run_program_and_log_output(cdrecord, 5);
|
---|
| 3098 | } else {
|
---|
| 3099 | while ((res = run_program_and_log_output(cdrecord, 5))) {
|
---|
| 3100 | retract_CD_tray_and_defeat_autorun();
|
---|
| 3101 | if (ask_me_yes_or_no
|
---|
| 3102 | ("Unable to examine CD. Are you sure this is a valid CD-R(W) CD?"))
|
---|
| 3103 | {
|
---|
| 3104 | log_msg(1, "Well, he insisted...");
|
---|
| 3105 | break;
|
---|
| 3106 | }
|
---|
| 3107 | }
|
---|
| 3108 | }
|
---|
| 3109 | }
|
---|
| 3110 | }
|
---|
[1] | 3111 | // retract_CD_tray_and_defeat_autorun();
|
---|
[128] | 3112 | paranoid_free(tmp);
|
---|
| 3113 | paranoid_free(cdrecord);
|
---|
| 3114 | paranoid_free(bkp);
|
---|
| 3115 | return (res);
|
---|
[1] | 3116 | }
|
---|
| 3117 |
|
---|
| 3118 |
|
---|
| 3119 |
|
---|
| 3120 |
|
---|
| 3121 |
|
---|
| 3122 |
|
---|
| 3123 |
|
---|
| 3124 |
|
---|
| 3125 |
|
---|
| 3126 | /**
|
---|
| 3127 | * Asks the user to put a CD-R(W) in the drive.
|
---|
| 3128 | * @param ask_for_one_if_more_than_this (unused)
|
---|
| 3129 | * @param pmountable If non-NULL, pointed-to value is set to TRUE if the CD is mountable, FALSE otherwise.
|
---|
| 3130 | */
|
---|
| 3131 | void
|
---|
[128] | 3132 | pause_and_ask_for_cdr(int ask_for_one_if_more_than_this, bool * pmountable)
|
---|
[1] | 3133 | {
|
---|
| 3134 |
|
---|
[128] | 3135 | /*@ buffers ********************************************* */
|
---|
| 3136 | char *tmp;
|
---|
| 3137 | char *szmsg;
|
---|
| 3138 | char *cdrom_dev;
|
---|
| 3139 | char *cdrw_dev;
|
---|
| 3140 | char *our_serial_str;
|
---|
| 3141 | bool ok_go_ahead_burn_it;
|
---|
| 3142 | int cd_number = -1;
|
---|
| 3143 | int attempt_to_mount_returned_this = 999;
|
---|
| 3144 | char *mtpt;
|
---|
| 3145 | char *szcdno;
|
---|
| 3146 | char *szserfname;
|
---|
| 3147 | char *szunmount;
|
---|
[1] | 3148 |
|
---|
[128] | 3149 | malloc_string(tmp);
|
---|
| 3150 | malloc_string(szmsg);
|
---|
| 3151 | malloc_string(cdrom_dev);
|
---|
| 3152 | malloc_string(cdrw_dev);
|
---|
| 3153 | malloc_string(mtpt);
|
---|
| 3154 | malloc_string(szcdno);
|
---|
| 3155 | malloc_string(szserfname);
|
---|
| 3156 | malloc_string(our_serial_str);
|
---|
| 3157 | malloc_string(szunmount);
|
---|
[1] | 3158 |
|
---|
[128] | 3159 | sprintf(szmsg, "I am about to burn %s #%d",
|
---|
| 3160 | media_descriptor_string(g_backup_media_type),
|
---|
| 3161 | g_current_media_number);
|
---|
| 3162 | log_to_screen(szmsg);
|
---|
| 3163 | if (g_current_media_number < ask_for_one_if_more_than_this) {
|
---|
| 3164 | return;
|
---|
| 3165 | }
|
---|
| 3166 | log_to_screen("Scanning CD-ROM drive...");
|
---|
| 3167 | sprintf(mtpt, "/tmp/cd.mtpt.%ld.%ld", (long int) random(),
|
---|
| 3168 | (long int) random());
|
---|
| 3169 | make_hole_for_dir(mtpt);
|
---|
[1] | 3170 |
|
---|
[128] | 3171 | gotos_make_me_puke:
|
---|
| 3172 | ok_go_ahead_burn_it = TRUE;
|
---|
| 3173 | if (!find_cdrom_device(cdrom_dev, FALSE)) {
|
---|
[1] | 3174 | /* When enabled, it made CD eject-and-retract when wrong CD inserted.. Weird
|
---|
| 3175 | log_msg(2, "paafcd: Retracting CD-ROM drive if possible" );
|
---|
| 3176 | retract_CD_tray_and_defeat_autorun();
|
---|
| 3177 | */
|
---|
[128] | 3178 | sprintf(tmp, "umount %s", cdrom_dev);
|
---|
| 3179 | run_program_and_log_output(tmp, 1);
|
---|
| 3180 | sprintf(szcdno, "%s/archives/THIS-CD-NUMBER", mtpt);
|
---|
| 3181 | sprintf(szserfname, "%s/archives/SERIAL-STRING", mtpt);
|
---|
| 3182 | sprintf(szunmount, "umount %s", mtpt);
|
---|
| 3183 | cd_number = -1;
|
---|
| 3184 | our_serial_str[0] = '\0';
|
---|
| 3185 | sprintf(tmp, "mount %s %s", cdrom_dev, mtpt);
|
---|
| 3186 | if ((attempt_to_mount_returned_this =
|
---|
| 3187 | run_program_and_log_output(tmp, 1))) {
|
---|
| 3188 | log_msg(4, "Failed to mount %s at %s", cdrom_dev, mtpt);
|
---|
| 3189 | log_to_screen("If there's a CD/DVD in the drive, it's blank.");
|
---|
| 3190 | /*
|
---|
| 3191 | if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE))
|
---|
| 3192 | {
|
---|
| 3193 | ok_go_ahead_burn_it = FALSE;
|
---|
| 3194 | log_to_screen("There isn't a writable CD/DVD in the drive.");
|
---|
| 3195 | }
|
---|
| 3196 | else
|
---|
| 3197 | {
|
---|
| 3198 | log_to_screen("Confirmed. There is a blank CD/DVD in the drive.");
|
---|
| 3199 | }
|
---|
| 3200 | */
|
---|
| 3201 | } else if (!does_file_exist(szcdno)
|
---|
| 3202 | || !does_file_exist(szserfname)) {
|
---|
| 3203 | log_to_screen
|
---|
| 3204 | ("%s has data on it but it's probably not a Mondo CD.",
|
---|
| 3205 | media_descriptor_string(g_backup_media_type));
|
---|
| 3206 | } else {
|
---|
| 3207 | log_to_screen("%s found in drive. It's a Mondo disk.",
|
---|
| 3208 | media_descriptor_string(g_backup_media_type));
|
---|
| 3209 | cd_number = atoi(last_line_of_file(szcdno));
|
---|
| 3210 | sprintf(tmp, "cat %s 2> /dev/null", szserfname);
|
---|
| 3211 | strcpy(our_serial_str,
|
---|
| 3212 | call_program_and_get_last_line_of_output(tmp));
|
---|
| 3213 | // FIXME - should be able to use last_line_of_file(), surely?
|
---|
| 3214 | }
|
---|
| 3215 | run_program_and_log_output(szunmount, 1);
|
---|
| 3216 | log_msg(2, "paafcd: cd_number = %d", cd_number);
|
---|
| 3217 | log_msg(2, "our serial str = %s; g_serial_string = %s",
|
---|
| 3218 | our_serial_str, g_serial_string);
|
---|
| 3219 | if (cd_number > 0 && !strcmp(our_serial_str, g_serial_string)) {
|
---|
| 3220 | log_msg(2, "This %s is part of this backup set!",
|
---|
| 3221 | media_descriptor_string(g_backup_media_type));
|
---|
| 3222 | ok_go_ahead_burn_it = FALSE;
|
---|
| 3223 | if (cd_number == g_current_media_number - 1) {
|
---|
| 3224 | log_to_screen
|
---|
| 3225 | ("I think you've left the previous %s in the drive.",
|
---|
| 3226 | media_descriptor_string(g_backup_media_type));
|
---|
| 3227 | } else {
|
---|
| 3228 | log_to_screen
|
---|
| 3229 | ("Please remove this %s. It is part of the backup set you're making now.",
|
---|
| 3230 | media_descriptor_string(g_backup_media_type));
|
---|
| 3231 | }
|
---|
| 3232 | } else {
|
---|
| 3233 | log_to_screen("...but not part of _our_ backup set.");
|
---|
| 3234 | }
|
---|
| 3235 | } else {
|
---|
| 3236 | log_msg(2,
|
---|
| 3237 | "paafcd: Can't find CD-ROM drive. Perhaps it has a blank %s in it?",
|
---|
| 3238 | media_descriptor_string(g_backup_media_type));
|
---|
| 3239 | if (interrogate_disk_currently_in_cdrw_drive(cdrw_dev, FALSE)) {
|
---|
| 3240 | ok_go_ahead_burn_it = FALSE;
|
---|
| 3241 | log_to_screen("There isn't a writable %s in the drive.",
|
---|
| 3242 | media_descriptor_string(g_backup_media_type));
|
---|
| 3243 | }
|
---|
[1] | 3244 | }
|
---|
| 3245 |
|
---|
| 3246 | /*
|
---|
| 3247 | if (g_current_media_number > ask_for_one_if_more_than_this)
|
---|
| 3248 | {
|
---|
| 3249 | ok_go_ahead_burn_it = FALSE;
|
---|
| 3250 | log_it("paafcd: %d > %d, so I'll definitely pause.", g_current_media_number > ask_for_one_if_more_than_this);
|
---|
| 3251 | }
|
---|
| 3252 | */
|
---|
| 3253 |
|
---|
[128] | 3254 | if (!ok_go_ahead_burn_it) {
|
---|
| 3255 | eject_device(cdrom_dev);
|
---|
| 3256 | sprintf(tmp,
|
---|
| 3257 | "I am about to burn %s #%d of the backup set. Please insert %s and press Enter.",
|
---|
| 3258 | media_descriptor_string(g_backup_media_type),
|
---|
| 3259 | g_current_media_number,
|
---|
| 3260 | media_descriptor_string(g_backup_media_type));
|
---|
| 3261 | popup_and_OK(tmp);
|
---|
| 3262 | goto gotos_make_me_puke;
|
---|
| 3263 | } else {
|
---|
| 3264 | log_msg(2, "paafcd: OK, going ahead and burning it.");
|
---|
| 3265 | }
|
---|
[1] | 3266 |
|
---|
[128] | 3267 | log_msg(2,
|
---|
| 3268 | "paafcd: OK, I assume I have a blank/reusable %s in the drive...",
|
---|
| 3269 | media_descriptor_string(g_backup_media_type));
|
---|
[1] | 3270 |
|
---|
[128] | 3271 | // if (ask_for_one_if_more_than_this>1) { popup_and_OK(szmsg); }
|
---|
[1] | 3272 |
|
---|
[128] | 3273 | log_to_screen("Proceeding w/ %s in drive.",
|
---|
| 3274 | media_descriptor_string(g_backup_media_type));
|
---|
| 3275 | paranoid_free(tmp);
|
---|
| 3276 | paranoid_free(szmsg);
|
---|
| 3277 | paranoid_free(cdrom_dev);
|
---|
| 3278 | paranoid_free(cdrw_dev);
|
---|
| 3279 | paranoid_free(mtpt);
|
---|
| 3280 | paranoid_free(szcdno);
|
---|
| 3281 | paranoid_free(szserfname);
|
---|
| 3282 | paranoid_free(our_serial_str);
|
---|
| 3283 | paranoid_free(szunmount);
|
---|
| 3284 | if (pmountable) {
|
---|
| 3285 | if (attempt_to_mount_returned_this) {
|
---|
| 3286 | *pmountable = FALSE;
|
---|
| 3287 | } else {
|
---|
| 3288 | *pmountable = TRUE;
|
---|
| 3289 | }
|
---|
| 3290 | }
|
---|
[1] | 3291 |
|
---|
| 3292 | }
|
---|
| 3293 |
|
---|
| 3294 |
|
---|
| 3295 |
|
---|
| 3296 |
|
---|
| 3297 |
|
---|
| 3298 |
|
---|
| 3299 |
|
---|
| 3300 |
|
---|
| 3301 | /**
|
---|
| 3302 | * Set the <tt>N</tt>th bit of @c array to @c true_or_false.
|
---|
| 3303 | * @param array The bit array (as a @c char pointer).
|
---|
| 3304 | * @param N The bit number to set or reset.
|
---|
| 3305 | * @param true_or_false If TRUE then set bit @c N, if FALSE then reset bit @c N.
|
---|
| 3306 | * @see get_bit_N_of_array
|
---|
| 3307 | */
|
---|
[128] | 3308 | void set_bit_N_of_array(char *array, int N, bool true_or_false)
|
---|
[1] | 3309 | {
|
---|
[128] | 3310 | int bit_number;
|
---|
| 3311 | int mask, orig_val, to_add;
|
---|
| 3312 | int element_number;
|
---|
[1] | 3313 |
|
---|
[128] | 3314 | assert(array != NULL);
|
---|
[1] | 3315 |
|
---|
[128] | 3316 | element_number = N / 8;
|
---|
| 3317 | bit_number = N % 8;
|
---|
| 3318 | to_add = (1 << bit_number);
|
---|
| 3319 | mask = 255 - to_add;
|
---|
| 3320 | orig_val = array[element_number] & mask;
|
---|
| 3321 | // log_it("array[%d]=%02x; %02x&%02x = %02x", element_number, array[element_number], mask, orig_val);
|
---|
| 3322 | if (true_or_false) {
|
---|
| 3323 | array[element_number] = orig_val | to_add;
|
---|
| 3324 | }
|
---|
[1] | 3325 | }
|
---|
| 3326 |
|
---|
| 3327 | /* @} - end of utilityGroup */
|
---|
| 3328 |
|
---|
| 3329 |
|
---|
| 3330 |
|
---|
| 3331 |
|
---|
| 3332 |
|
---|
| 3333 |
|
---|
| 3334 |
|
---|
| 3335 |
|
---|
| 3336 | /**
|
---|
| 3337 | * Chop up @c filename.
|
---|
| 3338 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 3339 | * - @c backup_media_type
|
---|
| 3340 | * - @c compression_level
|
---|
| 3341 | * - @c optimal_set_size
|
---|
| 3342 | * - @c tmpdir
|
---|
| 3343 | * - @c use_lzo
|
---|
| 3344 | * - @c zip_exe
|
---|
| 3345 | * - @c zip_suffix
|
---|
| 3346 | *
|
---|
| 3347 | * @param biggie_filename The file to chop up.
|
---|
[296] | 3348 | * @param ntfsprog_fifo The FIFO to ntfsclone if this is an imagedev, NULL otherwise.
|
---|
[1] | 3349 | * @param biggie_file_number The sequence number of this biggie file (starting from 0).
|
---|
| 3350 | * @param noof_biggie_files The number of biggie files there are total.
|
---|
| 3351 | * @return The number of errors encountered (0 for success)
|
---|
| 3352 | * @see make_slices_and_images
|
---|
| 3353 | * @ingroup LLarchiveGroup
|
---|
| 3354 | */
|
---|
| 3355 | int
|
---|
[541] | 3356 | slice_up_file_etc(struct s_bkpinfo *bkpinfo, char *biggie_filename,
|
---|
[296] | 3357 | char *ntfsprog_fifo, long biggie_file_number,
|
---|
| 3358 | long noof_biggie_files, bool use_ntfsprog)
|
---|
[1] | 3359 | {
|
---|
| 3360 |
|
---|
[128] | 3361 | /*@ buffers ************************************************** */
|
---|
| 3362 | char *tmp, *checksum_line, *command;
|
---|
| 3363 | char *tempblock;
|
---|
| 3364 | char *curr_slice_fname_uncompressed;
|
---|
| 3365 | char *curr_slice_fname_compressed;
|
---|
| 3366 | char *file_to_archive;
|
---|
| 3367 | char *file_to_openin;
|
---|
| 3368 | /*@ pointers ************************************************** */
|
---|
| 3369 | char *pB;
|
---|
| 3370 | FILE *fin, *fout;
|
---|
[1] | 3371 |
|
---|
[128] | 3372 | /*@ bool ****************************************************** */
|
---|
| 3373 | bool finished = FALSE;
|
---|
[1] | 3374 |
|
---|
[128] | 3375 | /*@ long ****************************************************** */
|
---|
| 3376 | size_t blksize = 0;
|
---|
| 3377 | long slice_num = 0;
|
---|
| 3378 | long i;
|
---|
| 3379 | long optimal_set_size;
|
---|
| 3380 | bool should_I_compress_slices;
|
---|
| 3381 | char *suffix; // for compressed slices
|
---|
[1] | 3382 |
|
---|
[128] | 3383 | /*@ long long ************************************************** */
|
---|
[684] | 3384 | off_t totalread = (off_t)0;
|
---|
| 3385 | off_t totallength = (off_t)0;
|
---|
| 3386 | off_t length;
|
---|
[1] | 3387 |
|
---|
[128] | 3388 | /*@ int ******************************************************** */
|
---|
| 3389 | int retval = 0;
|
---|
| 3390 | int res = 0;
|
---|
[1] | 3391 |
|
---|
[128] | 3392 | /*@ structures ************************************************** */
|
---|
| 3393 | struct s_filename_and_lstat_info biggiestruct;
|
---|
[1] | 3394 | // struct stat statbuf;
|
---|
| 3395 |
|
---|
[128] | 3396 | assert(bkpinfo != NULL);
|
---|
| 3397 | assert_string_is_neither_NULL_nor_zerolength(biggie_filename);
|
---|
| 3398 | malloc_string(tmp);
|
---|
| 3399 | malloc_string(checksum_line);
|
---|
| 3400 | malloc_string(curr_slice_fname_uncompressed);
|
---|
| 3401 | malloc_string(curr_slice_fname_compressed);
|
---|
| 3402 | malloc_string(file_to_archive);
|
---|
| 3403 | malloc_string(suffix);
|
---|
| 3404 | command = malloc(MAX_STR_LEN * 8);
|
---|
[1] | 3405 |
|
---|
[128] | 3406 | biggiestruct.for_backward_compatibility = '\n';
|
---|
[296] | 3407 | biggiestruct.use_ntfsprog = use_ntfsprog;
|
---|
[128] | 3408 | if (!(tempblock = (char *) malloc(256 * 1024))) {
|
---|
| 3409 | fatal_error("malloc error 256*1024");
|
---|
| 3410 | }
|
---|
| 3411 | optimal_set_size = bkpinfo->optimal_set_size;
|
---|
| 3412 | if (is_this_file_compressed(biggie_filename)
|
---|
| 3413 | || bkpinfo->compression_level == 0) {
|
---|
| 3414 | suffix[0] = '\0';
|
---|
| 3415 | // log_it("%s is indeed compressed :-)", filename);
|
---|
| 3416 | should_I_compress_slices = FALSE;
|
---|
| 3417 | } else {
|
---|
| 3418 | strcpy(suffix, bkpinfo->zip_suffix);
|
---|
| 3419 | should_I_compress_slices = TRUE;
|
---|
| 3420 | }
|
---|
[1] | 3421 |
|
---|
[128] | 3422 | if (optimal_set_size < 999) {
|
---|
| 3423 | fatal_error("bkpinfo->optimal_set_size is insanely small");
|
---|
| 3424 | }
|
---|
[296] | 3425 | if (ntfsprog_fifo) {
|
---|
| 3426 | file_to_openin = ntfsprog_fifo;
|
---|
[128] | 3427 | strcpy(checksum_line, "IGNORE");
|
---|
| 3428 | log_msg(2,
|
---|
| 3429 | "Not calculating checksum for %s: it would take too long",
|
---|
| 3430 | biggie_filename);
|
---|
[296] | 3431 | if ( !find_home_of_exe("ntfsresize")) {
|
---|
| 3432 | fatal_error("ntfsresize not found");
|
---|
| 3433 | }
|
---|
| 3434 | sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
|
---|
| 3435 | log_it("command = %s", command);
|
---|
| 3436 | strcpy (tmp, call_program_and_get_last_line_of_output(command));
|
---|
| 3437 | log_it("res of it = %s", tmp);
|
---|
[684] | 3438 | totallength = (off_t)atoll(tmp);
|
---|
[128] | 3439 | } else {
|
---|
| 3440 | file_to_openin = biggie_filename;
|
---|
[693] | 3441 | if (strchr(biggie_filename,'\'') != NULL) {
|
---|
| 3442 | sprintf(command, "md5sum \"%s\"", biggie_filename);
|
---|
| 3443 | } else {
|
---|
| 3444 | sprintf(command, "md5sum '%s'", biggie_filename);
|
---|
| 3445 | }
|
---|
[128] | 3446 | if (!(fin = popen(command, "r"))) {
|
---|
| 3447 | log_OS_error("Unable to popen-in command");
|
---|
| 3448 | return (1);
|
---|
| 3449 | }
|
---|
| 3450 | (void) fgets(checksum_line, MAX_STR_LEN, fin);
|
---|
| 3451 | pclose(fin);
|
---|
[167] | 3452 | totallength = length_of_file (biggie_filename);
|
---|
[128] | 3453 | }
|
---|
| 3454 | lstat(biggie_filename, &biggiestruct.properties);
|
---|
| 3455 | strcpy(biggiestruct.filename, biggie_filename);
|
---|
| 3456 | pB = strchr(checksum_line, ' ');
|
---|
| 3457 | if (!pB) {
|
---|
| 3458 | pB = strchr(checksum_line, '\t');
|
---|
| 3459 | }
|
---|
| 3460 | if (pB) {
|
---|
| 3461 | *pB = '\0';
|
---|
| 3462 | }
|
---|
| 3463 | strcpy(biggiestruct.checksum, checksum_line);
|
---|
[1] | 3464 |
|
---|
[128] | 3465 | strcpy(tmp, slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, ""));
|
---|
| 3466 | fout = fopen(tmp, "w");
|
---|
| 3467 | (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout);
|
---|
| 3468 | paranoid_fclose(fout);
|
---|
| 3469 | length = totallength / optimal_set_size / 1024;
|
---|
| 3470 | log_msg(1, "Opening in %s; slicing it and writing to CD/tape",
|
---|
| 3471 | file_to_openin);
|
---|
| 3472 | if (!(fin = fopen(file_to_openin, "r"))) {
|
---|
| 3473 | log_OS_error("Unable to openin biggie_filename");
|
---|
| 3474 | sprintf(tmp, "Cannot archive bigfile '%s': not found",
|
---|
| 3475 | biggie_filename);
|
---|
| 3476 | log_to_screen(tmp);
|
---|
| 3477 | paranoid_free(tempblock);
|
---|
| 3478 | paranoid_free(tmp);
|
---|
| 3479 | paranoid_free(checksum_line);
|
---|
| 3480 | paranoid_free(command);
|
---|
| 3481 | return (1);
|
---|
| 3482 | }
|
---|
| 3483 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 3484 | res =
|
---|
| 3485 | move_files_to_stream(bkpinfo,
|
---|
| 3486 | slice_fname(biggie_file_number, 0,
|
---|
| 3487 | bkpinfo->tmpdir, ""), NULL);
|
---|
| 3488 | } else {
|
---|
| 3489 | res =
|
---|
[541] | 3490 | move_files_to_cd(bkpinfo,
|
---|
[128] | 3491 | slice_fname(biggie_file_number, 0,
|
---|
| 3492 | bkpinfo->tmpdir, ""), NULL);
|
---|
| 3493 | }
|
---|
| 3494 | i = bkpinfo->optimal_set_size / 256;
|
---|
| 3495 | for (slice_num = 1; !finished; slice_num++) {
|
---|
| 3496 | strcpy(curr_slice_fname_uncompressed,
|
---|
| 3497 | slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir,
|
---|
| 3498 | ""));
|
---|
| 3499 | strcpy(curr_slice_fname_compressed,
|
---|
| 3500 | slice_fname(biggie_file_number, slice_num, bkpinfo->tmpdir,
|
---|
| 3501 | suffix));
|
---|
[1] | 3502 |
|
---|
[128] | 3503 | strcpy(tmp, percent_media_full_comment(bkpinfo));
|
---|
| 3504 | update_progress_form(tmp);
|
---|
| 3505 | if (!(fout = fopen(curr_slice_fname_uncompressed, "w"))) {
|
---|
| 3506 | log_OS_error(curr_slice_fname_uncompressed);
|
---|
| 3507 | return (1);
|
---|
[1] | 3508 | }
|
---|
[128] | 3509 | if ((i == bkpinfo->optimal_set_size / 256)
|
---|
| 3510 | && (totalread < 1.1 * totallength)) {
|
---|
| 3511 | for (i = 0; i < bkpinfo->optimal_set_size / 256; i++) {
|
---|
| 3512 | blksize = fread(tempblock, 1, 256 * 1024, fin);
|
---|
| 3513 | if (blksize > 0) {
|
---|
| 3514 | totalread = totalread + blksize;
|
---|
| 3515 | (void) fwrite(tempblock, 1, blksize, fout);
|
---|
| 3516 | } else {
|
---|
| 3517 | break;
|
---|
| 3518 | }
|
---|
| 3519 | }
|
---|
| 3520 | } else {
|
---|
| 3521 | i = 0;
|
---|
| 3522 | }
|
---|
| 3523 | paranoid_fclose(fout);
|
---|
| 3524 | if (i > 0) // length_of_file (curr_slice_fname_uncompressed)
|
---|
[1] | 3525 | {
|
---|
[128] | 3526 | if (!does_file_exist(curr_slice_fname_uncompressed)) {
|
---|
| 3527 | log_msg(2,
|
---|
| 3528 | "Warning - '%s' doesn't exist. How can I compress slice?",
|
---|
| 3529 | curr_slice_fname_uncompressed);
|
---|
| 3530 | }
|
---|
| 3531 | if (should_I_compress_slices && bkpinfo->compression_level > 0) {
|
---|
| 3532 | sprintf(command, "%s -%d %s", bkpinfo->zip_exe,
|
---|
| 3533 | bkpinfo->compression_level,
|
---|
| 3534 | curr_slice_fname_uncompressed);
|
---|
| 3535 | log_msg(2, command);
|
---|
| 3536 | if ((res = system(command))) {
|
---|
| 3537 | log_OS_error(command);
|
---|
| 3538 | }
|
---|
| 3539 | // did_I_compress_slice = TRUE;
|
---|
| 3540 | } else {
|
---|
| 3541 | sprintf(command, "mv %s %s 2>> %s",
|
---|
| 3542 | curr_slice_fname_uncompressed,
|
---|
| 3543 | curr_slice_fname_compressed, MONDO_LOGFILE);
|
---|
| 3544 | res = 0; // don't do it :)
|
---|
| 3545 | // did_I_compress_slice = FALSE;
|
---|
| 3546 | }
|
---|
| 3547 | retval += res;
|
---|
| 3548 | if (res) {
|
---|
| 3549 | log_msg(2, "Failed to compress the slice");
|
---|
| 3550 | }
|
---|
| 3551 | if (bkpinfo->use_lzo
|
---|
| 3552 | && strcmp(curr_slice_fname_compressed,
|
---|
| 3553 | curr_slice_fname_uncompressed)) {
|
---|
| 3554 | unlink(curr_slice_fname_uncompressed);
|
---|
| 3555 | }
|
---|
| 3556 | if (res) {
|
---|
| 3557 | sprintf(tmp, "Problem with slice # %ld", slice_num);
|
---|
| 3558 | } else {
|
---|
| 3559 | sprintf(tmp,
|
---|
| 3560 | "%s - Bigfile #%ld, slice #%ld compressed OK ",
|
---|
| 3561 | biggie_filename, biggie_file_number + 1,
|
---|
| 3562 | slice_num);
|
---|
| 3563 | }
|
---|
[1] | 3564 | #ifndef _XWIN
|
---|
[128] | 3565 | if (!g_text_mode) {
|
---|
| 3566 | newtDrawRootText(0, g_noof_rows - 2, tmp);
|
---|
| 3567 | newtRefresh();
|
---|
| 3568 | } else {
|
---|
| 3569 | log_msg(2, tmp);
|
---|
| 3570 | }
|
---|
[1] | 3571 | #else
|
---|
[128] | 3572 | log_msg(2, tmp);
|
---|
[1] | 3573 | #endif
|
---|
[128] | 3574 | strcpy(file_to_archive, curr_slice_fname_compressed);
|
---|
| 3575 | g_current_progress++;
|
---|
| 3576 | } else { /* if i==0 then ... */
|
---|
[1] | 3577 |
|
---|
[128] | 3578 | finished = TRUE;
|
---|
| 3579 | strcpy(file_to_archive, curr_slice_fname_uncompressed);
|
---|
| 3580 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 3581 | break;
|
---|
| 3582 | }
|
---|
| 3583 | }
|
---|
| 3584 |
|
---|
| 3585 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 3586 | register_in_tape_catalog(biggieslice, biggie_file_number,
|
---|
| 3587 | slice_num, file_to_archive);
|
---|
| 3588 | maintain_collection_of_recent_archives(bkpinfo->tmpdir,
|
---|
| 3589 | file_to_archive);
|
---|
| 3590 | res = move_files_to_stream(bkpinfo, file_to_archive, NULL);
|
---|
| 3591 | } else {
|
---|
[541] | 3592 | res = move_files_to_cd(bkpinfo, file_to_archive, NULL);
|
---|
[128] | 3593 | }
|
---|
| 3594 | retval += res;
|
---|
| 3595 | if (res) {
|
---|
| 3596 | sprintf(tmp,
|
---|
| 3597 | "Failed to add slice %ld of bigfile %ld to scratchdir",
|
---|
| 3598 | slice_num, biggie_file_number + 1);
|
---|
| 3599 | log_to_screen(tmp);
|
---|
| 3600 | fatal_error
|
---|
| 3601 | ("Hard disk full. You should have bought a bigger one.");
|
---|
| 3602 | }
|
---|
[1] | 3603 | }
|
---|
[128] | 3604 | paranoid_fclose(fin);
|
---|
| 3605 | sprintf(tmp, "Sliced bigfile #%ld", biggie_file_number + 1);
|
---|
| 3606 | if (retval) {
|
---|
| 3607 | strcat(tmp, "...FAILED");
|
---|
| 3608 | } else {
|
---|
| 3609 | strcat(tmp, "...OK!");
|
---|
[1] | 3610 | }
|
---|
[128] | 3611 | log_msg(1, tmp);
|
---|
| 3612 | paranoid_free(tempblock);
|
---|
| 3613 | paranoid_free(tmp);
|
---|
| 3614 | paranoid_free(checksum_line);
|
---|
| 3615 | paranoid_free(command);
|
---|
| 3616 | paranoid_free(curr_slice_fname_uncompressed);
|
---|
| 3617 | paranoid_free(curr_slice_fname_compressed);
|
---|
| 3618 | paranoid_free(file_to_archive);
|
---|
| 3619 | paranoid_free(suffix);
|
---|
| 3620 | return (retval);
|
---|
[1] | 3621 | }
|
---|
| 3622 |
|
---|
| 3623 |
|
---|
| 3624 |
|
---|
| 3625 |
|
---|
| 3626 |
|
---|
| 3627 |
|
---|
| 3628 | /**
|
---|
| 3629 | * Remove the archives in @c d.
|
---|
| 3630 | * This could possibly include any of:
|
---|
| 3631 | * - all afioballs (compressed and not)
|
---|
| 3632 | * - all filelists
|
---|
| 3633 | * - all slices
|
---|
| 3634 | * - all checksums
|
---|
| 3635 | * - a zero filler file
|
---|
| 3636 | *
|
---|
| 3637 | * @param d The directory to wipe the archives from.
|
---|
| 3638 | * @ingroup utilityGroup
|
---|
| 3639 | */
|
---|
[128] | 3640 | void wipe_archives(char *d)
|
---|
[1] | 3641 | {
|
---|
[128] | 3642 | /*@ buffers ********************************************* */
|
---|
| 3643 | char *tmp;
|
---|
| 3644 | char *dir;
|
---|
[1] | 3645 |
|
---|
[128] | 3646 | malloc_string(tmp);
|
---|
| 3647 | malloc_string(dir);
|
---|
| 3648 | assert_string_is_neither_NULL_nor_zerolength(d);
|
---|
[1] | 3649 |
|
---|
[128] | 3650 | sprintf(dir, "%s/archives", d);
|
---|
| 3651 | sprintf(tmp, "find %s -name '*.afio*' -exec rm -f '{}' \\;", dir);
|
---|
| 3652 | run_program_and_log_output(tmp, FALSE);
|
---|
| 3653 | sprintf(tmp, "find %s -name '*list.[0-9]*' -exec rm -f '{}' \\;", dir);
|
---|
| 3654 | run_program_and_log_output(tmp, FALSE);
|
---|
| 3655 | sprintf(tmp, "find %s -name 'slice*' -exec rm -f '{}' \\;", dir);
|
---|
| 3656 | run_program_and_log_output(tmp, FALSE);
|
---|
| 3657 | sprintf(tmp, "rm -f %s/cklist*", dir);
|
---|
| 3658 | run_program_and_log_output(tmp, FALSE);
|
---|
| 3659 | sprintf(tmp, "rm -f %s/zero", dir);
|
---|
| 3660 | run_program_and_log_output(tmp, FALSE);
|
---|
| 3661 | log_msg(1, "Wiped %s's archives", dir);
|
---|
| 3662 | sprintf(tmp, "ls -l %s", dir);
|
---|
| 3663 | run_program_and_log_output(tmp, FALSE);
|
---|
| 3664 | paranoid_free(tmp);
|
---|
| 3665 | paranoid_free(dir);
|
---|
[1] | 3666 | }
|
---|
| 3667 |
|
---|
| 3668 |
|
---|
| 3669 |
|
---|
| 3670 | /**
|
---|
| 3671 | * @addtogroup LLarchiveGroup
|
---|
| 3672 | * @{
|
---|
| 3673 | */
|
---|
| 3674 | /**
|
---|
| 3675 | * Write the final ISO image.
|
---|
| 3676 | * @param bkpinfo The backup information structure. Used only
|
---|
| 3677 | * in the call to @c write_iso_and_go_on().
|
---|
| 3678 | * @return The number of errors encountered (0 for success)
|
---|
| 3679 | * @see write_iso_and_go_on
|
---|
| 3680 | * @see make_iso_fs
|
---|
| 3681 | * @bug The final ISO is written even if there are no files on it. In practice,
|
---|
| 3682 | * however, this occurs rarely.
|
---|
| 3683 | */
|
---|
[541] | 3684 | int write_final_iso_if_necessary(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 3685 | {
|
---|
[128] | 3686 | /*@ int ***************************************************** */
|
---|
| 3687 | int res;
|
---|
[1] | 3688 |
|
---|
[128] | 3689 | /*@ buffers ************************************************** */
|
---|
| 3690 | char *tmp;
|
---|
[1] | 3691 |
|
---|
[128] | 3692 | malloc_string(tmp);
|
---|
| 3693 | assert(bkpinfo != NULL);
|
---|
[1] | 3694 |
|
---|
| 3695 | // I should really check if there are any slices or tarballs to be copied to CD-R(W)'s; the odds are approx. 1 in a million that there are no files here, so I'll just go ahead & make one more CD anyway
|
---|
| 3696 |
|
---|
[128] | 3697 | sprintf(tmp, "Writing the final ISO");
|
---|
| 3698 | log_msg(2, tmp);
|
---|
| 3699 | center_string(tmp, 80);
|
---|
[1] | 3700 | #ifndef _XWIN
|
---|
[128] | 3701 | if (!g_text_mode) {
|
---|
| 3702 | newtPushHelpLine(tmp);
|
---|
| 3703 | }
|
---|
[1] | 3704 | #endif
|
---|
[541] | 3705 | res = write_iso_and_go_on(bkpinfo, TRUE);
|
---|
[1] | 3706 | #ifndef _XWIN
|
---|
[128] | 3707 | if (!g_text_mode) {
|
---|
| 3708 | newtPopHelpLine();
|
---|
| 3709 | }
|
---|
[1] | 3710 | #endif
|
---|
[128] | 3711 | log_msg(2, "Returning from writing final ISO (res=%d)", res);
|
---|
| 3712 | paranoid_free(tmp);
|
---|
| 3713 | return (res);
|
---|
[1] | 3714 | }
|
---|
| 3715 |
|
---|
| 3716 |
|
---|
| 3717 | /**
|
---|
[20] | 3718 | * Write an ISO image to <tt>[bkpinfo->isodir]/bkpinfo->prefix-[g_current_media_number].iso</tt>.
|
---|
[1] | 3719 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 3720 | * - @c backup_media_type
|
---|
[20] | 3721 | * - @c prefix
|
---|
[1] | 3722 | * - @c isodir
|
---|
| 3723 | * - @c manual_cd_tray
|
---|
| 3724 | * - @c media_size
|
---|
| 3725 | * - @c nfs_mount
|
---|
| 3726 | * - @c nfs_remote_dir
|
---|
| 3727 | * - @c scratchdir
|
---|
| 3728 | * - @c verify_data
|
---|
| 3729 | *
|
---|
| 3730 | * @param last_cd If TRUE, this is the last CD to write; if FALSE, it's not.
|
---|
| 3731 | * @return The number of errors encountered (0 for success)
|
---|
| 3732 | * @see make_iso_fs
|
---|
| 3733 | */
|
---|
[541] | 3734 | int write_iso_and_go_on(struct s_bkpinfo *bkpinfo, bool last_cd)
|
---|
[1] | 3735 | {
|
---|
[128] | 3736 | /*@ pointers **************************************************** */
|
---|
| 3737 | FILE *fout;
|
---|
[1] | 3738 |
|
---|
[128] | 3739 | /*@ buffers ***************************************************** */
|
---|
| 3740 | char *tmp;
|
---|
| 3741 | char *cdno_fname;
|
---|
| 3742 | char *lastcd_fname;
|
---|
| 3743 | char *isofile;
|
---|
[1] | 3744 |
|
---|
[128] | 3745 | /*@ bool ******************************************************** */
|
---|
| 3746 | bool that_one_was_ok;
|
---|
| 3747 | bool using_nfs;
|
---|
| 3748 | bool orig_vfy_flag_val;
|
---|
[1] | 3749 |
|
---|
[128] | 3750 | /*@ int *********************************************************** */
|
---|
| 3751 | int res = 0;
|
---|
[1] | 3752 |
|
---|
[128] | 3753 | malloc_string(tmp);
|
---|
| 3754 | malloc_string(cdno_fname);
|
---|
| 3755 | malloc_string(lastcd_fname);
|
---|
| 3756 | malloc_string(isofile);
|
---|
[1] | 3757 |
|
---|
[128] | 3758 | assert(bkpinfo != NULL);
|
---|
| 3759 | orig_vfy_flag_val = bkpinfo->verify_data;
|
---|
| 3760 | if (bkpinfo->media_size[g_current_media_number] <= 0) {
|
---|
| 3761 | fatal_error("write_iso_and_go_on() - unknown media size");
|
---|
| 3762 | }
|
---|
[1] | 3763 |
|
---|
[128] | 3764 | if (strlen(bkpinfo->nfs_mount) > 1) {
|
---|
| 3765 | using_nfs = TRUE;
|
---|
| 3766 | } else {
|
---|
| 3767 | using_nfs = FALSE;
|
---|
| 3768 | }
|
---|
| 3769 | log_msg(1, "OK, time to make %s #%d",
|
---|
| 3770 | media_descriptor_string(bkpinfo->backup_media_type),
|
---|
| 3771 | g_current_media_number);
|
---|
[1] | 3772 |
|
---|
[128] | 3773 | /* label the ISO with its number */
|
---|
[1] | 3774 |
|
---|
[128] | 3775 | sprintf(cdno_fname, "%s/archives/THIS-CD-NUMBER", bkpinfo->scratchdir);
|
---|
| 3776 | fout = fopen(cdno_fname, "w");
|
---|
| 3777 | fprintf(fout, "%d", g_current_media_number);
|
---|
| 3778 | paranoid_fclose(fout);
|
---|
[1] | 3779 |
|
---|
[128] | 3780 | sprintf(tmp, "cp -f %s/autorun %s/", g_mondo_home,
|
---|
| 3781 | bkpinfo->scratchdir);
|
---|
| 3782 | if (run_program_and_log_output(tmp, FALSE)) {
|
---|
| 3783 | log_msg(2, "Warning - unable to copy autorun to scratchdir");
|
---|
[1] | 3784 | }
|
---|
[128] | 3785 |
|
---|
| 3786 | /* last CD or not? Label accordingly */
|
---|
| 3787 | sprintf(lastcd_fname, "%s/archives/NOT-THE-LAST", bkpinfo->scratchdir);
|
---|
| 3788 | if (last_cd) {
|
---|
| 3789 | unlink(lastcd_fname);
|
---|
| 3790 | log_msg(2,
|
---|
| 3791 | "OK, you're telling me this is the last CD. Fair enough.");
|
---|
| 3792 | } else {
|
---|
| 3793 | fout = fopen(lastcd_fname, "w");
|
---|
| 3794 | fprintf(fout,
|
---|
| 3795 | "You're listening to 90.3 WPLN, Nashville Public Radio.\n");
|
---|
| 3796 | paranoid_fclose(fout);
|
---|
[1] | 3797 | }
|
---|
[128] | 3798 | if (space_occupied_by_cd(bkpinfo->scratchdir) / 1024 >
|
---|
| 3799 | bkpinfo->media_size[g_current_media_number]) {
|
---|
| 3800 | sprintf(tmp,
|
---|
| 3801 | "Warning! CD is too big. It occupies %ld KB, which is more than the %ld KB allowed.",
|
---|
| 3802 | (long) space_occupied_by_cd(bkpinfo->scratchdir),
|
---|
| 3803 | (long) bkpinfo->media_size[g_current_media_number]);
|
---|
| 3804 | log_to_screen(tmp);
|
---|
| 3805 | }
|
---|
| 3806 | sprintf(isofile, "%s/%s/%s-%d.iso", bkpinfo->isodir,
|
---|
| 3807 | bkpinfo->nfs_remote_dir, bkpinfo->prefix,
|
---|
| 3808 | g_current_media_number);
|
---|
| 3809 | for (that_one_was_ok = FALSE; !that_one_was_ok;) {
|
---|
[541] | 3810 | res = make_iso_fs(bkpinfo, isofile);
|
---|
[128] | 3811 | if (g_current_media_number == 1 && !res
|
---|
| 3812 | && (bkpinfo->backup_media_type == cdr
|
---|
| 3813 | || bkpinfo->backup_media_type == cdrw)) {
|
---|
| 3814 | if (find_cdrom_device(tmp, FALSE)) // make sure find_cdrom_device() finds, records CD-R's loc
|
---|
| 3815 | {
|
---|
| 3816 | log_msg(3, "*Sigh* Mike, I hate your computer.");
|
---|
| 3817 | bkpinfo->manual_cd_tray = TRUE;
|
---|
| 3818 | } // if it can't be found then force pausing
|
---|
| 3819 | else {
|
---|
| 3820 | log_msg(3, "Great. Found Mike's CD-ROM drive.");
|
---|
| 3821 | }
|
---|
[1] | 3822 | }
|
---|
[128] | 3823 | if (bkpinfo->verify_data && !res) {
|
---|
| 3824 | log_to_screen
|
---|
| 3825 | ("Please reboot from the 1st %s in Compare Mode, as a precaution.",
|
---|
| 3826 | media_descriptor_string(g_backup_media_type));
|
---|
| 3827 | chdir("/");
|
---|
| 3828 | iamhere("Before calling verify_cd_image()");
|
---|
| 3829 | res += verify_cd_image(bkpinfo);
|
---|
| 3830 | iamhere("After calling verify_cd_image()");
|
---|
[1] | 3831 | }
|
---|
[128] | 3832 | if (!res) {
|
---|
| 3833 | that_one_was_ok = TRUE;
|
---|
| 3834 | } else {
|
---|
| 3835 | sprintf(tmp, "Failed to burn %s #%d. Retry?",
|
---|
| 3836 | media_descriptor_string(bkpinfo->backup_media_type),
|
---|
| 3837 | g_current_media_number);
|
---|
| 3838 | res = ask_me_yes_or_no(tmp);
|
---|
| 3839 | if (!res) {
|
---|
| 3840 | if (ask_me_yes_or_no("Abort the backup?")) {
|
---|
| 3841 | fatal_error("FAILED TO BACKUP");
|
---|
| 3842 | } else {
|
---|
| 3843 | break;
|
---|
| 3844 | }
|
---|
| 3845 | } else {
|
---|
| 3846 | log_msg(2, "Retrying, at user's request...");
|
---|
| 3847 | res = 0;
|
---|
| 3848 | }
|
---|
| 3849 | }
|
---|
[1] | 3850 | }
|
---|
| 3851 | /*
|
---|
| 3852 | if (using_nfs)
|
---|
| 3853 | {
|
---|
| 3854 | sprintf(tmp,"mv -f %s %s/%s/", isofile, bkpinfo->isodir, bkpinfo->nfs_remote_dir);
|
---|
| 3855 | if (run_program_and_log_output(tmp, FALSE))
|
---|
| 3856 | { log_to_screen("Unable to move ISO to NFS dir"); }
|
---|
| 3857 | }
|
---|
| 3858 | */
|
---|
[128] | 3859 | g_current_media_number++;
|
---|
| 3860 | if (g_current_media_number > MAX_NOOF_MEDIA) {
|
---|
| 3861 | fatal_error("Too many CD-R(W)'s. Use tape or net.");
|
---|
| 3862 | }
|
---|
| 3863 | wipe_archives(bkpinfo->scratchdir);
|
---|
| 3864 | sprintf(tmp, "rm -Rf %s/images/*gz %s/images/*data*img",
|
---|
| 3865 | bkpinfo->scratchdir, bkpinfo->scratchdir);
|
---|
| 3866 | if (system(tmp)) {
|
---|
| 3867 | log_msg
|
---|
| 3868 | (2,
|
---|
| 3869 | "Error occurred when I tried to delete the redundant IMGs and GZs");
|
---|
| 3870 | }
|
---|
[1] | 3871 |
|
---|
[128] | 3872 | if (last_cd) {
|
---|
| 3873 | log_msg(2, "This was your last CD.");
|
---|
| 3874 | } else {
|
---|
| 3875 | log_msg(2, "Continuing to backup your data...");
|
---|
| 3876 | }
|
---|
[1] | 3877 |
|
---|
[128] | 3878 | bkpinfo->verify_data = orig_vfy_flag_val;
|
---|
| 3879 | paranoid_free(tmp);
|
---|
| 3880 | paranoid_free(cdno_fname);
|
---|
| 3881 | paranoid_free(lastcd_fname);
|
---|
| 3882 | paranoid_free(isofile);
|
---|
| 3883 | return (0);
|
---|
[1] | 3884 | }
|
---|
| 3885 |
|
---|
| 3886 | /* @} - end of LLarchiveGroup */
|
---|
| 3887 |
|
---|
| 3888 |
|
---|
| 3889 |
|
---|
| 3890 |
|
---|
| 3891 | /**
|
---|
| 3892 | * Verify the user's data.
|
---|
| 3893 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 3894 | * - @c backup_data
|
---|
| 3895 | * - @c backup_media_type
|
---|
| 3896 | * - @c media_device
|
---|
| 3897 | * - @c verify_data
|
---|
| 3898 | *
|
---|
| 3899 | * @return The number of errors encountered (0 for success)
|
---|
| 3900 | * @ingroup verifyGroup
|
---|
| 3901 | */
|
---|
| 3902 | int verify_data(struct s_bkpinfo *bkpinfo)
|
---|
| 3903 | {
|
---|
[128] | 3904 | int res = 0, retval = 0, cdno = 0;
|
---|
| 3905 | char *tmp;
|
---|
| 3906 | long diffs = 0;
|
---|
[1] | 3907 |
|
---|
[128] | 3908 | malloc_string(tmp);
|
---|
| 3909 | assert(bkpinfo != NULL);
|
---|
| 3910 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 3911 | chdir("/");
|
---|
| 3912 | mvaddstr_and_log_it(g_currentY, 0,
|
---|
| 3913 | "Verifying archives against live filesystem");
|
---|
| 3914 | if (bkpinfo->backup_media_type == cdstream) {
|
---|
| 3915 | strcpy(bkpinfo->media_device, "/dev/cdrom");
|
---|
| 3916 | }
|
---|
| 3917 | verify_tape_backups(bkpinfo);
|
---|
| 3918 | mvaddstr_and_log_it(g_currentY++, 74, "Done.");
|
---|
| 3919 | } else if (bkpinfo->backup_data)
|
---|
| 3920 | //bkpinfo->backup_media_type == cdrw || bkpinfo->backup_media_type == cdr))
|
---|
[1] | 3921 | {
|
---|
[128] | 3922 | log_msg(2,
|
---|
| 3923 | "Not verifying again. Per-CD/ISO verification already carried out.");
|
---|
| 3924 | paranoid_system
|
---|
| 3925 | ("cat /tmp/changed.files.* > /tmp/changed.files 2> /dev/null");
|
---|
| 3926 | } else {
|
---|
| 3927 | g_current_media_number = cdno;
|
---|
| 3928 | if (bkpinfo->backup_media_type != iso) {
|
---|
| 3929 | find_cdrom_device(bkpinfo->media_device, FALSE); // replace 0,0,0 with /dev/cdrom
|
---|
[1] | 3930 | }
|
---|
[128] | 3931 | chdir("/");
|
---|
| 3932 | for (cdno = 1; cdno < 99 && bkpinfo->verify_data; cdno++) {
|
---|
| 3933 | if (cdno != g_current_media_number) {
|
---|
| 3934 | log_msg(2,
|
---|
| 3935 | "Warning - had to change g_current_media_number from %d to %d",
|
---|
| 3936 | g_current_media_number, cdno);
|
---|
| 3937 | g_current_media_number = cdno;
|
---|
| 3938 | }
|
---|
| 3939 | if (bkpinfo->backup_media_type != iso) {
|
---|
| 3940 | insist_on_this_cd_number(bkpinfo, cdno);
|
---|
| 3941 | }
|
---|
| 3942 | res = verify_cd_image(bkpinfo); // sets verify_data to FALSE if it's time to stop verifying
|
---|
| 3943 | retval += res;
|
---|
| 3944 | if (res) {
|
---|
| 3945 | sprintf(tmp,
|
---|
| 3946 | "Warnings/errors were reported while checking %s #%d",
|
---|
| 3947 | media_descriptor_string(bkpinfo->
|
---|
| 3948 | backup_media_type),
|
---|
| 3949 | g_current_media_number);
|
---|
| 3950 | log_to_screen(tmp);
|
---|
[1] | 3951 |
|
---|
[128] | 3952 | }
|
---|
[1] | 3953 | }
|
---|
| 3954 | /*
|
---|
| 3955 | sprintf (tmp,
|
---|
| 3956 | "cat %s | grep \"afio: \" | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -vx \"/afio:.*\" > /tmp/changed.files",
|
---|
| 3957 | MONDO_LOGFILE);
|
---|
| 3958 | system (tmp);
|
---|
| 3959 | */
|
---|
[128] | 3960 | sprintf(tmp,
|
---|
[911] | 3961 | "grep 'afio: ' %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> /tmp/changed.files",
|
---|
[128] | 3962 | MONDO_LOGFILE);
|
---|
| 3963 | system(tmp);
|
---|
| 3964 |
|
---|
| 3965 | sprintf(tmp,
|
---|
[911] | 3966 | "grep 'star: ' %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> /tmp/changed.files",
|
---|
[128] | 3967 | MONDO_LOGFILE);
|
---|
| 3968 | system(tmp);
|
---|
| 3969 | run_program_and_log_output("umount " MNT_CDROM, FALSE);
|
---|
| 3970 | // if (bkpinfo->backup_media_type != iso && !bkpinfo->please_dont_eject_when_restoring)
|
---|
[1] | 3971 | //{
|
---|
[128] | 3972 | eject_device(bkpinfo->media_device);
|
---|
[1] | 3973 | //}
|
---|
| 3974 | }
|
---|
[128] | 3975 | diffs = count_lines_in_file("/tmp/changed.files");
|
---|
[1] | 3976 |
|
---|
[128] | 3977 | if (diffs > 0) {
|
---|
| 3978 | if (retval == 0) {
|
---|
| 3979 | retval = (int) (-diffs);
|
---|
| 3980 | }
|
---|
[1] | 3981 | }
|
---|
[128] | 3982 | paranoid_free(tmp);
|
---|
| 3983 | return (retval);
|
---|
[1] | 3984 | }
|
---|
| 3985 |
|
---|
| 3986 |
|
---|
| 3987 |
|
---|
| 3988 |
|
---|
| 3989 |
|
---|
| 3990 | /**
|
---|
| 3991 | * @addtogroup utilityGroup
|
---|
| 3992 | * @{
|
---|
| 3993 | */
|
---|
| 3994 | /**
|
---|
| 3995 | * Write an image to a real 3.5" floppy disk.
|
---|
| 3996 | * @param device The device to write to (e.g. @c /dev/fd0)
|
---|
| 3997 | * @param datafile The image to write to @p device.
|
---|
| 3998 | * @return The number of errors encountered (0 for success)
|
---|
| 3999 | * @see write_image_to_floppy
|
---|
| 4000 | */
|
---|
[128] | 4001 | int write_image_to_floppy_SUB(char *device, char *datafile)
|
---|
[1] | 4002 | {
|
---|
[128] | 4003 | /*@ int *************************************************************** */
|
---|
| 4004 | int res = 0;
|
---|
[1] | 4005 | int percentage = 0;
|
---|
| 4006 | int blockno = 0;
|
---|
[128] | 4007 | int maxblocks = 0;
|
---|
[1] | 4008 |
|
---|
[128] | 4009 | /*@ buffers************************************************************ */
|
---|
| 4010 | char *tmp;
|
---|
[1] | 4011 | char blk[1024];
|
---|
| 4012 | char *title;
|
---|
| 4013 |
|
---|
[128] | 4014 | /*@ pointers ********************************************************** */
|
---|
[1] | 4015 | char *p;
|
---|
[128] | 4016 | FILE *fout, *fin;
|
---|
[1] | 4017 |
|
---|
| 4018 |
|
---|
[128] | 4019 | malloc_string(tmp);
|
---|
| 4020 | malloc_string(title);
|
---|
| 4021 | /* pretty stuff */
|
---|
| 4022 | if (!(p = strrchr(datafile, '/'))) {
|
---|
| 4023 | p = datafile;
|
---|
| 4024 | } else {
|
---|
| 4025 | p++;
|
---|
[1] | 4026 | }
|
---|
[128] | 4027 | sprintf(title, "Writing %s to floppy", p);
|
---|
| 4028 | open_evalcall_form(title);
|
---|
| 4029 | /* functional stuff */
|
---|
| 4030 | for (p = device + strlen(device); p != device && isdigit(*(p - 1));
|
---|
| 4031 | p--);
|
---|
| 4032 | maxblocks = atoi(p);
|
---|
| 4033 | if (!maxblocks) {
|
---|
| 4034 | maxblocks = 1440;
|
---|
[1] | 4035 | }
|
---|
[128] | 4036 | sprintf(tmp, "maxblocks = %d; p=%s", maxblocks, p);
|
---|
| 4037 | log_msg(2, tmp);
|
---|
| 4038 | /* copy data from image to floppy */
|
---|
| 4039 | if (!(fin = fopen(datafile, "r"))) {
|
---|
| 4040 | log_OS_error("Cannot open img");
|
---|
| 4041 | return (1);
|
---|
[1] | 4042 | }
|
---|
[128] | 4043 | if (!(fout = fopen(device, "w"))) {
|
---|
| 4044 | log_OS_error("Cannot open fdd");
|
---|
| 4045 | return (1);
|
---|
| 4046 | }
|
---|
| 4047 | for (blockno = 0; blockno < maxblocks; blockno++) {
|
---|
| 4048 | percentage = blockno * 100 / maxblocks;
|
---|
| 4049 | if (fread(blk, 1, 1024, fin) != 1024) {
|
---|
| 4050 | if (feof(fin)) {
|
---|
| 4051 | log_msg(1,
|
---|
| 4052 | "img read err - img ended prematurely - non-fatal error");
|
---|
| 4053 | sleep(3);
|
---|
| 4054 | return (res);
|
---|
| 4055 | }
|
---|
| 4056 | res++;
|
---|
| 4057 | log_to_screen("img read err");
|
---|
| 4058 | }
|
---|
| 4059 | if (fwrite(blk, 1, 1024, fout) != 1024) {
|
---|
| 4060 | res++;
|
---|
| 4061 | log_to_screen("fdd write err");
|
---|
| 4062 | }
|
---|
| 4063 | if (((blockno + 1) % 128) == 0) {
|
---|
| 4064 | paranoid_system("sync"); /* fflush doesn't work; dunno why */
|
---|
| 4065 | update_evalcall_form(percentage);
|
---|
| 4066 | }
|
---|
| 4067 | }
|
---|
| 4068 | paranoid_fclose(fin);
|
---|
| 4069 | paranoid_fclose(fout);
|
---|
| 4070 | paranoid_free(tmp);
|
---|
| 4071 | paranoid_free(title);
|
---|
| 4072 | close_evalcall_form();
|
---|
| 4073 | return (res);
|
---|
[1] | 4074 | }
|
---|
| 4075 |
|
---|
| 4076 |
|
---|
| 4077 |
|
---|
| 4078 |
|
---|
| 4079 |
|
---|
| 4080 |
|
---|
| 4081 |
|
---|
| 4082 |
|
---|
| 4083 |
|
---|
| 4084 | /**
|
---|
| 4085 | * Wrapper around @c write_image_to_floppy_SUB().
|
---|
| 4086 | * This function, unlike @c write_image_to_floppy_SUB(),
|
---|
| 4087 | * gives the user the opportunity to retry if the write fails.
|
---|
| 4088 | * @see write_image_to_floppy_SUB
|
---|
| 4089 | */
|
---|
[128] | 4090 | int write_image_to_floppy(char *device, char *datafile)
|
---|
[1] | 4091 | {
|
---|
[128] | 4092 | /*@ int ************************************************************** */
|
---|
| 4093 | int res = 0;
|
---|
[1] | 4094 |
|
---|
[128] | 4095 | assert_string_is_neither_NULL_nor_zerolength(device);
|
---|
| 4096 | assert_string_is_neither_NULL_nor_zerolength(datafile);
|
---|
[1] | 4097 |
|
---|
[128] | 4098 | while ((res = write_image_to_floppy_SUB(device, datafile))) {
|
---|
| 4099 | if (!ask_me_yes_or_no("Failed to write image to floppy. Retry?")) {
|
---|
| 4100 | return (res);
|
---|
| 4101 | }
|
---|
[1] | 4102 | }
|
---|
[128] | 4103 | return (res);
|
---|
[1] | 4104 | }
|
---|
| 4105 |
|
---|
| 4106 | /* @} - end of utilityGroup */
|
---|
[259] | 4107 |
|
---|
[424] | 4108 | void setenv_mondo_share(void) {
|
---|
[259] | 4109 |
|
---|
[424] | 4110 | setenv("MONDO_SHARE", MONDO_SHARE, 1);
|
---|
[259] | 4111 | }
|
---|