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