[1] | 1 | /***************************************************************************
|
---|
[1080] | 2 | * $Id: mondo-rstr-tools.c 1594 2007-08-26 10:26:06Z bruno $
|
---|
[1] | 3 | */
|
---|
| 4 |
|
---|
| 5 |
|
---|
| 6 | #include <pthread.h>
|
---|
[1216] | 7 | #include <unistd.h>
|
---|
[1067] | 8 | #include "my-stuff.h"
|
---|
[1168] | 9 | #include "mr_mem.h"
|
---|
| 10 | #include "mr_msg.h"
|
---|
| 11 | #include "mr_str.h"
|
---|
[1556] | 12 | #include "mr_gettext.h"
|
---|
[1168] | 13 |
|
---|
| 14 | #include "mondostructures.h"
|
---|
| 15 | #include "libmondo.h"
|
---|
[1] | 16 | #include "mr-externs.h"
|
---|
| 17 | #include "mondo-rstr-tools.h"
|
---|
| 18 |
|
---|
[1268] | 19 | extern char *bkptype_to_string(t_bkptype bt);
|
---|
| 20 |
|
---|
[1] | 21 | extern bool g_sigpipe_caught;
|
---|
[128] | 22 | extern bool g_ISO_restore_mode; /* are we in Iso Mode? */
|
---|
[1] | 23 | extern bool g_I_have_just_nuked;
|
---|
| 24 | extern char *g_tmpfs_mountpt;
|
---|
| 25 | extern char *g_isodir_device;
|
---|
| 26 | extern char *g_isodir_format;
|
---|
| 27 | extern long g_current_progress, g_maximum_progress;
|
---|
[128] | 28 | extern char *g_biggielist_txt; // where 'biggielist.txt' is stored, on ramdisk / tempdir;
|
---|
| 29 | // biggielist.txt is the list of big files stored on the
|
---|
| 30 | // backup media set in question
|
---|
| 31 | extern char *g_filelist_full; // filelist.full.gz is the list of all regular files
|
---|
| 32 | // (excluding big files) stored on the backup media set
|
---|
| 33 | extern char *g_biggielist_pot; // list of big files which _could_ be restored, if the
|
---|
| 34 | // user chooses them
|
---|
| 35 | extern char *g_filelist_imagedevs; // list of devices (e.g. /dev/hda1, /dev/sda5) which
|
---|
| 36 | // were archived as images, not just /dev entries
|
---|
| 37 | // ... e.g. NTFS, BeOS partitions
|
---|
| 38 | extern char *g_imagedevs_restthese; // of the imagedevs listed in FILELIST_IMAGEDEVS,
|
---|
| 39 | // restore only these
|
---|
| 40 | extern char *g_mondo_cfg_file; // where m*ndo-restore.cfg (the config file) is stored
|
---|
| 41 | extern char *g_mountlist_fname; // where mountlist.txt (the mountlist file) is stored
|
---|
[1] | 42 |
|
---|
| 43 | extern t_bkptype g_backup_media_type;
|
---|
[1216] | 44 | extern char *g_backup_media_string;
|
---|
[1] | 45 |
|
---|
| 46 | extern int g_partition_table_locked_up;
|
---|
[1326] | 47 | extern char *MONDO_LOGFILE;
|
---|
[1] | 48 |
|
---|
[949] | 49 | /* Should we use or not extended attributes and acl when restoring */
|
---|
| 50 | char *g_getfattr = NULL;
|
---|
| 51 | char *g_getfacl = NULL;
|
---|
| 52 |
|
---|
[1] | 53 | /**
|
---|
| 54 | * @addtogroup restoreUtilityGroup
|
---|
| 55 | * @{
|
---|
| 56 | */
|
---|
| 57 | /**
|
---|
| 58 | * Free the malloc()s for the filename variables.
|
---|
| 59 | */
|
---|
[1103] | 60 | void free_MR_global_filenames(void)
|
---|
[1] | 61 | {
|
---|
[1080] | 62 | mr_free(g_biggielist_txt);
|
---|
| 63 | mr_free(g_filelist_full);
|
---|
| 64 | mr_free(g_filelist_imagedevs);
|
---|
| 65 | mr_free(g_imagedevs_restthese);
|
---|
| 66 | mr_free(g_mondo_cfg_file);
|
---|
| 67 | mr_free(g_mountlist_fname);
|
---|
| 68 | mr_free(g_tmpfs_mountpt);
|
---|
| 69 | mr_free(g_isodir_device);
|
---|
| 70 | mr_free(g_isodir_format);
|
---|
[1] | 71 | }
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | /**
|
---|
| 75 | * Ask the user which imagedevs from the list contained in @p infname should
|
---|
| 76 | * actually be restored.
|
---|
| 77 | * @param infname The file containing a list of all imagedevs.
|
---|
| 78 | * @param outfname The location of the output file containing the imagedevs the user wanted to restore.
|
---|
| 79 | * @ingroup restoreUtilityGroup
|
---|
| 80 | */
|
---|
[128] | 81 | void ask_about_these_imagedevs(char *infname, char *outfname)
|
---|
[1] | 82 | {
|
---|
[1216] | 83 | FILE *fin = NULL;
|
---|
| 84 | FILE *fout = NULL;
|
---|
[1] | 85 | /************************************************************************
|
---|
| 86 | * allocate memory regions. test and set -sab 16 feb 2003 *
|
---|
| 87 | ************************************************************************/
|
---|
[1216] | 88 | char *incoming = NULL;
|
---|
| 89 | char *question = NULL;
|
---|
[1] | 90 |
|
---|
[1216] | 91 | size_t n = 0;
|
---|
[1] | 92 |
|
---|
[128] | 93 | assert_string_is_neither_NULL_nor_zerolength(infname);
|
---|
| 94 | assert_string_is_neither_NULL_nor_zerolength(outfname);
|
---|
[1] | 95 |
|
---|
[128] | 96 | if (!(fin = fopen(infname, "r"))) {
|
---|
| 97 | fatal_error("Cannot openin infname");
|
---|
[1] | 98 | }
|
---|
[128] | 99 | if (!(fout = fopen(outfname, "w"))) {
|
---|
| 100 | fatal_error("Cannot openin outfname");
|
---|
| 101 | }
|
---|
[1216] | 102 | for (mr_getline(&incoming, &n, fin);
|
---|
| 103 | !feof(fin); mr_getline(&incoming, &n, fin)) {
|
---|
| 104 | mr_strip_spaces(incoming);
|
---|
[1] | 105 |
|
---|
[128] | 106 | if (incoming[0] == '\0') {
|
---|
| 107 | continue;
|
---|
| 108 | }
|
---|
[1] | 109 |
|
---|
[1216] | 110 | mr_asprintf(&question,
|
---|
| 111 | _("Should I restore the image of %s ?"), incoming);
|
---|
[128] | 112 |
|
---|
[1216] | 113 | if (ask_me_yes_or_no(question)) {
|
---|
| 114 | fprintf(fout, "%s\n", incoming);
|
---|
[128] | 115 | }
|
---|
[1216] | 116 | mr_free(question);
|
---|
[128] | 117 | }
|
---|
| 118 |
|
---|
[1] | 119 | /*** free memory ***********/
|
---|
[1216] | 120 | mr_free(incoming);
|
---|
[1] | 121 |
|
---|
[128] | 122 | paranoid_fclose(fout);
|
---|
| 123 | paranoid_fclose(fin);
|
---|
[1] | 124 | }
|
---|
| 125 |
|
---|
| 126 | /**************************************************************************
|
---|
| 127 | *ASK_ABOUT_THESE_IMAGEDEVS *
|
---|
| 128 | **************************************************************************/
|
---|
| 129 |
|
---|
| 130 |
|
---|
| 131 | /**
|
---|
| 132 | * Extract @c mondo-restore.cfg and @c mountlist.txt from @p ramdisk_fname.
|
---|
| 133 | * @param bkpinfo The backup information structure. @c tmpdir is the only field used.
|
---|
| 134 | * @param ramdisk_fname The filename of the @b compressed ramdisk to look in.
|
---|
| 135 | * @param output_cfg_file Where to put the configuration file extracted.
|
---|
| 136 | * @param output_mountlist_file Where to put the mountlist file extracted.
|
---|
| 137 | * @return 0 for success, nonzero for failure.
|
---|
| 138 | * @ingroup restoreUtilityGroup
|
---|
| 139 | */
|
---|
[128] | 140 | int
|
---|
| 141 | extract_config_file_from_ramdisk(struct s_bkpinfo *bkpinfo,
|
---|
| 142 | char *ramdisk_fname,
|
---|
| 143 | char *output_cfg_file,
|
---|
| 144 | char *output_mountlist_file)
|
---|
[1] | 145 | {
|
---|
[1216] | 146 | char *mountpt = NULL;
|
---|
| 147 | char *command = NULL;
|
---|
| 148 | char *orig_fname = NULL;
|
---|
[128] | 149 | int retval = 0;
|
---|
[1] | 150 |
|
---|
[128] | 151 | assert(bkpinfo != NULL);
|
---|
| 152 | assert_string_is_neither_NULL_nor_zerolength(ramdisk_fname);
|
---|
| 153 | assert_string_is_neither_NULL_nor_zerolength(output_cfg_file);
|
---|
| 154 | assert_string_is_neither_NULL_nor_zerolength(output_mountlist_file);
|
---|
[1216] | 155 | mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
|
---|
| 156 | mr_asprintf(&command, "mkdir -p %s", mountpt);
|
---|
[128] | 157 | run_program_and_log_output(command, FALSE);
|
---|
[1216] | 158 | mr_free(command);
|
---|
| 159 |
|
---|
| 160 | mr_asprintf(&command, "gzip -dc %s > %s/mindi.rd 2> /dev/null",
|
---|
[128] | 161 | ramdisk_fname, bkpinfo->tmpdir);
|
---|
| 162 | run_program_and_log_output(command, FALSE);
|
---|
[1216] | 163 | mr_free(command);
|
---|
[1] | 164 |
|
---|
[1216] | 165 | mr_asprintf(&command, "umount %s", mountpt);
|
---|
[128] | 166 | run_program_and_log_output(command, FALSE);
|
---|
[1216] | 167 | mr_free(command);
|
---|
[1] | 168 |
|
---|
[1216] | 169 | mr_asprintf(&command, "mount -o loop %s/mindi.rd -t ext2 %s",
|
---|
[128] | 170 | bkpinfo->tmpdir, mountpt);
|
---|
| 171 | run_program_and_log_output(command, FALSE);
|
---|
[1216] | 172 | mr_free(command);
|
---|
[1] | 173 |
|
---|
[1216] | 174 | mr_asprintf(&command, "mkdir -p %s/tmp", bkpinfo->tmpdir);
|
---|
[128] | 175 | run_program_and_log_output(command, FALSE);
|
---|
[1216] | 176 | mr_free(command);
|
---|
[1] | 177 |
|
---|
[1216] | 178 | mr_asprintf(&command, "cp -f %s/%s %s", // %s/%s becomes {mountpt}/tmp/m*ndo-restore.cfg
|
---|
[128] | 179 | mountpt, g_mondo_cfg_file, output_cfg_file);
|
---|
| 180 | run_program_and_log_output(command, FALSE);
|
---|
[1216] | 181 | mr_free(command);
|
---|
[1] | 182 |
|
---|
[1216] | 183 | mr_asprintf(&orig_fname, "%s/%s", mountpt, g_mountlist_fname);
|
---|
[128] | 184 | if (does_file_exist(orig_fname)) {
|
---|
[1216] | 185 | mr_asprintf(&command, "cp -f %s %s", orig_fname, output_mountlist_file);
|
---|
[128] | 186 | run_program_and_log_output(command, FALSE);
|
---|
[1216] | 187 | mr_free(command);
|
---|
[128] | 188 | }
|
---|
[1216] | 189 | mr_asprintf(&command, "umount %s", mountpt);
|
---|
| 190 | mr_free(mountpt);
|
---|
| 191 |
|
---|
[128] | 192 | run_program_and_log_output(command, FALSE);
|
---|
[1216] | 193 | mr_free(command);
|
---|
| 194 |
|
---|
[128] | 195 | if (!does_file_exist(output_cfg_file)
|
---|
| 196 | || (!does_file_exist(output_mountlist_file)
|
---|
| 197 | && does_file_exist(orig_fname))) {
|
---|
[1108] | 198 | mr_msg(2, "Failed to extract %s and/or %s from ramdisk",
|
---|
[128] | 199 | output_cfg_file, output_mountlist_file);
|
---|
| 200 | retval = 1;
|
---|
| 201 | } else {
|
---|
| 202 | retval = 0;
|
---|
| 203 | }
|
---|
[1080] | 204 | mr_free(orig_fname);
|
---|
[128] | 205 | return (retval);
|
---|
[1] | 206 | }
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 | /**
|
---|
| 210 | * Keep trying to get mondo-restore.cfg from the archive, until the user gives up.
|
---|
| 211 | * @param bkpinfo The backup information structure.
|
---|
| 212 | */
|
---|
| 213 | void get_cfg_file_from_archive_or_bust(struct s_bkpinfo *bkpinfo)
|
---|
| 214 | {
|
---|
[128] | 215 | while (get_cfg_file_from_archive(bkpinfo)) {
|
---|
| 216 | if (!ask_me_yes_or_no
|
---|
[1216] | 217 | (_
|
---|
| 218 | ("Failed to find config file/archives. Choose another source?")))
|
---|
[128] | 219 | {
|
---|
| 220 | fatal_error("Could not find config file/archives. Aborting.");
|
---|
| 221 | }
|
---|
| 222 | interactively_obtain_media_parameters_from_user(bkpinfo, FALSE);
|
---|
| 223 | }
|
---|
[1] | 224 | }
|
---|
| 225 |
|
---|
| 226 |
|
---|
| 227 | /**
|
---|
| 228 | * Determine whether @p list_fname contains a line containing @p f.
|
---|
| 229 | * @param f The line to search for.
|
---|
| 230 | * @param list_fname The file to search in.
|
---|
| 231 | * @param preamble Ignore this beginning part of @p f ("" to disable).
|
---|
| 232 | * @return TRUE if it's in the list, FALSE if it's not.
|
---|
| 233 | */
|
---|
[128] | 234 | bool is_file_in_list(char *f, char *list_fname, char *preamble)
|
---|
[1] | 235 | {
|
---|
| 236 |
|
---|
| 237 | /** needs malloc **/
|
---|
[1216] | 238 | char *command = NULL;
|
---|
| 239 | char *file = NULL;
|
---|
| 240 | char *tmp = NULL;
|
---|
| 241 | int res = 0;
|
---|
[1] | 242 |
|
---|
[128] | 243 | assert_string_is_neither_NULL_nor_zerolength(f);
|
---|
| 244 | assert_string_is_neither_NULL_nor_zerolength(list_fname);
|
---|
| 245 | assert(preamble != NULL);
|
---|
[1] | 246 |
|
---|
[128] | 247 | if (strncmp(preamble, f, strlen(preamble)) == 0) {
|
---|
[1216] | 248 | mr_asprintf(&file, f + strlen(preamble));
|
---|
[128] | 249 | } else {
|
---|
[1216] | 250 | mr_asprintf(&file, f);
|
---|
[128] | 251 | }
|
---|
| 252 | if (file[0] == '/' && file[1] == '/') {
|
---|
[1216] | 253 | mr_asprintf(&tmp, file);
|
---|
| 254 | mr_free(file);
|
---|
| 255 | mr_asprintf(&file, tmp + 1);
|
---|
| 256 | mr_free(tmp);
|
---|
[128] | 257 | }
|
---|
[1216] | 258 | mr_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles",
|
---|
[128] | 259 | f, file);
|
---|
[1216] | 260 | mr_asprintf(&command, "grep -E '^%s$' %s", file, list_fname);
|
---|
| 261 | mr_free(file);
|
---|
| 262 |
|
---|
[128] | 263 | res = run_program_and_log_output(command, FALSE);
|
---|
[1080] | 264 | mr_free(command);
|
---|
[128] | 265 | if (res) {
|
---|
| 266 | return (FALSE);
|
---|
| 267 | } else {
|
---|
| 268 | return (TRUE);
|
---|
| 269 | }
|
---|
[1] | 270 | }
|
---|
| 271 | /**************************************************************************
|
---|
| 272 | *END_IS_FILE_IN_LIST *
|
---|
| 273 | **************************************************************************/
|
---|
| 274 |
|
---|
| 275 |
|
---|
| 276 | /**
|
---|
| 277 | * Set up an ISO backup.
|
---|
| 278 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 279 | * - @c bkpinfo->backup_media_type
|
---|
| 280 | * - @c bkpinfo->disaster_recovery
|
---|
| 281 | * - @c bkpinfo->isodir
|
---|
| 282 | * @param nuke_me_please If TRUE, we're in nuke mode; if FALSE we're in interactive mode.
|
---|
| 283 | * @return 0 for success, nonzero for failure.
|
---|
| 284 | */
|
---|
| 285 | int iso_fiddly_bits(struct s_bkpinfo *bkpinfo, bool nuke_me_please)
|
---|
| 286 | {
|
---|
[1216] | 287 | char *mount_isodir_command = NULL;
|
---|
| 288 | char *command = NULL;
|
---|
| 289 | int retval = 0, i = 0;
|
---|
[128] | 290 | bool already_mounted = FALSE;
|
---|
[1] | 291 |
|
---|
[128] | 292 | assert(bkpinfo != NULL);
|
---|
[1216] | 293 |
|
---|
[128] | 294 | g_ISO_restore_mode = TRUE;
|
---|
| 295 | read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
|
---|
| 296 | if (bkpinfo->disaster_recovery) {
|
---|
[1216] | 297 | /* Patch Conor Daly 26-june-2004
|
---|
| 298 | * Don't let this clobber an existing bkpinfo->isodir */
|
---|
| 299 | if (!bkpinfo->isodir) {
|
---|
| 300 | mr_allocstr(bkpinfo->isodir, "/tmp/isodir");
|
---|
[128] | 301 | }
|
---|
[1] | 302 | /* End patch */
|
---|
[1216] | 303 | mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir);
|
---|
[128] | 304 | run_program_and_log_output(command, 5);
|
---|
[1216] | 305 | mr_free(command);
|
---|
[1108] | 306 | mr_msg(2, "Setting isodir to %s", bkpinfo->isodir);
|
---|
[128] | 307 | }
|
---|
[1] | 308 |
|
---|
[128] | 309 | if (!get_isodir_info
|
---|
| 310 | (g_isodir_device, g_isodir_format, bkpinfo->isodir,
|
---|
| 311 | nuke_me_please)) {
|
---|
| 312 | return (1);
|
---|
| 313 | }
|
---|
| 314 | paranoid_system("umount " MNT_CDROM " 2> /dev/null"); /* just in case */
|
---|
[1] | 315 |
|
---|
[128] | 316 | if (is_this_device_mounted(g_isodir_device)) {
|
---|
[1216] | 317 | log_to_screen(_("WARNING - isodir is already mounted"));
|
---|
[128] | 318 | already_mounted = TRUE;
|
---|
| 319 | } else {
|
---|
| 320 | if (strlen(g_isodir_format) > 1) {
|
---|
[1216] | 321 | mr_asprintf(&mount_isodir_command, "mount %s -t %s -o ro %s", g_isodir_device, g_isodir_format, bkpinfo->isodir);
|
---|
| 322 | } else {
|
---|
| 323 | mr_asprintf(&mount_isodir_command, "mount %s -o ro %s", g_isodir_device, bkpinfo->isodir);
|
---|
[128] | 324 | }
|
---|
[691] | 325 | run_program_and_log_output("df -m", FALSE);
|
---|
[1216] | 326 | mr_msg(1, "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?",
|
---|
[128] | 327 | mount_isodir_command);
|
---|
| 328 | if (run_program_and_log_output(mount_isodir_command, FALSE)) {
|
---|
| 329 | popup_and_OK
|
---|
[1216] | 330 | (_
|
---|
| 331 | ("Cannot mount the device where the ISO files are stored."));
|
---|
| 332 | mr_free(mount_isodir_command);
|
---|
[128] | 333 | return (1);
|
---|
| 334 | }
|
---|
[1216] | 335 | mr_free(mount_isodir_command);
|
---|
[128] | 336 | log_to_screen
|
---|
[1216] | 337 | (_
|
---|
| 338 | ("I have mounted the device where the ISO files are stored."));
|
---|
[128] | 339 | }
|
---|
| 340 | if (!IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 341 | mount_cdrom(bkpinfo);
|
---|
| 342 | }
|
---|
| 343 | i = what_number_cd_is_this(bkpinfo); /* has the side-effect of calling mount_cdrom() */
|
---|
[1216] | 344 | mr_msg(1, "%s #%d has been mounted via loopback mount",
|
---|
| 345 | bkpinfo->backup_media_string, i);
|
---|
[128] | 346 | if (i < 0) {
|
---|
| 347 | popup_and_OK
|
---|
[1216] | 348 | (_("Cannot find ISO images in the directory you specified."));
|
---|
[128] | 349 | retval = 1;
|
---|
| 350 | }
|
---|
[1108] | 351 | mr_msg(2, "%ld: bkpinfo->isodir is now %s", __LINE__,
|
---|
[128] | 352 | bkpinfo->isodir);
|
---|
| 353 | return (retval);
|
---|
[1] | 354 | }
|
---|
| 355 |
|
---|
| 356 |
|
---|
| 357 | /**
|
---|
| 358 | * Kill all Petris processes.
|
---|
| 359 | */
|
---|
[128] | 360 | void kill_petris(void)
|
---|
[1] | 361 | {
|
---|
[1216] | 362 | char *command = NULL;
|
---|
| 363 | mr_asprintf(&command,
|
---|
[792] | 364 | "kill `ps 2> /dev/null | grep petris 2> /dev/null | grep -v grep | cut -d' ' -f2` 2> /dev/null");
|
---|
[128] | 365 | paranoid_system(command);
|
---|
[1080] | 366 | mr_free(command);
|
---|
[1] | 367 | }
|
---|
[128] | 368 |
|
---|
[1] | 369 | /**************************************************************************
|
---|
| 370 | *END_KILL_PETRIS *
|
---|
| 371 | **************************************************************************/
|
---|
| 372 |
|
---|
| 373 | /**
|
---|
[1216] | 374 | * Mount @p device at @p mpt as @p format.
|
---|
| 375 | * @param device The device (/dev entry) to mount.
|
---|
| 376 | * @param mpt The directory to mount it on.
|
---|
| 377 | * @param format The filesystem type of @p device.
|
---|
| 378 | * @param writeable If TRUE, mount read-write; if FALSE, mount read-only.
|
---|
[1] | 379 | * @return 0 for success, nonzero for failure.
|
---|
| 380 | */
|
---|
[1216] | 381 | int mount_device(char *device, char *mpt, char *format, bool writeable)
|
---|
[1] | 382 | {
|
---|
[1216] | 383 | int res = 0;
|
---|
[1] | 384 |
|
---|
[1216] | 385 | char *command = NULL;
|
---|
| 386 | char *mountdir = NULL;
|
---|
| 387 | char *mountpoint = NULL;
|
---|
| 388 | char *additional_parameters = NULL;
|
---|
[1219] | 389 |
|
---|
[1216] | 390 | assert_string_is_neither_NULL_nor_zerolength(device);
|
---|
| 391 | assert_string_is_neither_NULL_nor_zerolength(mpt);
|
---|
| 392 | assert(format != NULL);
|
---|
[1] | 393 |
|
---|
[1216] | 394 | if (!strcmp(mpt, "/1")) {
|
---|
| 395 | mr_asprintf(&mountpoint, "/");
|
---|
| 396 | mr_msg(3, "Mommm! SME is being a dildo!");
|
---|
| 397 | } else {
|
---|
| 398 | mr_asprintf(&mountpoint, mpt);
|
---|
| 399 | }
|
---|
[1] | 400 |
|
---|
[1216] | 401 | if (!strcmp(mountpoint, "lvm")) {
|
---|
| 402 | mr_free(mountpoint);
|
---|
| 403 | return (0);
|
---|
| 404 | }
|
---|
| 405 | if (!strcmp(mountpoint, "image")) {
|
---|
| 406 | mr_free(mountpoint);
|
---|
| 407 | return (0);
|
---|
| 408 | }
|
---|
[1219] | 409 | mr_msg(1, "Mounting device %s ", device);
|
---|
[1216] | 410 | if (writeable) {
|
---|
[1219] | 411 | mr_asprintf(&additional_parameters, "-o rw");
|
---|
[1216] | 412 | } else {
|
---|
[1219] | 413 | mr_asprintf(&additional_parameters, "-o ro");
|
---|
[1216] | 414 | }
|
---|
| 415 | if (find_home_of_exe("setfattr")) {
|
---|
[1219] | 416 | mr_strcat(additional_parameters, ",user_xattr");
|
---|
[1216] | 417 | }
|
---|
| 418 | if (find_home_of_exe("setfacl")) {
|
---|
[1219] | 419 | mr_strcat(additional_parameters, ",acl");
|
---|
[1216] | 420 | }
|
---|
[1] | 421 |
|
---|
[1216] | 422 | if (!strcmp(mountpoint, "swap")) {
|
---|
[1219] | 423 | mr_asprintf(&command, "swapon %s", device);
|
---|
[1216] | 424 | } else {
|
---|
| 425 | if (!strcmp(mountpoint, "/")) {
|
---|
[1219] | 426 | mr_asprintf(&mountdir, MNT_RESTORING);
|
---|
[1216] | 427 | } else {
|
---|
[1219] | 428 | mr_asprintf(&mountdir, "%s%s", MNT_RESTORING, mountpoint);
|
---|
[1216] | 429 | }
|
---|
[1219] | 430 | mr_asprintf(&command, "mkdir -p %s", mountdir);
|
---|
[1216] | 431 | run_program_and_log_output(command, FALSE);
|
---|
[1219] | 432 | mr_free(command);
|
---|
| 433 |
|
---|
| 434 | mr_asprintf(&command, "mount -t %s %s %s %s 2>> %s", format, device,
|
---|
[1216] | 435 | additional_parameters, mountdir, MONDO_LOGFILE);
|
---|
| 436 | mr_msg(2, "command='%s'", command);
|
---|
[128] | 437 | }
|
---|
[1219] | 438 | mr_free(additional_parameters);
|
---|
| 439 |
|
---|
[1216] | 440 | res = run_program_and_log_output(command, TRUE);
|
---|
| 441 | if (res && (strstr(command, "xattr") || strstr(command, "acl"))) {
|
---|
| 442 | mr_msg(1, "Re-trying without the fancy extra parameters");
|
---|
[1219] | 443 | mr_free(command);
|
---|
| 444 |
|
---|
| 445 | mr_asprintf(&command, "mount -t %s %s %s 2>> %s", format, device,
|
---|
[1216] | 446 | mountdir, MONDO_LOGFILE);
|
---|
| 447 | res = run_program_and_log_output(command, TRUE);
|
---|
[128] | 448 | }
|
---|
[1216] | 449 | if (res) {
|
---|
| 450 | mr_msg(1, "Unable to mount device %s (type %s) at %s", device,
|
---|
| 451 | format, mountdir);
|
---|
| 452 | mr_msg(1, "command was '%s'", command);
|
---|
| 453 | if (!strcmp(mountpoint, "swap")) {
|
---|
[1219] | 454 | log_to_screen("Unable to mount device %s (type %s) at %s", device,
|
---|
| 455 | format, mountdir);
|
---|
[1216] | 456 | } else {
|
---|
| 457 | mr_msg(2, "Retrying w/o the '-t' switch");
|
---|
[1219] | 458 | mr_free(command);
|
---|
| 459 |
|
---|
| 460 | mr_asprintf(&command, "mount %s %s 2>> %s", device, mountdir,
|
---|
[1216] | 461 | MONDO_LOGFILE);
|
---|
| 462 | mr_msg(2, "2nd command = '%s'", command);
|
---|
| 463 | res = run_program_and_log_output(command, TRUE);
|
---|
| 464 | if (res == 0) {
|
---|
| 465 | mr_msg(1,
|
---|
| 466 | "That's OK. I called mount w/o a filesystem type and it worked fine in the end.");
|
---|
| 467 | }
|
---|
| 468 | }
|
---|
| 469 | }
|
---|
[1219] | 470 | mr_free(command);
|
---|
| 471 | mr_free(mountdir);
|
---|
| 472 |
|
---|
[1216] | 473 | if (res && !strcmp(mountpoint, "swap")) {
|
---|
| 474 | mr_msg(2, "That's ok. It's just a swap partition.");
|
---|
| 475 | mr_msg(2, "Non-fatal error. Returning 0.");
|
---|
| 476 | res = 0;
|
---|
| 477 | }
|
---|
| 478 | mr_free(mountpoint);
|
---|
| 479 |
|
---|
| 480 | return (res);
|
---|
[1] | 481 | }
|
---|
| 482 | /**************************************************************************
|
---|
[1216] | 483 | *END_MOUNT_DEVICE *
|
---|
[1] | 484 | **************************************************************************/
|
---|
| 485 |
|
---|
| 486 |
|
---|
| 487 | /**
|
---|
| 488 | * Mount all devices in @p p_external_copy_of_mountlist on @p MNT_RESTORING.
|
---|
| 489 | * @param p_external_copy_of_mountlist The mountlist containing devices to be mounted.
|
---|
| 490 | * @param writeable If TRUE, then mount read-write; if FALSE mount read-only.
|
---|
| 491 | * @return The number of errors encountered (0 for success).
|
---|
| 492 | */
|
---|
[128] | 493 | int mount_all_devices(struct mountlist_itself
|
---|
| 494 | *p_external_copy_of_mountlist, bool writeable)
|
---|
[1] | 495 | {
|
---|
[1219] | 496 | int retval = 0;
|
---|
| 497 | int lino = 0;
|
---|
| 498 | int res = 0;
|
---|
| 499 | char *tmp = NULL;
|
---|
| 500 | char *these_failed = NULL;
|
---|
| 501 | char *format = NULL;
|
---|
| 502 | struct mountlist_itself *mountlist = NULL;
|
---|
[1] | 503 |
|
---|
[128] | 504 | assert(p_external_copy_of_mountlist != NULL);
|
---|
[1102] | 505 | mountlist = (struct mountlist_itself *)mr_malloc(sizeof(struct mountlist_itself));
|
---|
[128] | 506 | memcpy((void *) mountlist, (void *) p_external_copy_of_mountlist,
|
---|
| 507 | sizeof(struct mountlist_itself));
|
---|
| 508 | sort_mountlist_by_mountpoint(mountlist, 0);
|
---|
[1] | 509 |
|
---|
[1219] | 510 | mvaddstr_and_log_it(g_currentY, 0, _("Mounting devices "));
|
---|
| 511 | open_progress_form(_("Mounting devices"),
|
---|
| 512 | _("I am now mounting all the drives."),
|
---|
| 513 | _("This should not take long."),
|
---|
[128] | 514 | "", mountlist->entries);
|
---|
| 515 |
|
---|
| 516 | for (lino = 0; lino < mountlist->entries; lino++) {
|
---|
| 517 | if (!strcmp(mountlist->el[lino].device, "/proc")) {
|
---|
[1108] | 518 | mr_msg(1,
|
---|
[128] | 519 | "Again with the /proc - why is this in your mountlist?");
|
---|
| 520 | } else if (is_this_device_mounted(mountlist->el[lino].device)) {
|
---|
[1219] | 521 | log_to_screen(_("%s is already mounted"),
|
---|
[128] | 522 | mountlist->el[lino].device);
|
---|
| 523 | } else if (strcmp(mountlist->el[lino].mountpoint, "none")
|
---|
| 524 | && strcmp(mountlist->el[lino].mountpoint, "lvm")
|
---|
| 525 | && strcmp(mountlist->el[lino].mountpoint, "raid")
|
---|
| 526 | && strcmp(mountlist->el[lino].mountpoint, "image")) {
|
---|
[1219] | 527 | mr_asprintf(&tmp, "Mounting %s", mountlist->el[lino].device);
|
---|
[128] | 528 | update_progress_form(tmp);
|
---|
[1219] | 529 | mr_free(tmp);
|
---|
| 530 |
|
---|
| 531 | mr_asprintf(&format, mountlist->el[lino].format);
|
---|
[128] | 532 | if (!strcmp(format, "ext3")) {
|
---|
[1219] | 533 | mr_free(format);
|
---|
| 534 | mr_asprintf(&format, "ext2");
|
---|
[128] | 535 | }
|
---|
| 536 | res = mount_device(mountlist->el[lino].device,
|
---|
| 537 | mountlist->el[lino].mountpoint,
|
---|
| 538 | format, writeable);
|
---|
| 539 | retval += res;
|
---|
| 540 | if (res) {
|
---|
[1219] | 541 | if (these_failed != NULL) { /* not the first time */
|
---|
| 542 | mr_strcat(these_failed, " %s", mountlist->el[lino].device);
|
---|
| 543 | } else { /* The first time */
|
---|
| 544 | mr_asprintf(&these_failed, "%s", mountlist->el[lino].device);
|
---|
| 545 | }
|
---|
[128] | 546 | }
|
---|
[1219] | 547 | mr_free(format);
|
---|
[128] | 548 | }
|
---|
| 549 | g_current_progress++;
|
---|
[1] | 550 | }
|
---|
[128] | 551 | close_progress_form();
|
---|
[691] | 552 | run_program_and_log_output("df -m", TRUE);
|
---|
[128] | 553 | if (retval) {
|
---|
| 554 | if (g_partition_table_locked_up > 0) {
|
---|
| 555 | log_to_screen
|
---|
[1219] | 556 | (_
|
---|
| 557 | ("fdisk's ioctl() call to refresh its copy of the partition table causes the kernel to"));
|
---|
| 558 | log_to_screen(_
|
---|
| 559 | ("lock up the partition table. You might have to reboot and use Interactive Mode to"));
|
---|
| 560 | log_to_screen(_
|
---|
| 561 | ("format and restore *without* partitioning first. Sorry for the inconvenience."));
|
---|
[128] | 562 | }
|
---|
[1219] | 563 | mr_asprintf(&tmp, _("Could not mount devices %s- shall I abort?"),
|
---|
[128] | 564 | these_failed);
|
---|
[1219] | 565 | mr_free(these_failed);
|
---|
| 566 |
|
---|
[128] | 567 | if (!ask_me_yes_or_no(tmp)) {
|
---|
| 568 | retval = 0;
|
---|
| 569 | log_to_screen
|
---|
[1219] | 570 | (_
|
---|
| 571 | ("Continuing, although some devices failed to be mounted"));
|
---|
| 572 | mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
|
---|
[128] | 573 | } else {
|
---|
[1219] | 574 | mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
|
---|
[128] | 575 | log_to_screen
|
---|
[1219] | 576 | (_("Unable to mount some or all of your partitions."));
|
---|
[128] | 577 | }
|
---|
[1219] | 578 | mr_free(tmp);
|
---|
[128] | 579 | } else {
|
---|
[1219] | 580 | log_to_screen(_("All partitions were mounted OK."));
|
---|
| 581 | mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
|
---|
[1] | 582 | }
|
---|
[691] | 583 | run_program_and_log_output("df -m", 3);
|
---|
[1124] | 584 | mr_free(mountlist);
|
---|
[128] | 585 | return (retval);
|
---|
[1] | 586 | }
|
---|
| 587 | /**************************************************************************
|
---|
| 588 | *END_MOUNT_ALL_DEVICES *
|
---|
| 589 | **************************************************************************/
|
---|
| 590 |
|
---|
| 591 |
|
---|
| 592 | /**
|
---|
| 593 | * Mount the CD-ROM device at /mnt/cdrom.
|
---|
| 594 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 595 | * - @c bkpinfo->backup_media_type
|
---|
| 596 | * - @c bkpinfo->disaster_recovery
|
---|
| 597 | * - @c bkpinfo->isodir
|
---|
| 598 | * - @c bkpinfo->media_device
|
---|
| 599 | * @return 0 for success, nonzero for failure.
|
---|
| 600 | */
|
---|
| 601 | int mount_cdrom(struct s_bkpinfo *bkpinfo)
|
---|
| 602 | {
|
---|
[1219] | 603 | char *mount_cmd = NULL;
|
---|
| 604 | int i = 0, res = 0;
|
---|
[1] | 605 | #ifdef __FreeBSD__
|
---|
[1219] | 606 | char *mddev = NULL;
|
---|
[1] | 607 | #endif
|
---|
| 608 |
|
---|
[128] | 609 | assert(bkpinfo != NULL);
|
---|
[1] | 610 |
|
---|
[128] | 611 | if (bkpinfo->backup_media_type == tape
|
---|
| 612 | || bkpinfo->backup_media_type == udev) {
|
---|
[1108] | 613 | mr_msg(8, "Tape/udev. Therefore, no need to mount CDROM.");
|
---|
[128] | 614 | return 0;
|
---|
| 615 | }
|
---|
[1] | 616 |
|
---|
[681] | 617 | if (!run_program_and_log_output("mount | grep -F " MNT_CDROM, FALSE)) {
|
---|
[1108] | 618 | mr_msg(2, "mount_cdrom() - CD already mounted. Fair enough.");
|
---|
[128] | 619 | return (0);
|
---|
[1] | 620 | }
|
---|
| 621 |
|
---|
[128] | 622 | if (bkpinfo->backup_media_type == nfs) {
|
---|
[1108] | 623 | mr_msg(2, "Mounting for NFS thingy");
|
---|
| 624 | mr_msg(2, "isodir = %s", bkpinfo->isodir);
|
---|
[128] | 625 | if ((!bkpinfo->isodir[0] || !strcmp(bkpinfo->isodir, "/"))
|
---|
| 626 | && am_I_in_disaster_recovery_mode()) {
|
---|
| 627 | strcpy(bkpinfo->isodir, "/tmp/isodir");
|
---|
[1108] | 628 | mr_msg(1, "isodir is being set to %s", bkpinfo->isodir);
|
---|
[128] | 629 | }
|
---|
[1] | 630 | #ifdef __FreeBSD__
|
---|
[1219] | 631 | mr_asprintf(&mount_cmd, "/mnt/isodir/%s/%s/%s-%d.iso", bkpinfo->isodir,
|
---|
| 632 | bkpinfo->nfs_remote_dir, bkpinfo->prefix,
|
---|
| 633 | g_current_media_number);
|
---|
[128] | 634 | mddev = make_vn(mount_cmd);
|
---|
[1219] | 635 | mr_free(mount_cmd);
|
---|
| 636 |
|
---|
| 637 | mr_asprintf(&mount_cmd, "mount_cd9660 -r %s " MNT_CDROM, mddev);
|
---|
| 638 | mr_free(mddev);
|
---|
[1] | 639 | #else
|
---|
[1219] | 640 | mr_asprintf(&mount_cmd,
|
---|
| 641 | "mount %s/%s/%s-%d.iso -t iso9660 -o loop,ro %s",
|
---|
| 642 | bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix,
|
---|
| 643 | g_current_media_number, MNT_CDROM);
|
---|
[1] | 644 | #endif
|
---|
| 645 |
|
---|
[1219] | 646 | } else if (bkpinfo->backup_media_type == iso) {
|
---|
[1] | 647 | #ifdef __FreeBSD__
|
---|
[1219] | 648 | mr_asprintf(&mount_cmd, "%s/%s-%d.iso", bkpinfo->isodir,
|
---|
[148] | 649 | bkpinfo->prefix, g_current_media_number);
|
---|
[128] | 650 | mddev = make_vn(mount_cmd);
|
---|
[1219] | 651 | mr_free(mount_cmd);
|
---|
| 652 |
|
---|
| 653 | mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", mddev, MNT_CDROM);
|
---|
| 654 | mr_free(mddev);
|
---|
[1] | 655 | #else
|
---|
[1219] | 656 | mr_asprintf(&mount_cmd, "mount %s/%s-%d.iso -t iso9660 -o loop,ro %s",
|
---|
| 657 | bkpinfo->isodir, bkpinfo->prefix, g_current_media_number,
|
---|
| 658 | MNT_CDROM);
|
---|
[1] | 659 | #endif
|
---|
[128] | 660 | } else if (strstr(bkpinfo->media_device, "/dev/"))
|
---|
[1] | 661 | #ifdef __FreeBSD__
|
---|
[128] | 662 | {
|
---|
[1219] | 663 | mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
|
---|
[128] | 664 | MNT_CDROM);
|
---|
| 665 | }
|
---|
[1] | 666 | #else
|
---|
[128] | 667 | {
|
---|
[1219] | 668 | mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",
|
---|
[128] | 669 | bkpinfo->media_device, MNT_CDROM);
|
---|
| 670 | }
|
---|
[1] | 671 | #endif
|
---|
| 672 |
|
---|
[128] | 673 | else {
|
---|
| 674 | if (bkpinfo->disaster_recovery
|
---|
| 675 | && does_file_exist("/tmp/CDROM-LIVES-HERE")) {
|
---|
[1594] | 676 | mr_allocstr(bkpinfo->media_device,
|
---|
[128] | 677 | last_line_of_file("/tmp/CDROM-LIVES-HERE"));
|
---|
| 678 | }
|
---|
[1] | 679 |
|
---|
| 680 | #ifdef __FreeBSD__
|
---|
[1219] | 681 | mr_asprintf(&mount_cmd, "mount_cd9660 -r %s %s", bkpinfo->media_device,
|
---|
[128] | 682 | MNT_CDROM);
|
---|
[1] | 683 | #else
|
---|
[1219] | 684 | mr_asprintf(&mount_cmd, "mount %s -t iso9660 -o ro %s",
|
---|
[128] | 685 | bkpinfo->media_device, MNT_CDROM);
|
---|
[1] | 686 | #endif
|
---|
| 687 |
|
---|
| 688 | }
|
---|
[1108] | 689 | mr_msg(2, "(mount_cdrom) --- command = %s", mount_cmd);
|
---|
[128] | 690 | for (i = 0; i < 2; i++) {
|
---|
| 691 | res = run_program_and_log_output(mount_cmd, FALSE);
|
---|
| 692 | if (!res) {
|
---|
| 693 | break;
|
---|
| 694 | } else {
|
---|
[1108] | 695 | mr_msg(2, "Failed to mount CD-ROM drive.");
|
---|
[128] | 696 | sleep(5);
|
---|
| 697 | run_program_and_log_output("sync", FALSE);
|
---|
| 698 | }
|
---|
[1] | 699 | }
|
---|
[1219] | 700 | mr_free(mount_cmd);
|
---|
| 701 |
|
---|
[128] | 702 | if (res) {
|
---|
[1108] | 703 | mr_msg(2, "Failed, despite %d attempts", i);
|
---|
[128] | 704 | } else {
|
---|
[1108] | 705 | mr_msg(2, "Mounted CD-ROM drive OK");
|
---|
[128] | 706 | }
|
---|
| 707 | return (res);
|
---|
[1] | 708 | }
|
---|
| 709 | /**************************************************************************
|
---|
| 710 | *END_MOUNT_CDROM *
|
---|
| 711 | **************************************************************************/
|
---|
| 712 |
|
---|
| 713 |
|
---|
| 714 | /**
|
---|
| 715 | * Fix some miscellaneous things in the filesystem so the system will come
|
---|
| 716 | * up correctly on the first boot.
|
---|
| 717 | */
|
---|
[128] | 718 | void protect_against_braindead_sysadmins()
|
---|
[1] | 719 | {
|
---|
[128] | 720 | run_program_and_log_output("touch " MNT_RESTORING "/var/log/pacct",
|
---|
| 721 | FALSE);
|
---|
| 722 | run_program_and_log_output("touch " MNT_RESTORING "/var/account/pacct",
|
---|
| 723 | FALSE);
|
---|
| 724 | if (run_program_and_log_output("ls " MNT_RESTORING " /tmp", FALSE)) {
|
---|
[1594] | 725 | chmod(MNT_RESTORING "/tmp",1777 );
|
---|
[128] | 726 | }
|
---|
| 727 | run_program_and_log_output("mkdir -p " MNT_RESTORING
|
---|
| 728 | "/var/run/console", FALSE);
|
---|
[1594] | 729 | chmod(MNT_RESTORING "/dev/null",0777);
|
---|
[128] | 730 | run_program_and_log_output("cd " MNT_RESTORING
|
---|
[691] | 731 | "; for i in `ls home/`; do echo \"Moving $i's spurious files to $i/.disabled\"; mkdir \"$i\"/.disabled ; mv -f \"$i\"/.DCOP* \"$i\"/.MCOP* \"$i\"/.*authority \"$i\"/.kde/tmp* \"$i\"/.kde/socket* \"$i\"/.disabled/ ; done",
|
---|
[128] | 732 | TRUE);
|
---|
| 733 | run_program_and_log_output("rm -f " MNT_RESTORING "/var/run/*.pid",
|
---|
| 734 | TRUE);
|
---|
| 735 | run_program_and_log_output("rm -f " MNT_RESTORING "/var/lock/subsys/*",
|
---|
| 736 | TRUE);
|
---|
[1] | 737 | }
|
---|
| 738 | /**************************************************************************
|
---|
| 739 | *END_PROTECT_AGAINST_BRAINDEAD_SYSADMINS *
|
---|
| 740 | **************************************************************************/
|
---|
| 741 |
|
---|
| 742 |
|
---|
| 743 | /**
|
---|
| 744 | * Fill out @p bkpinfo based on @p cfg_file.
|
---|
| 745 | * @param cfg_file The mondo-restore.cfg file to read into @p bkpinfo.
|
---|
| 746 | * @param bkpinfo The backup information structure to fill out with information
|
---|
| 747 | * from @p cfg_file.
|
---|
| 748 | * @return 0 for success, nonzero for failure.
|
---|
| 749 | */
|
---|
[128] | 750 | int read_cfg_file_into_bkpinfo(char *cfgf, struct s_bkpinfo *bkpinfo)
|
---|
[1] | 751 | {
|
---|
[870] | 752 | char *value = NULL;
|
---|
| 753 | char *tmp = NULL;
|
---|
[873] | 754 | char *envtmp1 = NULL;
|
---|
| 755 | char *envtmp2 = NULL;
|
---|
[870] | 756 | char *command = NULL;
|
---|
| 757 | char *iso_mnt = NULL;
|
---|
| 758 | char *iso_path = NULL;
|
---|
| 759 | char *old_isodir = NULL;
|
---|
[1219] | 760 | char *cfg_file = NULL;
|
---|
[128] | 761 | t_bkptype media_specified_by_user;
|
---|
[1] | 762 |
|
---|
[128] | 763 | malloc_string(value);
|
---|
| 764 | assert(bkpinfo != NULL);
|
---|
[1] | 765 |
|
---|
[128] | 766 | if (!cfgf) {
|
---|
[1219] | 767 | cfg_file = g_mondo_cfg_file;
|
---|
[128] | 768 | } else {
|
---|
[1219] | 769 | cfg_file = cfgf;
|
---|
[128] | 770 | }
|
---|
[1] | 771 |
|
---|
[128] | 772 | media_specified_by_user = bkpinfo->backup_media_type; // or 'none', if not specified
|
---|
[1] | 773 |
|
---|
[128] | 774 | if (0 == read_cfg_var(cfg_file, "backup-media-type", value)) {
|
---|
| 775 | if (!strcmp(value, "cdstream")) {
|
---|
| 776 | bkpinfo->backup_media_type = cdstream;
|
---|
| 777 | } else if (!strcmp(value, "cdr")) {
|
---|
| 778 | bkpinfo->backup_media_type = cdr;
|
---|
| 779 | } else if (!strcmp(value, "cdrw")) {
|
---|
| 780 | bkpinfo->backup_media_type = cdrw;
|
---|
| 781 | } else if (!strcmp(value, "dvd")) {
|
---|
| 782 | bkpinfo->backup_media_type = dvd;
|
---|
| 783 | } else if (!strcmp(value, "iso")) {
|
---|
[1219] | 784 | // Patch by Conor Daly - 2004/07/12
|
---|
[128] | 785 | bkpinfo->backup_media_type = iso;
|
---|
| 786 | if (am_I_in_disaster_recovery_mode()) {
|
---|
| 787 | /* Check to see if CD is already mounted before mounting it... */
|
---|
| 788 | if (!is_this_device_mounted("/dev/cdrom")) {
|
---|
[1108] | 789 | mr_msg(2,
|
---|
[128] | 790 | "NB: CDROM device not mounted, mounting...");
|
---|
| 791 | run_program_and_log_output("mount /dev/cdrom "
|
---|
| 792 | MNT_CDROM, 1);
|
---|
| 793 | }
|
---|
[253] | 794 | if (does_file_exist(MNT_CDROM "/archives/filelist.0")) {
|
---|
[128] | 795 | bkpinfo->backup_media_type = cdr;
|
---|
| 796 | run_program_and_log_output("umount " MNT_CDROM, 1);
|
---|
| 797 | log_it
|
---|
| 798 | ("Re-jigging configuration AGAIN. CD-R, not ISO.");
|
---|
| 799 | }
|
---|
[253] | 800 | }
|
---|
[251] | 801 | if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) {
|
---|
| 802 | strcpy(bkpinfo->prefix,value);
|
---|
| 803 | } else {
|
---|
| 804 | strcpy(bkpinfo->prefix,STD_PREFIX);
|
---|
[128] | 805 | }
|
---|
| 806 | } else if (!strcmp(value, "nfs")) {
|
---|
| 807 | bkpinfo->backup_media_type = nfs;
|
---|
[148] | 808 | if (read_cfg_var(cfg_file, "iso-prefix", value) == 0) {
|
---|
| 809 | strcpy(bkpinfo->prefix,value);
|
---|
| 810 | } else {
|
---|
| 811 | strcpy(bkpinfo->prefix,STD_PREFIX);
|
---|
| 812 | }
|
---|
[801] | 813 | if (strstr(call_program_and_get_last_line_of_output
|
---|
| 814 | ("cat /proc/cmdline"), "pxe")) {
|
---|
[913] | 815 | /* We need to override prefix value in PXE mode as it's
|
---|
| 816 | * already done in start-nfs */
|
---|
| 817 | envtmp1 = getenv("imgname");
|
---|
| 818 | if (envtmp1 == NULL) {
|
---|
| 819 | fatal_error("no imgname variable in environment");
|
---|
| 820 | }
|
---|
| 821 | strcpy(bkpinfo->prefix,envtmp1);
|
---|
[801] | 822 | }
|
---|
| 823 |
|
---|
[128] | 824 | } else if (!strcmp(value, "tape")) {
|
---|
| 825 | bkpinfo->backup_media_type = tape;
|
---|
| 826 | } else if (!strcmp(value, "udev")) {
|
---|
| 827 | bkpinfo->backup_media_type = udev;
|
---|
| 828 | } else {
|
---|
| 829 | fatal_error("UNKNOWN bkp-media-type");
|
---|
| 830 | }
|
---|
| 831 | } else {
|
---|
| 832 | fatal_error("backup-media-type not specified!");
|
---|
[1] | 833 | }
|
---|
[128] | 834 | if (bkpinfo->disaster_recovery) {
|
---|
| 835 | if (bkpinfo->backup_media_type == cdstream) {
|
---|
[1594] | 836 | mr_allocstr(bkpinfo->media_device, "/dev/cdrom");
|
---|
[1376] | 837 | bkpinfo->media_size = (long)650; /* good guess */
|
---|
[128] | 838 | } else if (bkpinfo->backup_media_type == tape
|
---|
| 839 | || bkpinfo->backup_media_type == udev) {
|
---|
| 840 | if (read_cfg_var(cfg_file, "media-dev", value)) {
|
---|
| 841 | fatal_error("Cannot get tape device name from cfg file");
|
---|
| 842 | }
|
---|
[1594] | 843 | mr_allocstr(bkpinfo->media_device, value);
|
---|
[128] | 844 | read_cfg_var(cfg_file, "media-size", value);
|
---|
[1376] | 845 | bkpinfo->media_size = atol(value);
|
---|
[1219] | 846 | mr_msg(2, "Backup medium is TAPE --- dev=%s",
|
---|
[128] | 847 | bkpinfo->media_device);
|
---|
| 848 | } else {
|
---|
[1594] | 849 | mr_allocstr(bkpinfo->media_device, "/dev/cdrom"); /* we don't really need this var */
|
---|
[1384] | 850 | bkpinfo->media_size = (long)1999*1024; /* 650, probably, but we don't need this var anyway */
|
---|
[1108] | 851 | mr_msg(2, "Backup medium is CD-R[W]");
|
---|
[128] | 852 | }
|
---|
| 853 | } else {
|
---|
[1108] | 854 | mr_msg(2,
|
---|
[128] | 855 | "Not in Disaster Recovery Mode. No need to derive device name from config file.");
|
---|
[1] | 856 | }
|
---|
[128] | 857 |
|
---|
| 858 | read_cfg_var(cfg_file, "use-star", value);
|
---|
| 859 | if (strstr(value, "yes")) {
|
---|
| 860 | bkpinfo->use_star = TRUE;
|
---|
[1108] | 861 | mr_msg(1, "Goody! ... bkpinfo->use_star is now true.");
|
---|
[1] | 862 | }
|
---|
[128] | 863 |
|
---|
[949] | 864 | read_cfg_var(cfg_file, "acl", value);
|
---|
[1087] | 865 | if (strstr(value, "yes")) {
|
---|
[1080] | 866 | mr_asprintf(&g_getfacl,"setfacl");
|
---|
[1108] | 867 | mr_msg(1, "We will restore ACLs");
|
---|
[951] | 868 | if (! find_home_of_exe("setfacl")) {
|
---|
[1108] | 869 | mr_msg(1, "Unable to restore ACLs as no setfacl found");
|
---|
[949] | 870 | }
|
---|
| 871 | }
|
---|
| 872 | read_cfg_var(cfg_file, "xattr", value);
|
---|
[1087] | 873 | if (strstr(value, "yes")) {
|
---|
[1080] | 874 | mr_asprintf(&g_getfattr,"setfattr");
|
---|
[1108] | 875 | mr_msg(1, "We will restore XATTRs");
|
---|
[951] | 876 | if (! find_home_of_exe("setfattr")) {
|
---|
[1108] | 877 | mr_msg(1, "Unable to restore XATTRs as no setfattr found");
|
---|
[949] | 878 | }
|
---|
| 879 | }
|
---|
| 880 |
|
---|
[128] | 881 | if (0 == read_cfg_var(cfg_file, "internal-tape-block-size", value)) {
|
---|
| 882 | bkpinfo->internal_tape_block_size = atol(value);
|
---|
[1108] | 883 | mr_msg(1, "Internal tape block size has been custom-set to %ld",
|
---|
[128] | 884 | bkpinfo->internal_tape_block_size);
|
---|
| 885 | } else {
|
---|
| 886 | bkpinfo->internal_tape_block_size =
|
---|
| 887 | DEFAULT_INTERNAL_TAPE_BLOCK_SIZE;
|
---|
[1108] | 888 | mr_msg(1, "Internal tape block size = default (%ld)",
|
---|
[128] | 889 | DEFAULT_INTERNAL_TAPE_BLOCK_SIZE);
|
---|
[1] | 890 | }
|
---|
[128] | 891 |
|
---|
| 892 | read_cfg_var(cfg_file, "use-lzo", value);
|
---|
| 893 | if (strstr(value, "yes")) {
|
---|
| 894 | bkpinfo->use_lzo = TRUE;
|
---|
[998] | 895 | bkpinfo->use_gzip = FALSE;
|
---|
[128] | 896 | strcpy(bkpinfo->zip_exe, "lzop");
|
---|
| 897 | strcpy(bkpinfo->zip_suffix, "lzo");
|
---|
| 898 | } else {
|
---|
[998] | 899 | read_cfg_var(cfg_file, "use-gzip", value);
|
---|
[128] | 900 | if (strstr(value, "yes")) {
|
---|
| 901 | bkpinfo->use_lzo = FALSE;
|
---|
[998] | 902 | bkpinfo->use_gzip = TRUE;
|
---|
| 903 | strcpy(bkpinfo->zip_exe, "gzip");
|
---|
| 904 | strcpy(bkpinfo->zip_suffix, "gz");
|
---|
[128] | 905 | } else {
|
---|
[998] | 906 | read_cfg_var(cfg_file, "use-comp", value);
|
---|
| 907 | if (strstr(value, "yes")) {
|
---|
| 908 | bkpinfo->use_lzo = FALSE;
|
---|
| 909 | bkpinfo->use_gzip = FALSE;
|
---|
| 910 | strcpy(bkpinfo->zip_exe, "bzip2");
|
---|
| 911 | strcpy(bkpinfo->zip_suffix, "bz2");
|
---|
| 912 | } else {
|
---|
| 913 | bkpinfo->zip_exe[0] = bkpinfo->zip_suffix[0] = '\0';
|
---|
| 914 | }
|
---|
[128] | 915 | }
|
---|
[1] | 916 | }
|
---|
| 917 |
|
---|
[128] | 918 | value[0] = '\0';
|
---|
| 919 | read_cfg_var(cfg_file, "differential", value);
|
---|
| 920 | if (!strcmp(value, "yes") || !strcmp(value, "1")) {
|
---|
| 921 | bkpinfo->differential = TRUE;
|
---|
[1] | 922 | }
|
---|
[1108] | 923 | mr_msg(2, "differential var = '%s'", value);
|
---|
[128] | 924 | if (bkpinfo->differential) {
|
---|
[1108] | 925 | mr_msg(2, "THIS IS A DIFFERENTIAL BACKUP");
|
---|
[128] | 926 | } else {
|
---|
[1108] | 927 | mr_msg(2, "This is a regular (full) backup");
|
---|
[1] | 928 | }
|
---|
| 929 |
|
---|
[128] | 930 | read_cfg_var(g_mondo_cfg_file, "please-dont-eject", tmp);
|
---|
| 931 | if (tmp[0]
|
---|
| 932 | ||
|
---|
| 933 | strstr(call_program_and_get_last_line_of_output
|
---|
| 934 | ("cat /proc/cmdline"), "donteject")) {
|
---|
| 935 | bkpinfo->please_dont_eject = TRUE;
|
---|
[1108] | 936 | mr_msg(2, "Ok, I shan't eject when restoring! Groovy.");
|
---|
[128] | 937 | }
|
---|
[1] | 938 |
|
---|
[128] | 939 | if (bkpinfo->backup_media_type == nfs) {
|
---|
| 940 | if (!cfgf) {
|
---|
[1108] | 941 | mr_msg(2, "nfs_mount remains %s", bkpinfo->nfs_mount);
|
---|
| 942 | mr_msg(2, "nfs_remote_dir remains %s",
|
---|
[128] | 943 | bkpinfo->nfs_remote_dir);
|
---|
[1108] | 944 | mr_msg(2,
|
---|
[128] | 945 | "...cos it wouldn't make sense to abandon the values that GOT ME to this config file in the first place");
|
---|
| 946 | } else {
|
---|
| 947 | read_cfg_var(g_mondo_cfg_file, "nfs-server-mount",
|
---|
| 948 | bkpinfo->nfs_mount);
|
---|
| 949 | read_cfg_var(g_mondo_cfg_file, "nfs-server-path",
|
---|
| 950 | bkpinfo->nfs_remote_dir);
|
---|
[1108] | 951 | mr_msg(2, "nfs_mount is %s", bkpinfo->nfs_mount);
|
---|
| 952 | mr_msg(2, "nfs_remote_dir is %s", bkpinfo->nfs_remote_dir);
|
---|
[128] | 953 | }
|
---|
[801] | 954 | if (strstr(call_program_and_get_last_line_of_output
|
---|
| 955 | ("cat /proc/cmdline"), "pxe")) {
|
---|
[913] | 956 | /* We need to override values in PXE mode as it's
|
---|
| 957 | * already done in start-nfs */
|
---|
| 958 | envtmp1 = getenv("nfsmount");
|
---|
| 959 | if (envtmp1 == NULL) {
|
---|
| 960 | fatal_error("no nfsmount variable in environment");
|
---|
[801] | 961 | }
|
---|
[913] | 962 | envtmp2 = getenv("dirimg");
|
---|
| 963 | if (envtmp2 == NULL) {
|
---|
| 964 | fatal_error("no dirimg variable in environment");
|
---|
| 965 | }
|
---|
| 966 | strcpy(bkpinfo->nfs_mount,envtmp1);
|
---|
| 967 | strcpy(bkpinfo->nfs_remote_dir,envtmp2);
|
---|
| 968 | }
|
---|
[128] | 969 | } else if (bkpinfo->backup_media_type == iso) {
|
---|
| 970 | /* Patch by Conor Daly 23-june-2004
|
---|
| 971 | * to correctly mount iso-dev and set a sensible
|
---|
| 972 | * isodir in disaster recovery mode
|
---|
| 973 | */
|
---|
[1219] | 974 | mr_asprintf(&old_isodir, bkpinfo->isodir);
|
---|
[128] | 975 | read_cfg_var(g_mondo_cfg_file, "iso-mnt", iso_mnt);
|
---|
| 976 | read_cfg_var(g_mondo_cfg_file, "isodir", iso_path);
|
---|
| 977 | sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
|
---|
| 978 | if (!bkpinfo->isodir[0]) {
|
---|
| 979 | strcpy(bkpinfo->isodir, old_isodir);
|
---|
| 980 | }
|
---|
| 981 | if (!bkpinfo->disaster_recovery) {
|
---|
| 982 | if (strcmp(old_isodir, bkpinfo->isodir)) {
|
---|
| 983 | log_it
|
---|
| 984 | ("user nominated isodir differs from archive, keeping user's choice: %s %s\n",
|
---|
| 985 | old_isodir, bkpinfo->isodir);
|
---|
| 986 | strcpy(bkpinfo->isodir, old_isodir);
|
---|
| 987 | }
|
---|
| 988 | }
|
---|
[1219] | 989 | mr_free(old_isodir);
|
---|
| 990 |
|
---|
[128] | 991 | read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device);
|
---|
[1219] | 992 | mr_msg(2, "isodir=%s; iso-dev=%s", bkpinfo->isodir, g_isodir_device);
|
---|
[128] | 993 | if (bkpinfo->disaster_recovery) {
|
---|
| 994 | if (is_this_device_mounted(g_isodir_device)) {
|
---|
[1108] | 995 | mr_msg(2, "NB: isodir is already mounted");
|
---|
[128] | 996 | /* Find out where it's mounted */
|
---|
[1219] | 997 | mr_asprintf(&command,
|
---|
[909] | 998 | "mount | grep -E '^%s' | tail -n1 | cut -d' ' -f3",
|
---|
[128] | 999 | g_isodir_device);
|
---|
| 1000 | log_it("command = %s", command);
|
---|
[1219] | 1001 | mr_asprintf(&iso_mnt, "%s",
|
---|
[128] | 1002 | call_program_and_get_last_line_of_output(command));
|
---|
[1219] | 1003 | log_it("res of it = %s", iso_mnt);
|
---|
[128] | 1004 | } else {
|
---|
[1219] | 1005 | mr_asprintf(&iso_mnt, "/tmp/isodir");
|
---|
| 1006 | mr_asprintf(&tmp, "mkdir -p %s", iso_mnt);
|
---|
[128] | 1007 | run_program_and_log_output(tmp, 5);
|
---|
[1219] | 1008 | mr_free(tmp);
|
---|
| 1009 |
|
---|
| 1010 | mr_asprintf(&tmp, "mount %s %s", g_isodir_device, iso_mnt);
|
---|
[128] | 1011 | if (run_program_and_log_output(tmp, 3)) {
|
---|
[1108] | 1012 | mr_msg(1,
|
---|
[128] | 1013 | "Unable to mount isodir. Perhaps this is really a CD backup?");
|
---|
| 1014 | bkpinfo->backup_media_type = cdr;
|
---|
[1594] | 1015 | mr_allocstr(bkpinfo->media_device, "/dev/cdrom"); /* superfluous */
|
---|
[1219] | 1016 | bkpinfo->isodir[0] = '\0';
|
---|
| 1017 | mr_free(iso_mnt);
|
---|
| 1018 | mr_free(iso_path);
|
---|
| 1019 | mr_asprintf(&iso_mnt, "");
|
---|
| 1020 | mr_asprintf(&iso_path, "");
|
---|
[128] | 1021 | if (mount_cdrom(bkpinfo)) {
|
---|
| 1022 | fatal_error
|
---|
| 1023 | ("Unable to mount isodir. Failed to mount CD-ROM as well.");
|
---|
| 1024 | } else {
|
---|
[1108] | 1025 | mr_msg(1,
|
---|
[801] | 1026 | "You backed up to disk, then burned some CDs.");
|
---|
[128] | 1027 | }
|
---|
| 1028 | }
|
---|
[1219] | 1029 | mr_free(tmp);
|
---|
[128] | 1030 | }
|
---|
[148] | 1031 | /* bkpinfo->isodir should now be the true path to prefix-1.iso etc... */
|
---|
[128] | 1032 | if (bkpinfo->backup_media_type == iso) {
|
---|
| 1033 | sprintf(bkpinfo->isodir, "%s%s", iso_mnt, iso_path);
|
---|
| 1034 | }
|
---|
[1219] | 1035 | mr_free(iso_mnt);
|
---|
| 1036 | mr_free(iso_path);
|
---|
[128] | 1037 | }
|
---|
[1] | 1038 | }
|
---|
| 1039 |
|
---|
[128] | 1040 | if (media_specified_by_user != none) {
|
---|
| 1041 | if (g_restoring_live_from_cd) {
|
---|
| 1042 | if (bkpinfo->backup_media_type != media_specified_by_user) {
|
---|
[1108] | 1043 | mr_msg(2,
|
---|
[128] | 1044 | "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)");
|
---|
[1219] | 1045 | interactively_obtain_media_parameters_from_user(bkpinfo, FALSE);
|
---|
[128] | 1046 | media_specified_by_user = bkpinfo->backup_media_type;
|
---|
| 1047 | get_cfg_file_from_archive(bkpinfo);
|
---|
| 1048 | }
|
---|
| 1049 | }
|
---|
| 1050 | bkpinfo->backup_media_type = media_specified_by_user;
|
---|
| 1051 | }
|
---|
| 1052 | g_backup_media_type = bkpinfo->backup_media_type;
|
---|
[1219] | 1053 | strcpy(bkpinfo->backup_media_string, bkptype_to_string(bkpinfo->backup_media_type));
|
---|
| 1054 | strcpy(g_backup_media_string, bkpinfo->backup_media_string);
|
---|
[1080] | 1055 | mr_free(value);
|
---|
[128] | 1056 | return (0);
|
---|
[1] | 1057 | }
|
---|
| 1058 | /**************************************************************************
|
---|
| 1059 | *END_READ_CFG_FILE_INTO_BKPINFO *
|
---|
| 1060 | **************************************************************************/
|
---|
| 1061 |
|
---|
| 1062 |
|
---|
| 1063 | /**
|
---|
| 1064 | * Allow the user to edit the filelist and biggielist.
|
---|
| 1065 | * The filelist is unlinked after it is read.
|
---|
| 1066 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 1067 | * - @c bkpinfo->backup_media_type
|
---|
| 1068 | * - @c bkpinfo->isodir
|
---|
| 1069 | * - @c bkpinfo->media_device
|
---|
| 1070 | * - @c bkpinfo->tmpdir
|
---|
| 1071 | * @return The filelist structure containing the information read from disk.
|
---|
| 1072 | */
|
---|
| 1073 | struct
|
---|
[128] | 1074 | s_node *process_filelist_and_biggielist(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 1075 | {
|
---|
[1219] | 1076 | struct s_node *filelist = NULL;
|
---|
[1] | 1077 |
|
---|
[1219] | 1078 | char *command = NULL;
|
---|
| 1079 | char *tmp = NULL;
|
---|
[128] | 1080 | int res = 0;
|
---|
[1219] | 1081 | size_t n = 0;
|
---|
[128] | 1082 | pid_t pid;
|
---|
[1] | 1083 |
|
---|
[128] | 1084 | assert(bkpinfo != NULL);
|
---|
| 1085 | malloc_string(tmp);
|
---|
[1] | 1086 |
|
---|
[128] | 1087 | if (does_file_exist(g_filelist_full)
|
---|
| 1088 | && does_file_exist(g_biggielist_txt)) {
|
---|
[1108] | 1089 | mr_msg(1, "%s exists", g_filelist_full);
|
---|
| 1090 | mr_msg(1, "%s exists", g_biggielist_txt);
|
---|
| 1091 | mr_msg(2,
|
---|
[128] | 1092 | "Filelist and biggielist already recovered from media. Yay!");
|
---|
| 1093 | } else {
|
---|
| 1094 | getcwd(tmp, MAX_STR_LEN);
|
---|
| 1095 | chdir(bkpinfo->tmpdir);
|
---|
[1108] | 1096 | mr_msg(1, "chdir(%s)", bkpinfo->tmpdir);
|
---|
[128] | 1097 | log_to_screen("Extracting filelist and biggielist from media...");
|
---|
| 1098 | unlink("/tmp/filelist.full");
|
---|
| 1099 | unlink("/" FILELIST_FULL_STUB);
|
---|
| 1100 | unlink("/tmp/i-want-my-lvm");
|
---|
| 1101 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
[1219] | 1102 | mr_asprintf(&command,
|
---|
[1241] | 1103 | "tar -b %ld -zxf %s %s %s %s %s %s",
|
---|
| 1104 | bkpinfo->internal_tape_block_size,
|
---|
[128] | 1105 | bkpinfo->media_device,
|
---|
| 1106 | MOUNTLIST_FNAME_STUB,
|
---|
| 1107 | BIGGIELIST_TXT_STUB,
|
---|
| 1108 | FILELIST_FULL_STUB,
|
---|
| 1109 | "tmp/i-want-my-lvm", MONDO_CFG_FILE_STUB);
|
---|
[1108] | 1110 | mr_msg(1, "tarcommand = %s", command);
|
---|
[128] | 1111 | run_program_and_log_output(command, 1);
|
---|
[1219] | 1112 | mr_free(command);
|
---|
[128] | 1113 | } else {
|
---|
[1108] | 1114 | mr_msg(2,
|
---|
[128] | 1115 | "Calling insist_on_this_cd_number; bkpinfo->isodir=%s",
|
---|
| 1116 | bkpinfo->isodir);
|
---|
| 1117 | insist_on_this_cd_number(bkpinfo, 1);
|
---|
[1108] | 1118 | mr_msg(2, "Back from iotcn");
|
---|
[128] | 1119 | run_program_and_log_output("mount", 1);
|
---|
[1219] | 1120 | mr_asprintf(&command,
|
---|
[128] | 1121 | "tar -zxf %s/images/all.tar.gz %s %s %s %s %s",
|
---|
| 1122 | MNT_CDROM,
|
---|
| 1123 | MOUNTLIST_FNAME_STUB,
|
---|
| 1124 | BIGGIELIST_TXT_STUB,
|
---|
| 1125 | FILELIST_FULL_STUB,
|
---|
| 1126 | "tmp/i-want-my-lvm", MONDO_CFG_FILE_STUB);
|
---|
[1] | 1127 |
|
---|
[1108] | 1128 | mr_msg(1, "tarcommand = %s", command);
|
---|
[128] | 1129 | run_program_and_log_output(command, 1);
|
---|
[1219] | 1130 | mr_free(command);
|
---|
| 1131 |
|
---|
[128] | 1132 | if (!does_file_exist(BIGGIELIST_TXT_STUB)) {
|
---|
| 1133 | fatal_error
|
---|
| 1134 | ("all.tar.gz did not include tmp/biggielist.txt");
|
---|
| 1135 | }
|
---|
| 1136 | if (!does_file_exist(FILELIST_FULL_STUB)) {
|
---|
| 1137 | fatal_error
|
---|
| 1138 | ("all.tar.gz did not include tmp/filelist.full.gz");
|
---|
| 1139 | }
|
---|
| 1140 | }
|
---|
[1219] | 1141 | mr_asprintf(&command, "cp -f %s %s", MONDO_CFG_FILE_STUB,
|
---|
[128] | 1142 | g_mondo_cfg_file);
|
---|
| 1143 | run_program_and_log_output(command, FALSE);
|
---|
[1219] | 1144 | mr_free(command);
|
---|
[1] | 1145 |
|
---|
[1219] | 1146 | mr_asprintf(&command, "cp -f %s/%s %s", bkpinfo->tmpdir,
|
---|
[128] | 1147 | BIGGIELIST_TXT_STUB, g_biggielist_txt);
|
---|
[1108] | 1148 | mr_msg(1, "command = %s", command);
|
---|
[128] | 1149 | paranoid_system(command);
|
---|
[1219] | 1150 | mr_free(command);
|
---|
| 1151 |
|
---|
| 1152 | mr_asprintf(&command, "ln -sf %s/%s %s", bkpinfo->tmpdir,
|
---|
[128] | 1153 | FILELIST_FULL_STUB, g_filelist_full);
|
---|
[1108] | 1154 | mr_msg(1, "command = %s", command);
|
---|
[128] | 1155 | paranoid_system(command);
|
---|
[1219] | 1156 | mr_free(command);
|
---|
[128] | 1157 | }
|
---|
[1] | 1158 |
|
---|
[128] | 1159 | if (am_I_in_disaster_recovery_mode()
|
---|
| 1160 | &&
|
---|
[1219] | 1161 | ask_me_yes_or_no(_
|
---|
| 1162 | ("Do you want to retrieve the mountlist as well?")))
|
---|
[128] | 1163 | {
|
---|
[1219] | 1164 | mr_asprintf(&command, "ln -sf %s/%s /tmp", MOUNTLIST_FNAME_STUB,
|
---|
[128] | 1165 | bkpinfo->tmpdir);
|
---|
| 1166 | paranoid_system(command);
|
---|
[1219] | 1167 | mr_free(command);
|
---|
[128] | 1168 | }
|
---|
[1] | 1169 |
|
---|
[128] | 1170 | chdir(tmp);
|
---|
[1219] | 1171 | mr_free(tmp);
|
---|
[1] | 1172 |
|
---|
[128] | 1173 | if (!does_file_exist(g_biggielist_txt)) {
|
---|
[1108] | 1174 | mr_msg(1, "Warning - %s not found", g_biggielist_txt);
|
---|
[128] | 1175 | }
|
---|
| 1176 | if (!does_file_exist(g_filelist_full)) {
|
---|
[1108] | 1177 | mr_msg(1, "Warning - %s does not exist", g_filelist_full);
|
---|
[128] | 1178 | }
|
---|
[1] | 1179 |
|
---|
[1108] | 1180 | mr_msg(2, "Forking");
|
---|
[128] | 1181 | pid = fork();
|
---|
| 1182 | switch (pid) {
|
---|
| 1183 | case -1:
|
---|
| 1184 | fatal_error("Forking error");
|
---|
| 1185 | break;
|
---|
[1] | 1186 |
|
---|
[128] | 1187 | case 0:
|
---|
[1219] | 1188 | log_to_screen(_("Pre-processing filelist"));
|
---|
[128] | 1189 | if (!does_file_exist(g_biggielist_txt)) {
|
---|
[1241] | 1190 | mr_asprintf(&command, "echo -n > %s", g_biggielist_txt);
|
---|
[128] | 1191 | paranoid_system(command);
|
---|
[1219] | 1192 | mr_free(command);
|
---|
[128] | 1193 | }
|
---|
[1219] | 1194 | mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s",
|
---|
[128] | 1195 | g_biggielist_txt, g_filelist_imagedevs);
|
---|
| 1196 | paranoid_system(command);
|
---|
[1219] | 1197 | mr_free(command);
|
---|
[128] | 1198 | exit(0);
|
---|
| 1199 | break;
|
---|
| 1200 |
|
---|
| 1201 | default:
|
---|
[1219] | 1202 | open_evalcall_form(_("Pre-processing filelist"));
|
---|
[128] | 1203 | while (!waitpid(pid, (int *) 0, WNOHANG)) {
|
---|
| 1204 | usleep(100000);
|
---|
| 1205 | update_evalcall_form(0);
|
---|
| 1206 | }
|
---|
[1] | 1207 | }
|
---|
[128] | 1208 | close_evalcall_form();
|
---|
[1] | 1209 |
|
---|
[1108] | 1210 | mr_msg(3, "loading filelist");
|
---|
[128] | 1211 | filelist = load_filelist(g_filelist_full);
|
---|
[1108] | 1212 | mr_msg(3, "deleting original filelist");
|
---|
[128] | 1213 | unlink(g_filelist_full);
|
---|
| 1214 | if (g_text_mode) {
|
---|
[1219] | 1215 | printf(_("Restore which directory? --> "));
|
---|
| 1216 | mr_getline(&tmp, &n, stdin);
|
---|
[128] | 1217 | toggle_path_selection(filelist, tmp, TRUE);
|
---|
| 1218 | if (strlen(tmp) == 0) {
|
---|
| 1219 | res = 1;
|
---|
| 1220 | } else {
|
---|
| 1221 | res = 0;
|
---|
| 1222 | }
|
---|
[1219] | 1223 | mr_free(tmp);
|
---|
[128] | 1224 | } else {
|
---|
| 1225 | res = edit_filelist(filelist);
|
---|
[1] | 1226 | }
|
---|
[128] | 1227 | if (res) {
|
---|
[1108] | 1228 | mr_msg(2, "User hit 'cancel'. Freeing filelist and aborting.");
|
---|
[128] | 1229 | free_filelist(filelist);
|
---|
| 1230 | return (NULL);
|
---|
| 1231 | }
|
---|
| 1232 | ask_about_these_imagedevs(g_filelist_imagedevs, g_imagedevs_restthese);
|
---|
| 1233 | close_evalcall_form();
|
---|
[1] | 1234 |
|
---|
[128] | 1235 | // NB: It's not necessary to add g_biggielist_txt to the filelist.full
|
---|
| 1236 | // file. The filelist.full file already contains the filename of EVERY
|
---|
| 1237 | // file backed up - regular and biggie files.
|
---|
[1] | 1238 |
|
---|
[128] | 1239 | // However, we do want to make sure the imagedevs selected by the user
|
---|
| 1240 | // are flagged for restoring.
|
---|
| 1241 | if (length_of_file(g_imagedevs_restthese) > 2) {
|
---|
| 1242 | add_list_of_files_to_filelist(filelist, g_imagedevs_restthese,
|
---|
| 1243 | TRUE);
|
---|
| 1244 | }
|
---|
| 1245 | return (filelist);
|
---|
| 1246 | }
|
---|
[1] | 1247 | /**************************************************************************
|
---|
| 1248 | *END_ PROCESS_FILELIST_AND_BIGGIELIST *
|
---|
| 1249 | **************************************************************************/
|
---|
| 1250 |
|
---|
| 1251 |
|
---|
| 1252 | /**
|
---|
| 1253 | * Make a backup copy of <tt>path_root</tt>/<tt>filename</tt>.
|
---|
| 1254 | * The backup filename is the filename of the original with ".pristine" added.
|
---|
| 1255 | * @param path_root The place where the filesystem is mounted (e.g. MNT_RESTORING).
|
---|
| 1256 | * @param filename The filename (absolute path) within @p path_root.
|
---|
| 1257 | * @return 0 for success, nonzero for failure.
|
---|
| 1258 | */
|
---|
[128] | 1259 | int backup_crucial_file(char *path_root, char *filename)
|
---|
[1] | 1260 | {
|
---|
[1219] | 1261 | char *command = NULL;
|
---|
| 1262 | int res = 0;
|
---|
[1] | 1263 |
|
---|
[128] | 1264 | assert(path_root != NULL);
|
---|
| 1265 | assert_string_is_neither_NULL_nor_zerolength(filename);
|
---|
| 1266 |
|
---|
[1219] | 1267 | mr_asprintf(&command, "cp -f %s/%s %s/%s.pristine", path_root, filename,path_root, filename);
|
---|
[128] | 1268 | res = run_program_and_log_output(command, 5);
|
---|
[1080] | 1269 | mr_free(command);
|
---|
[128] | 1270 | return (res);
|
---|
[1] | 1271 | }
|
---|
| 1272 |
|
---|
| 1273 |
|
---|
| 1274 | /**
|
---|
| 1275 | * Install the user's boot loader in the MBR.
|
---|
| 1276 | * Currently LILO, ELILO, GRUB, RAW (dd of MBR), and the FreeBSD bootloader are supported.
|
---|
| 1277 | * @param offer_to_hack_scripts If TRUE, then offer to hack the user's fstab for them.
|
---|
| 1278 | * @return 0 for success, nonzero for failure.
|
---|
| 1279 | */
|
---|
[128] | 1280 | int run_boot_loader(bool offer_to_hack_scripts)
|
---|
[1] | 1281 | {
|
---|
[1219] | 1282 | int res = 0;
|
---|
[128] | 1283 | int retval = 0;
|
---|
[1] | 1284 |
|
---|
[1219] | 1285 | char *device = NULL;
|
---|
[1265] | 1286 | #ifdef __FreeBSD__
|
---|
[1219] | 1287 | char *tmp = NULL;
|
---|
[1265] | 1288 | #endif
|
---|
[1219] | 1289 | char *name = NULL;
|
---|
[1] | 1290 |
|
---|
[128] | 1291 | malloc_string(device);
|
---|
| 1292 | malloc_string(name);
|
---|
| 1293 | backup_crucial_file(MNT_RESTORING, "/etc/fstab");
|
---|
| 1294 | backup_crucial_file(MNT_RESTORING, "/etc/grub.conf");
|
---|
| 1295 | backup_crucial_file(MNT_RESTORING, "/etc/lilo.conf");
|
---|
| 1296 | backup_crucial_file(MNT_RESTORING, "/etc/elilo.conf");
|
---|
| 1297 | read_cfg_var(g_mondo_cfg_file, "bootloader.device", device);
|
---|
| 1298 | read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);
|
---|
[1219] | 1299 | mr_msg(2, "run_boot_loader: device='%s', name='%s'", device, name);
|
---|
| 1300 | sync();
|
---|
[128] | 1301 | if (!strcmp(name, "LILO")) {
|
---|
| 1302 | res = run_lilo(offer_to_hack_scripts);
|
---|
| 1303 | } else if (!strcmp(name, "ELILO")) {
|
---|
| 1304 | res = run_elilo(offer_to_hack_scripts);
|
---|
| 1305 | } else if (!strcmp(name, "GRUB")) {
|
---|
| 1306 | res = run_grub(offer_to_hack_scripts, device);
|
---|
| 1307 | } else if (!strcmp(name, "RAW")) {
|
---|
| 1308 | res = run_raw_mbr(offer_to_hack_scripts, device);
|
---|
| 1309 | }
|
---|
[1] | 1310 | #ifdef __FreeBSD__
|
---|
[128] | 1311 | else if (!strcmp(name, "BOOT0")) {
|
---|
[1219] | 1312 | mr_asprintf(&tmp, "boot0cfg -B %s", device);
|
---|
[128] | 1313 | res = run_program_and_log_output(tmp, FALSE);
|
---|
[1219] | 1314 | mr_free(tmp);
|
---|
[128] | 1315 | } else {
|
---|
[1219] | 1316 | mr_asprintf(&tmp, "ls /dev | grep -Eq '^%ss[1-4].*$'", device);
|
---|
[128] | 1317 | if (!system(tmp)) {
|
---|
[1219] | 1318 | mr_free(tmp);
|
---|
| 1319 | mr_asprintf(&tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);
|
---|
[128] | 1320 | res = run_program_and_log_output(tmp, 3);
|
---|
| 1321 | } else {
|
---|
[1108] | 1322 | mr_msg(1,
|
---|
[128] | 1323 | "I'm not running any boot loader. You have a DD boot drive. It's already loaded up.");
|
---|
| 1324 | }
|
---|
[1219] | 1325 | mr_free(tmp);
|
---|
[128] | 1326 | }
|
---|
[1] | 1327 | #else
|
---|
[128] | 1328 | else {
|
---|
| 1329 | log_to_screen
|
---|
[1219] | 1330 | (_
|
---|
| 1331 | ("Unable to determine type of boot loader. Defaulting to LILO."));
|
---|
[128] | 1332 | res = run_lilo(offer_to_hack_scripts);
|
---|
| 1333 | }
|
---|
[1] | 1334 | #endif
|
---|
[1219] | 1335 | mr_free(device);
|
---|
| 1336 | mr_free(name);
|
---|
| 1337 |
|
---|
[128] | 1338 | retval += res;
|
---|
| 1339 | if (res) {
|
---|
[1219] | 1340 | log_to_screen(_("Your boot loader returned an error"));
|
---|
[128] | 1341 | } else {
|
---|
[1219] | 1342 | log_to_screen(_("Your boot loader ran OK"));
|
---|
[128] | 1343 | }
|
---|
| 1344 | return (retval);
|
---|
[1] | 1345 | }
|
---|
| 1346 | /**************************************************************************
|
---|
| 1347 | *END_ RUN_BOOT_LOADER *
|
---|
| 1348 | **************************************************************************/
|
---|
| 1349 |
|
---|
| 1350 |
|
---|
| 1351 | /**
|
---|
| 1352 | * Attempt to find the user's editor.
|
---|
| 1353 | * @return The editor found ("vi" if none could be found).
|
---|
| 1354 | * @note The returned string points to static storage that will be overwritten with each call.
|
---|
| 1355 | */
|
---|
| 1356 | char *find_my_editor(void)
|
---|
| 1357 | {
|
---|
[128] | 1358 | static char output[MAX_STR_LEN];
|
---|
[1275] | 1359 | char *p;
|
---|
[1219] | 1360 |
|
---|
[1275] | 1361 | if ((p = getenv("EDITOR")) != NULL) {
|
---|
| 1362 | strcpy(output, p);
|
---|
| 1363 | }
|
---|
[128] | 1364 | if (find_home_of_exe("pico")) {
|
---|
| 1365 | strcpy(output, "pico");
|
---|
| 1366 | } else if (find_home_of_exe("nano")) {
|
---|
| 1367 | strcpy(output, "nano");
|
---|
[1275] | 1368 | } else if (find_home_of_exe("vim")) {
|
---|
| 1369 | strcpy(output, "vim");
|
---|
[128] | 1370 | } else {
|
---|
| 1371 | strcpy(output, "vi");
|
---|
| 1372 | }
|
---|
| 1373 | if (!find_home_of_exe(output)) {
|
---|
[1108] | 1374 | mr_msg(2, " (find_my_editor) --- warning - %s not found", output);
|
---|
[128] | 1375 | }
|
---|
| 1376 | return (output);
|
---|
[1] | 1377 | }
|
---|
| 1378 |
|
---|
| 1379 |
|
---|
| 1380 | /**
|
---|
| 1381 | * Install GRUB on @p bd.
|
---|
| 1382 | * @param offer_to_run_stabgrub If TRUE, then offer to hack the user's fstab for them.
|
---|
| 1383 | * @param bd The boot device where GRUB is installed.
|
---|
| 1384 | * @return 0 for success, nonzero for failure.
|
---|
| 1385 | */
|
---|
[128] | 1386 | int run_grub(bool offer_to_run_stabgrub, char *bd)
|
---|
[1] | 1387 | {
|
---|
[1219] | 1388 | char *command = NULL;
|
---|
| 1389 | char *boot_device = NULL;
|
---|
| 1390 | char *tmp = NULL;
|
---|
| 1391 | char *editor = NULL;
|
---|
[1] | 1392 |
|
---|
[1219] | 1393 | int res = 0;
|
---|
| 1394 | int done = 0;
|
---|
[1] | 1395 |
|
---|
[128] | 1396 | malloc_string(boot_device);
|
---|
[1219] | 1397 | strcpy(boot_device, bd);
|
---|
[128] | 1398 | assert_string_is_neither_NULL_nor_zerolength(bd);
|
---|
[1219] | 1399 | mr_asprintf(&editor, find_my_editor());
|
---|
[128] | 1400 |
|
---|
| 1401 | if (offer_to_run_stabgrub
|
---|
[1219] | 1402 | && ask_me_yes_or_no(_("Did you change the mountlist?")))
|
---|
[128] | 1403 | /* interactive mode */
|
---|
[1] | 1404 | {
|
---|
[128] | 1405 | mvaddstr_and_log_it(g_currentY,
|
---|
| 1406 | 0,
|
---|
[1548] | 1407 | ("Modifying fstab, mtab, device.map and grub.conf, and running GRUB... "));
|
---|
[128] | 1408 | for (done = FALSE; !done;) {
|
---|
[1219] | 1409 | popup_and_get_string(_("Boot device"),
|
---|
| 1410 | _("Please confirm/enter the boot device. If in doubt, try /dev/hda"), boot_device, MAX_STR_LEN / 4);
|
---|
| 1411 | mr_asprintf(&command, "stabgrub-me %s", boot_device);
|
---|
[128] | 1412 | res = run_program_and_log_output(command, 1);
|
---|
[1219] | 1413 | mr_free(command);
|
---|
| 1414 |
|
---|
[128] | 1415 | if (res) {
|
---|
| 1416 | popup_and_OK
|
---|
[1219] | 1417 | (_
|
---|
| 1418 | ("GRUB installation failed. Please install manually using 'grub-install' or similar command. You are now chroot()'ed to your restored system. Please type 'exit' when you are done."));
|
---|
[128] | 1419 | newtSuspend();
|
---|
| 1420 | system("chroot " MNT_RESTORING);
|
---|
| 1421 | newtResume();
|
---|
[1219] | 1422 | popup_and_OK(_("Thank you."));
|
---|
[128] | 1423 | } else {
|
---|
| 1424 | done = TRUE;
|
---|
| 1425 | }
|
---|
[1548] | 1426 | popup_and_OK(_("You will now edit fstab, mtab, device.map and grub.conf"));
|
---|
[128] | 1427 | if (!g_text_mode) {
|
---|
| 1428 | newtSuspend();
|
---|
| 1429 | }
|
---|
[1500] | 1430 | mr_asprintf(&tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor);
|
---|
[128] | 1431 | paranoid_system(tmp);
|
---|
[1219] | 1432 | mr_free(tmp);
|
---|
| 1433 |
|
---|
[1548] | 1434 | mr_asprintf(&tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor);
|
---|
| 1435 | paranoid_system(tmp);
|
---|
| 1436 | mr_free(tmp);
|
---|
| 1437 |
|
---|
[1500] | 1438 | mr_asprintf(&tmp, "chroot %s %s /etc/grub.conf", MNT_RESTORING, editor);
|
---|
[128] | 1439 | paranoid_system(tmp);
|
---|
[1219] | 1440 | mr_free(tmp);
|
---|
| 1441 |
|
---|
[1548] | 1442 | mr_asprintf(&tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor);
|
---|
| 1443 | paranoid_system(tmp);
|
---|
| 1444 | mr_free(tmp);
|
---|
| 1445 |
|
---|
[128] | 1446 | if (!g_text_mode) {
|
---|
| 1447 | newtResume();
|
---|
| 1448 | }
|
---|
| 1449 | }
|
---|
[1219] | 1450 | } else {
|
---|
[128] | 1451 | /* nuke mode */
|
---|
[1219] | 1452 | if (!run_program_and_log_output("which grub-MR", FALSE)) {
|
---|
| 1453 | mr_msg(1, "Yay! grub-MR found...");
|
---|
| 1454 | mr_asprintf(&command, "grub-MR %s /tmp/mountlist.txt", bd);
|
---|
| 1455 | mr_msg(1, "command = %s", command);
|
---|
| 1456 | } else {
|
---|
| 1457 | mr_asprintf(&command, "chroot " MNT_RESTORING " grub-install %s", bd);
|
---|
| 1458 | mr_msg(1, "WARNING - grub-MR not found; using grub-install");
|
---|
| 1459 | }
|
---|
[128] | 1460 | mvaddstr_and_log_it(g_currentY,
|
---|
| 1461 | 0,
|
---|
[1219] | 1462 | _
|
---|
| 1463 | ("Running GRUB... "));
|
---|
[128] | 1464 | iamhere(command);
|
---|
| 1465 | res = run_program_and_log_output(command, 1);
|
---|
[1219] | 1466 | mr_free(command);
|
---|
| 1467 |
|
---|
[128] | 1468 | if (res) {
|
---|
| 1469 | popup_and_OK
|
---|
[1219] | 1470 | (_
|
---|
| 1471 | ("Because of bugs in GRUB's own installer, GRUB was not installed properly. Please install the boot loader manually now, using this chroot()'ed shell prompt. Type 'exit' when you have finished."));
|
---|
[128] | 1472 | newtSuspend();
|
---|
| 1473 | system("chroot " MNT_RESTORING);
|
---|
| 1474 | newtResume();
|
---|
[1219] | 1475 | popup_and_OK(_("Thank you."));
|
---|
[128] | 1476 | }
|
---|
[1] | 1477 | }
|
---|
[128] | 1478 | if (res) {
|
---|
[1219] | 1479 | mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
|
---|
[1384] | 1480 | log_to_screen(_("GRUB ran w/error(s). See %s for more info."), MONDO_LOGFILE);
|
---|
[1108] | 1481 | mr_msg(1, "Type:-");
|
---|
| 1482 | mr_msg(1, " mount-me");
|
---|
| 1483 | mr_msg(1, " chroot " MNT_RESTORING);
|
---|
| 1484 | mr_msg(1, " mount /boot");
|
---|
| 1485 | mr_msg(1, " grub-install '(hd0)'");
|
---|
| 1486 | mr_msg(1, " exit");
|
---|
| 1487 | mr_msg(1, " unmount-me");
|
---|
| 1488 | mr_msg(1,
|
---|
[128] | 1489 | "If you're really stuck, please e-mail the mailing list.");
|
---|
| 1490 | } else {
|
---|
[1219] | 1491 | mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
|
---|
[128] | 1492 | }
|
---|
[1080] | 1493 | mr_free(boot_device);
|
---|
| 1494 | mr_free(editor);
|
---|
[128] | 1495 | return (res);
|
---|
[1] | 1496 | }
|
---|
| 1497 | /**************************************************************************
|
---|
| 1498 | *END_RUN_GRUB *
|
---|
| 1499 | **************************************************************************/
|
---|
| 1500 |
|
---|
| 1501 |
|
---|
| 1502 | /**
|
---|
| 1503 | * Install ELILO on the user's boot drive (determined by elilo.conf).
|
---|
| 1504 | * @param offer_to_run_stabelilo If TRUE, then offer to hack the user's fstab for them.
|
---|
| 1505 | * @return 0 for success, nonzero for failure.
|
---|
| 1506 | */
|
---|
[128] | 1507 | int run_elilo(bool offer_to_run_stabelilo)
|
---|
[1] | 1508 | {
|
---|
[1219] | 1509 | char *command = NULL;
|
---|
| 1510 | char *tmp = NULL;
|
---|
| 1511 | char *editor = NULL;
|
---|
[1] | 1512 |
|
---|
[1219] | 1513 | int res = 0;
|
---|
| 1514 | int done = 0;
|
---|
[1] | 1515 |
|
---|
[1219] | 1516 | mr_asprintf(&editor, find_my_editor());
|
---|
[128] | 1517 | if (offer_to_run_stabelilo
|
---|
[1219] | 1518 | && ask_me_yes_or_no(_("Did you change the mountlist?")))
|
---|
[1] | 1519 |
|
---|
[128] | 1520 | /* interactive mode */
|
---|
| 1521 | {
|
---|
| 1522 | mvaddstr_and_log_it(g_currentY,
|
---|
| 1523 | 0,
|
---|
[1219] | 1524 | _
|
---|
| 1525 | ("Modifying fstab and elilo.conf... "));
|
---|
| 1526 | mr_asprintf(&command, "stabelilo-me");
|
---|
[128] | 1527 | res = run_program_and_log_output(command, 3);
|
---|
[1219] | 1528 | mr_free(command);
|
---|
| 1529 |
|
---|
[128] | 1530 | if (res) {
|
---|
| 1531 | popup_and_OK
|
---|
[1219] | 1532 | (_
|
---|
| 1533 | ("You will now edit fstab and elilo.conf, to make sure they match your new mountlist."));
|
---|
[128] | 1534 | for (done = FALSE; !done;) {
|
---|
| 1535 | if (!g_text_mode) {
|
---|
| 1536 | newtSuspend();
|
---|
| 1537 | }
|
---|
[1219] | 1538 | mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
|
---|
[128] | 1539 | paranoid_system(tmp);
|
---|
[1219] | 1540 | mr_free(tmp);
|
---|
| 1541 |
|
---|
| 1542 | mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/elilo.conf", editor);
|
---|
[128] | 1543 | paranoid_system(tmp);
|
---|
[1219] | 1544 | mr_free(tmp);
|
---|
| 1545 |
|
---|
[128] | 1546 | if (!g_text_mode) {
|
---|
| 1547 | newtResume();
|
---|
| 1548 | }
|
---|
[1] | 1549 | // newtCls();
|
---|
[1219] | 1550 | if (ask_me_yes_or_no(_("Edit them again?"))) {
|
---|
[128] | 1551 | continue;
|
---|
| 1552 | }
|
---|
| 1553 | done = TRUE;
|
---|
| 1554 | }
|
---|
| 1555 | } else {
|
---|
[1219] | 1556 | log_to_screen(_("elilo.conf and fstab were modified OK"));
|
---|
[1] | 1557 | }
|
---|
[128] | 1558 | } else
|
---|
| 1559 | /* nuke mode */
|
---|
[1] | 1560 | {
|
---|
[128] | 1561 | res = TRUE;
|
---|
[1] | 1562 | }
|
---|
[1080] | 1563 | mr_free(editor);
|
---|
[128] | 1564 | return (res);
|
---|
| 1565 | }
|
---|
[1] | 1566 | /**************************************************************************
|
---|
| 1567 | *END_RUN_ELILO *
|
---|
| 1568 | **************************************************************************/
|
---|
| 1569 |
|
---|
| 1570 |
|
---|
| 1571 | /**
|
---|
| 1572 | * Install LILO on the user's boot drive (determined by /etc/lilo.conf).
|
---|
| 1573 | * @param offer_to_run_stablilo If TRUE, then offer to hack the user's fstab for them.
|
---|
| 1574 | * @return 0 for success, nonzero for failure.
|
---|
| 1575 | */
|
---|
[128] | 1576 | int run_lilo(bool offer_to_run_stablilo)
|
---|
[1] | 1577 | {
|
---|
| 1578 | /** malloc **/
|
---|
[1219] | 1579 | char *command = NULL;
|
---|
| 1580 | char *tmp = NULL;
|
---|
| 1581 | char *editor = NULL;
|
---|
[1] | 1582 |
|
---|
[1219] | 1583 | int res = 0;
|
---|
| 1584 | int done = 0;
|
---|
[128] | 1585 | bool run_lilo_M = FALSE;
|
---|
[1] | 1586 |
|
---|
[128] | 1587 | if (!run_program_and_log_output
|
---|
| 1588 | ("grep \"boot.*=.*/dev/md\" " MNT_RESTORING "/etc/lilo.conf", 1)) {
|
---|
| 1589 | run_lilo_M = TRUE;
|
---|
| 1590 | }
|
---|
[1] | 1591 |
|
---|
[1219] | 1592 | mr_asprintf(&editor, find_my_editor());
|
---|
[128] | 1593 | if (offer_to_run_stablilo
|
---|
[1219] | 1594 | && ask_me_yes_or_no(_("Did you change the mountlist?"))) {
|
---|
[128] | 1595 | /* interactive mode */
|
---|
| 1596 | mvaddstr_and_log_it(g_currentY,
|
---|
| 1597 | 0,
|
---|
[1219] | 1598 | _
|
---|
| 1599 | ("Modifying fstab and lilo.conf, and running LILO... "));
|
---|
| 1600 | mr_asprintf(&command, "stablilo-me");
|
---|
[128] | 1601 | res = run_program_and_log_output(command, 3);
|
---|
[1219] | 1602 | mr_free(command);
|
---|
| 1603 |
|
---|
[128] | 1604 | if (res) {
|
---|
| 1605 | popup_and_OK
|
---|
[1219] | 1606 | (_
|
---|
| 1607 | ("You will now edit fstab and lilo.conf, to make sure they match your new mountlist."));
|
---|
[128] | 1608 | for (done = FALSE; !done;) {
|
---|
| 1609 | if (!g_text_mode) {
|
---|
| 1610 | newtSuspend();
|
---|
| 1611 | }
|
---|
[1219] | 1612 | mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
|
---|
[128] | 1613 | paranoid_system(tmp);
|
---|
[1219] | 1614 | mr_free(tmp);
|
---|
| 1615 |
|
---|
| 1616 | mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor);
|
---|
[128] | 1617 | paranoid_system(tmp);
|
---|
[1219] | 1618 | mr_free(tmp);
|
---|
| 1619 |
|
---|
[128] | 1620 | if (!g_text_mode) {
|
---|
| 1621 | newtResume();
|
---|
| 1622 | }
|
---|
[1219] | 1623 | if (ask_me_yes_or_no(_("Edit them again?"))) {
|
---|
[128] | 1624 | continue;
|
---|
| 1625 | }
|
---|
| 1626 | res =
|
---|
| 1627 | run_program_and_log_output("chroot " MNT_RESTORING
|
---|
| 1628 | " lilo -L", 3);
|
---|
| 1629 | if (res) {
|
---|
| 1630 | res =
|
---|
| 1631 | run_program_and_log_output("chroot " MNT_RESTORING
|
---|
| 1632 | " lilo", 3);
|
---|
| 1633 | }
|
---|
| 1634 | if (res) {
|
---|
| 1635 | done =
|
---|
| 1636 | ask_me_yes_or_no
|
---|
[1219] | 1637 | (_("LILO failed. Re-edit system files?"));
|
---|
[128] | 1638 | } else {
|
---|
| 1639 | done = TRUE;
|
---|
| 1640 | }
|
---|
| 1641 | }
|
---|
| 1642 | } else {
|
---|
[1219] | 1643 | log_to_screen(_("lilo.conf and fstab were modified OK"));
|
---|
[1] | 1644 | }
|
---|
[1219] | 1645 | } else {
|
---|
[128] | 1646 | /* nuke mode */
|
---|
| 1647 | mvaddstr_and_log_it(g_currentY,
|
---|
| 1648 | 0,
|
---|
[1219] | 1649 | _
|
---|
| 1650 | ("Running LILO... "));
|
---|
[128] | 1651 | res =
|
---|
| 1652 | run_program_and_log_output("chroot " MNT_RESTORING " lilo -L",
|
---|
| 1653 | 3);
|
---|
| 1654 | if (res) {
|
---|
| 1655 | res =
|
---|
| 1656 | run_program_and_log_output("chroot " MNT_RESTORING " lilo",
|
---|
| 1657 | 3);
|
---|
[1] | 1658 | }
|
---|
[128] | 1659 | if (res) {
|
---|
[1219] | 1660 | mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
|
---|
[128] | 1661 | log_to_screen
|
---|
[1219] | 1662 | (_
|
---|
| 1663 | ("Failed to re-jig fstab and/or lilo. Edit/run manually, please."));
|
---|
[128] | 1664 | } else {
|
---|
[1219] | 1665 | mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
|
---|
[128] | 1666 | }
|
---|
[1] | 1667 | }
|
---|
[128] | 1668 | if (run_lilo_M) {
|
---|
| 1669 | run_program_and_log_output("chroot " MNT_RESTORING
|
---|
| 1670 | " lilo -M /dev/hda", 3);
|
---|
| 1671 | run_program_and_log_output("chroot " MNT_RESTORING
|
---|
| 1672 | " lilo -M /dev/sda", 3);
|
---|
[1] | 1673 | }
|
---|
[1080] | 1674 | mr_free(editor);
|
---|
[128] | 1675 | return (res);
|
---|
| 1676 | }
|
---|
[1] | 1677 |
|
---|
| 1678 | /**************************************************************************
|
---|
| 1679 | *END_RUN_LILO *
|
---|
| 1680 | **************************************************************************/
|
---|
| 1681 |
|
---|
| 1682 |
|
---|
| 1683 | /**
|
---|
| 1684 | * Install a raw MBR onto @p bd.
|
---|
| 1685 | * @param offer_to_hack_scripts If TRUE, then offer to hack the user's fstab for them.
|
---|
| 1686 | * @param bd The device to copy the stored MBR to.
|
---|
| 1687 | * @return 0 for success, nonzero for failure.
|
---|
| 1688 | */
|
---|
[128] | 1689 | int run_raw_mbr(bool offer_to_hack_scripts, char *bd)
|
---|
[1] | 1690 | {
|
---|
[1219] | 1691 | char *command = NULL;
|
---|
| 1692 | char *boot_device = NULL;
|
---|
| 1693 | char *tmp = NULL;
|
---|
| 1694 | char *editor = NULL;
|
---|
| 1695 | int res = 0;
|
---|
| 1696 | int done = 0;
|
---|
[1] | 1697 |
|
---|
[128] | 1698 | assert_string_is_neither_NULL_nor_zerolength(bd);
|
---|
[1] | 1699 |
|
---|
[1219] | 1700 | malloc_string(boot_device);
|
---|
| 1701 | mr_asprintf(&editor, find_my_editor());
|
---|
[128] | 1702 | strcpy(boot_device, bd);
|
---|
| 1703 | if (offer_to_hack_scripts
|
---|
[1219] | 1704 | && ask_me_yes_or_no(_("Did you change the mountlist?"))) {
|
---|
[128] | 1705 | /* interactive mode */
|
---|
| 1706 | mvaddstr_and_log_it(g_currentY, 0,
|
---|
[1219] | 1707 | _
|
---|
| 1708 | ("Modifying fstab and restoring MBR... "));
|
---|
[128] | 1709 | for (done = FALSE; !done;) {
|
---|
| 1710 | if (!run_program_and_log_output("which vi", FALSE)) {
|
---|
[1219] | 1711 | popup_and_OK(_("You will now edit fstab"));
|
---|
[128] | 1712 | if (!g_text_mode) {
|
---|
| 1713 | newtSuspend();
|
---|
| 1714 | }
|
---|
[1219] | 1715 | mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor);
|
---|
[128] | 1716 | paranoid_system(tmp);
|
---|
[1219] | 1717 | mr_free(tmp);
|
---|
| 1718 |
|
---|
[128] | 1719 | if (!g_text_mode) {
|
---|
| 1720 | newtResume();
|
---|
| 1721 | }
|
---|
| 1722 | }
|
---|
[1219] | 1723 | popup_and_get_string(_("Boot device"),
|
---|
| 1724 | _("Please confirm/enter the boot device. If in doubt, try /dev/hda"), boot_device, MAX_STR_LEN / 4);
|
---|
| 1725 | mr_asprintf(&command, "stabraw-me %s", boot_device);
|
---|
[128] | 1726 | res = run_program_and_log_output(command, 3);
|
---|
[1219] | 1727 | mr_free(command);
|
---|
| 1728 |
|
---|
[128] | 1729 | if (res) {
|
---|
[1219] | 1730 | done =
|
---|
| 1731 | ask_me_yes_or_no(_("Modifications failed. Re-try?"));
|
---|
[128] | 1732 | } else {
|
---|
| 1733 | done = TRUE;
|
---|
| 1734 | }
|
---|
| 1735 | }
|
---|
[1219] | 1736 | } else {
|
---|
[128] | 1737 | /* nuke mode */
|
---|
| 1738 | mvaddstr_and_log_it(g_currentY, 0,
|
---|
[1219] | 1739 | _("Restoring MBR... "));
|
---|
| 1740 | mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", boot_device);
|
---|
| 1741 | mr_msg(2, "run_raw_mbr() --- command='%s'", command);
|
---|
[128] | 1742 | res = run_program_and_log_output(command, 3);
|
---|
[1219] | 1743 | mr_free(command);
|
---|
[1] | 1744 | }
|
---|
[128] | 1745 | if (res) {
|
---|
[1219] | 1746 | mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
|
---|
[1384] | 1747 | log_to_screen(_("MBR+fstab processed w/error(s). See %s for more info."), MONDO_LOGFILE);
|
---|
[128] | 1748 | } else {
|
---|
[1219] | 1749 | mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
|
---|
[128] | 1750 | }
|
---|
[1080] | 1751 | mr_free(boot_device);
|
---|
| 1752 | mr_free(editor);
|
---|
[128] | 1753 | return (res);
|
---|
[1] | 1754 | }
|
---|
| 1755 | /**************************************************************************
|
---|
| 1756 | *END_RUN_RAW_MBR *
|
---|
| 1757 | **************************************************************************/
|
---|
| 1758 |
|
---|
| 1759 |
|
---|
| 1760 | /**
|
---|
| 1761 | * Turn signal trapping on or off.
|
---|
| 1762 | * @param on If TRUE, then do full cleanup when we receive a signal; if FALSE, then
|
---|
| 1763 | * print a message and exit immediately.
|
---|
| 1764 | */
|
---|
[128] | 1765 | void set_signals(int on)
|
---|
[1] | 1766 | {
|
---|
[128] | 1767 | int signals[] =
|
---|
| 1768 | { SIGKILL, SIGPIPE, SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT,
|
---|
[1219] | 1769 | SIGSTOP, 0
|
---|
| 1770 | };
|
---|
[128] | 1771 | int i;
|
---|
| 1772 | for (i = 0; signals[i]; i++) {
|
---|
| 1773 | if (on) {
|
---|
| 1774 | signal(signals[i], terminate_daemon);
|
---|
| 1775 | } else {
|
---|
| 1776 | signal(signals[i], termination_in_progress);
|
---|
| 1777 | }
|
---|
[1] | 1778 | }
|
---|
| 1779 | }
|
---|
| 1780 |
|
---|
| 1781 | /**************************************************************************
|
---|
| 1782 | *END_SET_SIGNALS *
|
---|
| 1783 | **************************************************************************/
|
---|
| 1784 |
|
---|
| 1785 |
|
---|
| 1786 | /**
|
---|
| 1787 | * malloc() and set sensible defaults for the mondorestore filename variables.
|
---|
| 1788 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 1789 | * - @c bkpinfo->tmpdir
|
---|
| 1790 | * - @c bkpinfo->disaster_recovery
|
---|
| 1791 | */
|
---|
[128] | 1792 | void setup_MR_global_filenames(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 1793 | {
|
---|
[128] | 1794 | char *temppath;
|
---|
[1] | 1795 |
|
---|
[128] | 1796 | assert(bkpinfo != NULL);
|
---|
[1] | 1797 |
|
---|
[128] | 1798 | malloc_string(g_biggielist_txt);
|
---|
| 1799 | malloc_string(g_filelist_full);
|
---|
| 1800 | malloc_string(g_filelist_imagedevs);
|
---|
| 1801 | malloc_string(g_imagedevs_restthese);
|
---|
| 1802 | malloc_string(g_mondo_cfg_file);
|
---|
| 1803 | malloc_string(g_mountlist_fname);
|
---|
| 1804 | malloc_string(g_tmpfs_mountpt);
|
---|
| 1805 | malloc_string(g_isodir_device);
|
---|
| 1806 | malloc_string(g_isodir_format);
|
---|
[1] | 1807 |
|
---|
[128] | 1808 | temppath = bkpinfo->tmpdir;
|
---|
[1] | 1809 |
|
---|
[128] | 1810 | sprintf(g_biggielist_txt, "%s/%s", temppath, BIGGIELIST_TXT_STUB);
|
---|
| 1811 | sprintf(g_filelist_full, "%s/%s", temppath, FILELIST_FULL_STUB);
|
---|
| 1812 | sprintf(g_filelist_imagedevs, "%s/tmp/filelist.imagedevs", temppath);
|
---|
| 1813 | sprintf(g_imagedevs_restthese, "%s/tmp/imagedevs.restore-these",
|
---|
| 1814 | temppath);
|
---|
| 1815 | if (bkpinfo->disaster_recovery) {
|
---|
| 1816 | sprintf(g_mondo_cfg_file, "/%s", MONDO_CFG_FILE_STUB);
|
---|
| 1817 | sprintf(g_mountlist_fname, "/%s", MOUNTLIST_FNAME_STUB);
|
---|
| 1818 | } else {
|
---|
| 1819 | sprintf(g_mondo_cfg_file, "%s/%s", temppath, MONDO_CFG_FILE_STUB);
|
---|
| 1820 | sprintf(g_mountlist_fname, "%s/%s", temppath,
|
---|
| 1821 | MOUNTLIST_FNAME_STUB);
|
---|
| 1822 | }
|
---|
[1] | 1823 | }
|
---|
[128] | 1824 |
|
---|
[1] | 1825 | /**************************************************************************
|
---|
| 1826 | *END_SET_GLOBAL_FILENAME *
|
---|
| 1827 | **************************************************************************/
|
---|
| 1828 |
|
---|
| 1829 |
|
---|
| 1830 | /**
|
---|
| 1831 | * Copy @p input_file (containing the result of a compare) to @p output_file,
|
---|
| 1832 | * deleting spurious "changes" along the way.
|
---|
| 1833 | * @param output_file The output file to write with spurious changes removed.
|
---|
| 1834 | * @param input_file The input file, a list of changed files created by a compare.
|
---|
| 1835 | */
|
---|
[128] | 1836 | void streamline_changes_file(char *output_file, char *input_file)
|
---|
[1] | 1837 | {
|
---|
[128] | 1838 | FILE *fin;
|
---|
| 1839 | FILE *fout;
|
---|
[1219] | 1840 | char *incoming = NULL;
|
---|
| 1841 | size_t n = 0;
|
---|
[1] | 1842 |
|
---|
[128] | 1843 | assert_string_is_neither_NULL_nor_zerolength(output_file);
|
---|
| 1844 | assert_string_is_neither_NULL_nor_zerolength(input_file);
|
---|
| 1845 |
|
---|
| 1846 | if (!(fin = fopen(input_file, "r"))) {
|
---|
| 1847 | log_OS_error(input_file);
|
---|
| 1848 | return;
|
---|
| 1849 | }
|
---|
| 1850 | if (!(fout = fopen(output_file, "w"))) {
|
---|
| 1851 | fatal_error("cannot open output_file");
|
---|
| 1852 | }
|
---|
[1219] | 1853 | for (mr_getline(&incoming, &n, fin); !feof(fin);
|
---|
| 1854 | mr_getline(&incoming, &n, fin)) {
|
---|
[128] | 1855 | if (strncmp(incoming, "etc/adjtime", 11)
|
---|
| 1856 | && strncmp(incoming, "etc/mtab", 8)
|
---|
| 1857 | && strncmp(incoming, "tmp/", 4)
|
---|
| 1858 | && strncmp(incoming, "boot/map", 8)
|
---|
| 1859 | && !strstr(incoming, "incheckentry")
|
---|
| 1860 | && strncmp(incoming, "etc/mail/statistics", 19)
|
---|
| 1861 | && strncmp(incoming, "var/", 4))
|
---|
| 1862 | fprintf(fout, "%s", incoming); /* don't need \n here, for some reason.. */
|
---|
| 1863 | }
|
---|
[1219] | 1864 | mr_free(incoming);
|
---|
[128] | 1865 | paranoid_fclose(fout);
|
---|
| 1866 | paranoid_fclose(fin);
|
---|
[1] | 1867 | }
|
---|
| 1868 | /**************************************************************************
|
---|
| 1869 | *END_STREAMLINE_CHANGES_FILE *
|
---|
| 1870 | **************************************************************************/
|
---|
| 1871 |
|
---|
| 1872 |
|
---|
| 1873 | /**
|
---|
| 1874 | * Exit due to a signal (normal cleanup).
|
---|
| 1875 | * @param sig The signal we're exiting due to.
|
---|
| 1876 | */
|
---|
[128] | 1877 | void terminate_daemon(int sig)
|
---|
[1] | 1878 | {
|
---|
[128] | 1879 | log_to_screen
|
---|
[1219] | 1880 | (_("Mondorestore is terminating in response to a signal from the OS"));
|
---|
[1166] | 1881 | free_MR_global_filenames();
|
---|
| 1882 | finish(254);
|
---|
[1] | 1883 | }
|
---|
| 1884 | /**************************************************************************
|
---|
| 1885 | *END_TERMINATE_DAEMON *
|
---|
| 1886 | **************************************************************************/
|
---|
| 1887 |
|
---|
| 1888 |
|
---|
| 1889 | /**
|
---|
| 1890 | * Give the user twenty seconds to press Ctrl-Alt-Del before we nuke their drives.
|
---|
| 1891 | */
|
---|
[128] | 1892 | void twenty_seconds_til_yikes()
|
---|
[1] | 1893 | {
|
---|
[128] | 1894 | int i;
|
---|
[1219] | 1895 | char *tmp = NULL;
|
---|
[1] | 1896 |
|
---|
[128] | 1897 | if (does_file_exist("/tmp/NOPAUSE")) {
|
---|
| 1898 | return;
|
---|
| 1899 | }
|
---|
[1219] | 1900 | open_progress_form(_("CAUTION"),
|
---|
| 1901 | _
|
---|
| 1902 | ("Be advised: I am about to ERASE your hard disk(s)!"),
|
---|
| 1903 | _("You may press Ctrl+Alt+Del to abort safely."),
|
---|
[128] | 1904 | "", 20);
|
---|
| 1905 | for (i = 0; i < 20; i++) {
|
---|
| 1906 | g_current_progress = i;
|
---|
[1219] | 1907 | mr_asprintf(&tmp, _("You have %d seconds left to abort."), 20 - i);
|
---|
[128] | 1908 | update_progress_form(tmp);
|
---|
[1219] | 1909 | mr_free(tmp);
|
---|
[128] | 1910 | sleep(1);
|
---|
| 1911 | }
|
---|
| 1912 | close_progress_form();
|
---|
[1] | 1913 | }
|
---|
| 1914 | /**************************************************************************
|
---|
| 1915 | *END_TWENTY_SECONDS_TIL_YIKES *
|
---|
| 1916 | **************************************************************************/
|
---|
| 1917 |
|
---|
| 1918 |
|
---|
| 1919 | /**
|
---|
| 1920 | * Exit due to a signal (no cleanup).
|
---|
| 1921 | * @param sig The signal we're exiting due to.
|
---|
| 1922 | */
|
---|
[128] | 1923 | void termination_in_progress(int sig)
|
---|
[1] | 1924 | {
|
---|
[1108] | 1925 | mr_msg(1, "Termination in progress");
|
---|
[128] | 1926 | usleep(1000);
|
---|
| 1927 | pthread_exit(0);
|
---|
[1] | 1928 | }
|
---|
| 1929 | /**************************************************************************
|
---|
| 1930 | *END_TERMINATION_IN_PROGRESS *
|
---|
| 1931 | **************************************************************************/
|
---|
| 1932 |
|
---|
| 1933 |
|
---|
| 1934 | /**
|
---|
| 1935 | * Unmount all devices in @p p_external_copy_of_mountlist.
|
---|
| 1936 | * @param p_external_copy_of_mountlist The mountlist to guide the devices to unmount.
|
---|
| 1937 | * @return 0 for success, nonzero for failure.
|
---|
| 1938 | */
|
---|
[128] | 1939 | int unmount_all_devices(struct mountlist_itself
|
---|
| 1940 | *p_external_copy_of_mountlist)
|
---|
[1] | 1941 | {
|
---|
[128] | 1942 | struct mountlist_itself *mountlist;
|
---|
[1219] | 1943 | int retval = 0;
|
---|
| 1944 | int lino = 0;
|
---|
| 1945 | int res = 0;
|
---|
| 1946 | int i = 0;
|
---|
| 1947 | char *command = NULL;
|
---|
| 1948 | char *tmp = NULL;
|
---|
[1] | 1949 |
|
---|
[128] | 1950 | assert(p_external_copy_of_mountlist != NULL);
|
---|
[1] | 1951 |
|
---|
[1102] | 1952 | mountlist = (struct mountlist_itself *)mr_malloc(sizeof(struct mountlist_itself));
|
---|
[128] | 1953 | memcpy((void *) mountlist, (void *) p_external_copy_of_mountlist,
|
---|
| 1954 | sizeof(struct mountlist_itself));
|
---|
| 1955 | sort_mountlist_by_mountpoint(mountlist, 0);
|
---|
[1] | 1956 |
|
---|
[691] | 1957 | run_program_and_log_output("df -m", 3);
|
---|
[1219] | 1958 | mvaddstr_and_log_it(g_currentY, 0, _("Unmounting devices "));
|
---|
| 1959 | open_progress_form(_("Unmounting devices"),
|
---|
| 1960 | _("Unmounting all devices that were mounted,"),
|
---|
| 1961 | _
|
---|
| 1962 | ("in preparation for the post-restoration reboot."),
|
---|
[128] | 1963 | "", mountlist->entries);
|
---|
| 1964 | chdir("/");
|
---|
| 1965 | for (i = 0;
|
---|
| 1966 | i < 10
|
---|
| 1967 | &&
|
---|
| 1968 | run_program_and_log_output
|
---|
[792] | 1969 | ("ps | grep buffer | grep -v \"grep buffer\"", TRUE) == 0;
|
---|
[128] | 1970 | i++) {
|
---|
| 1971 | sleep(1);
|
---|
[1108] | 1972 | mr_msg(2, "Waiting for buffer() to finish");
|
---|
[128] | 1973 | }
|
---|
[1] | 1974 |
|
---|
[1219] | 1975 | sync();
|
---|
[1] | 1976 |
|
---|
[1326] | 1977 | sprintf(tmp, "cp -f %s " MNT_RESTORING "/var/log", MONDO_LOGFILE);
|
---|
| 1978 | if (run_program_and_log_output(tmp, FALSE)) {
|
---|
[1108] | 1979 | mr_msg(1,
|
---|
[1326] | 1980 | "Error. Failed to copy log to PC's /var/log dir. (Mounted read-only?)");
|
---|
[1] | 1981 | }
|
---|
[128] | 1982 | if (does_file_exist("/tmp/DUMBASS-GENTOO")) {
|
---|
| 1983 | run_program_and_log_output("mkdir -p " MNT_RESTORING
|
---|
| 1984 | "/mnt/.boot.d", 5);
|
---|
[1] | 1985 | }
|
---|
[128] | 1986 | for (lino = mountlist->entries - 1; lino >= 0; lino--) {
|
---|
| 1987 | if (!strcmp(mountlist->el[lino].mountpoint, "lvm")) {
|
---|
| 1988 | continue;
|
---|
| 1989 | }
|
---|
[1219] | 1990 | mr_asprintf(&tmp, _("Unmounting device %s "),
|
---|
| 1991 | mountlist->el[lino].device);
|
---|
[128] | 1992 |
|
---|
| 1993 | update_progress_form(tmp);
|
---|
[1219] | 1994 |
|
---|
[128] | 1995 | if (is_this_device_mounted(mountlist->el[lino].device)) {
|
---|
| 1996 | if (!strcmp(mountlist->el[lino].mountpoint, "swap")) {
|
---|
[1219] | 1997 | mr_asprintf(&command, "swapoff %s", mountlist->el[lino].device);
|
---|
[128] | 1998 | } else {
|
---|
| 1999 | if (!strcmp(mountlist->el[lino].mountpoint, "/1")) {
|
---|
[1219] | 2000 | mr_asprintf(&command, "umount %s/", MNT_RESTORING);
|
---|
[1108] | 2001 | mr_msg(3,
|
---|
[128] | 2002 | "Well, I know a certain kitty-kitty who'll be sleeping with Mommy tonight...");
|
---|
| 2003 | } else {
|
---|
[1219] | 2004 | mr_asprintf(&command, "umount " MNT_RESTORING "%s",
|
---|
[128] | 2005 | mountlist->el[lino].mountpoint);
|
---|
| 2006 | }
|
---|
| 2007 | }
|
---|
[1108] | 2008 | mr_msg(10, "The 'umount' command is '%s'", command);
|
---|
[128] | 2009 | res = run_program_and_log_output(command, 3);
|
---|
[1219] | 2010 | mr_free(command);
|
---|
[128] | 2011 | } else {
|
---|
[1219] | 2012 | mr_strcat(tmp, _("...not mounted anyway :-) OK"));
|
---|
[128] | 2013 | res = 0;
|
---|
| 2014 | }
|
---|
| 2015 | g_current_progress++;
|
---|
| 2016 | if (res) {
|
---|
[1219] | 2017 | mr_strcat(tmp, _("...Failed"));
|
---|
[128] | 2018 | retval++;
|
---|
| 2019 | log_to_screen(tmp);
|
---|
| 2020 | } else {
|
---|
[1108] | 2021 | mr_msg(2, tmp);
|
---|
[128] | 2022 | }
|
---|
[1219] | 2023 | mr_free(tmp);
|
---|
[128] | 2024 | }
|
---|
| 2025 | close_progress_form();
|
---|
| 2026 | if (retval) {
|
---|
[1219] | 2027 | mvaddstr_and_log_it(g_currentY++, 74, _("Failed."));
|
---|
[128] | 2028 | } else {
|
---|
[1219] | 2029 | mvaddstr_and_log_it(g_currentY++, 74, _("Done."));
|
---|
[128] | 2030 | }
|
---|
| 2031 | if (retval) {
|
---|
[1219] | 2032 | log_to_screen(_("Unable to unmount some of your partitions."));
|
---|
[128] | 2033 | } else {
|
---|
[1219] | 2034 | log_to_screen(_("All partitions were unmounted OK."));
|
---|
[128] | 2035 | }
|
---|
[1124] | 2036 | mr_free(mountlist);
|
---|
[128] | 2037 | return (retval);
|
---|
[1] | 2038 | }
|
---|
| 2039 | /**************************************************************************
|
---|
| 2040 | *END_UNMOUNT_ALL_DEVICES *
|
---|
| 2041 | **************************************************************************/
|
---|
| 2042 |
|
---|
| 2043 |
|
---|
| 2044 | /**
|
---|
| 2045 | * Extract mondo-restore.cfg and the mountlist from the tape inserted
|
---|
| 2046 | * to the ./tmp/ directory.
|
---|
| 2047 | * @param dev The tape device to read from.
|
---|
| 2048 | * @return 0 for success, nonzero for failure.
|
---|
| 2049 | */
|
---|
[128] | 2050 | int extract_cfg_file_and_mountlist_from_tape_dev(char *dev)
|
---|
[1] | 2051 | {
|
---|
[1219] | 2052 | char *command = NULL;
|
---|
[128] | 2053 | int res = 0;
|
---|
[1219] | 2054 | // BERLIOS: below 32KB seems to block at least on RHAS 2.1 and MDK 10.0
|
---|
[128] | 2055 | long tape_block_size = 32768;
|
---|
[1] | 2056 |
|
---|
[128] | 2057 | // tar -zxvf-
|
---|
[1219] | 2058 | mr_asprintf(&command,
|
---|
[128] | 2059 | "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s",
|
---|
| 2060 | dev,
|
---|
| 2061 | tape_block_size,
|
---|
| 2062 | 1024L * 1024 * 32 / tape_block_size,
|
---|
| 2063 | MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB,
|
---|
| 2064 | BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm");
|
---|
[1108] | 2065 | mr_msg(2, "command = '%s'", command);
|
---|
[128] | 2066 | res = run_program_and_log_output(command, -1);
|
---|
[1219] | 2067 | mr_free(command);
|
---|
| 2068 |
|
---|
[128] | 2069 | if (res != 0 && does_file_exist(MONDO_CFG_FILE_STUB)) {
|
---|
| 2070 | res = 0;
|
---|
| 2071 | }
|
---|
| 2072 | return (res);
|
---|
[1] | 2073 | }
|
---|
| 2074 |
|
---|
[128] | 2075 |
|
---|
[1] | 2076 | /**
|
---|
[1581] | 2077 | * Get the configuration file from the tape, or CD.
|
---|
[1] | 2078 | * @param bkpinfo The backup information structure. Fields used:
|
---|
| 2079 | * - @c bkpinfo->backup_media_type
|
---|
| 2080 | * - @c bkpinfo->media_device
|
---|
| 2081 | * - @c bkpinfo->tmpdir
|
---|
| 2082 | * @return 0 for success, nonzero for failure.
|
---|
| 2083 | */
|
---|
[128] | 2084 | int get_cfg_file_from_archive(struct s_bkpinfo *bkpinfo)
|
---|
[1] | 2085 | {
|
---|
[128] | 2086 | int retval = 0;
|
---|
[1219] | 2087 | char *command = NULL;
|
---|
| 2088 | char *cfg_file = NULL;
|
---|
| 2089 | char *mounted_cfgf_path = NULL;
|
---|
| 2090 | char *tmp = NULL;
|
---|
| 2091 | char *mountpt = NULL;
|
---|
| 2092 | char *ramdisk_fname = NULL;
|
---|
| 2093 | char *mountlist_file = NULL;
|
---|
| 2094 | int res = 0;
|
---|
[128] | 2095 |
|
---|
[1219] | 2096 | bool try_plan_B = FALSE;
|
---|
[1] | 2097 |
|
---|
[128] | 2098 | assert(bkpinfo != NULL);
|
---|
[1108] | 2099 | mr_msg(2, "gcffa --- starting");
|
---|
[1219] | 2100 | log_to_screen(_("I'm thinking..."));
|
---|
| 2101 | mr_asprintf(&mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
|
---|
[128] | 2102 | chdir(bkpinfo->tmpdir);
|
---|
[1219] | 2103 | // MONDO_CFG_FILE_STUB is missing the '/' at the start, FYI, by intent
|
---|
| 2104 | unlink(MONDO_CFG_FILE_STUB);
|
---|
| 2105 |
|
---|
[128] | 2106 | unlink(FILELIST_FULL_STUB);
|
---|
| 2107 | unlink(BIGGIELIST_TXT_STUB);
|
---|
| 2108 | unlink("tmp/i-want-my-lvm");
|
---|
[1219] | 2109 | mr_asprintf(&command, "mkdir -p %s", mountpt);
|
---|
[128] | 2110 | run_program_and_log_output(command, FALSE);
|
---|
[1219] | 2111 | mr_free(command);
|
---|
[128] | 2112 |
|
---|
[1219] | 2113 | mr_asprintf(&cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);
|
---|
| 2114 | mr_asprintf(&mountlist_file, "%s/%s", bkpinfo->tmpdir,
|
---|
[128] | 2115 | MOUNTLIST_FNAME_STUB);
|
---|
[1108] | 2116 | mr_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file);
|
---|
[128] | 2117 |
|
---|
[1219] | 2118 | mr_asprintf(&tmp, "mkdir -p %s/tmp", bkpinfo->tmpdir);
|
---|
[128] | 2119 | run_program_and_log_output(tmp, FALSE);
|
---|
[1219] | 2120 | mr_free(tmp);
|
---|
[128] | 2121 |
|
---|
| 2122 | if (!does_file_exist(cfg_file)) {
|
---|
[1108] | 2123 | mr_msg(2, "gcffa --- we don't have cfg file yet.");
|
---|
[128] | 2124 | if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
|
---|
| 2125 | try_plan_B = TRUE;
|
---|
| 2126 | } else {
|
---|
[1108] | 2127 | mr_msg(2, "gcffa --- calling mount_cdrom now :)");
|
---|
[128] | 2128 | if (!mount_cdrom(bkpinfo)) {
|
---|
[1108] | 2129 | mr_msg(2,
|
---|
[128] | 2130 | "gcffa --- managed to mount CD; so, no need for Plan B");
|
---|
| 2131 | try_plan_B = FALSE;
|
---|
| 2132 | } else {
|
---|
| 2133 | try_plan_B = TRUE;
|
---|
| 2134 | }
|
---|
| 2135 | if (what_number_cd_is_this(bkpinfo) > 1) {
|
---|
| 2136 | insist_on_this_cd_number(bkpinfo,
|
---|
| 2137 | (g_current_media_number = 1));
|
---|
| 2138 | }
|
---|
| 2139 | }
|
---|
| 2140 | if (try_plan_B) {
|
---|
[1108] | 2141 | mr_msg(2, "gcffa --- OK, switching to Plan B");
|
---|
[128] | 2142 | chdir(bkpinfo->tmpdir);
|
---|
| 2143 | run_program_and_log_output("mkdir -p tmp", FALSE);
|
---|
[1] | 2144 |
|
---|
[128] | 2145 | if (strlen(bkpinfo->media_device) == 0) {
|
---|
[1594] | 2146 | mr_allocstr(bkpinfo->media_device, "/dev/st0");
|
---|
[1219] | 2147 | mr_msg(2, "media_device is blank; assuming %s",
|
---|
| 2148 | bkpinfo->media_device);
|
---|
[128] | 2149 | }
|
---|
[1219] | 2150 | mr_asprintf(&tmp, bkpinfo->media_device);
|
---|
[128] | 2151 | if (extract_cfg_file_and_mountlist_from_tape_dev
|
---|
| 2152 | (bkpinfo->media_device)) {
|
---|
[1594] | 2153 | mr_allocstr(bkpinfo->media_device, "/dev/st0");
|
---|
[128] | 2154 | if (extract_cfg_file_and_mountlist_from_tape_dev
|
---|
| 2155 | (bkpinfo->media_device)) {
|
---|
[1594] | 2156 | mr_allocstr(bkpinfo->media_device, "/dev/osst0");
|
---|
[128] | 2157 | if (extract_cfg_file_and_mountlist_from_tape_dev
|
---|
| 2158 | (bkpinfo->media_device)) {
|
---|
[1594] | 2159 | mr_allocstr(bkpinfo->media_device, "/dev/ht0");
|
---|
[128] | 2160 | if (extract_cfg_file_and_mountlist_from_tape_dev
|
---|
| 2161 | (bkpinfo->media_device)) {
|
---|
[1108] | 2162 | mr_msg(3,
|
---|
[128] | 2163 | "I tried lots of devices but none worked.");
|
---|
[1594] | 2164 | mr_allocstr(bkpinfo->media_device, tmp);
|
---|
[128] | 2165 | }
|
---|
| 2166 | }
|
---|
| 2167 | }
|
---|
| 2168 | }
|
---|
[1219] | 2169 | mr_free(tmp);
|
---|
[1] | 2170 |
|
---|
[128] | 2171 | if (!does_file_exist("tmp/mondo-restore.cfg")) {
|
---|
[1219] | 2172 | log_to_screen(_
|
---|
[1581] | 2173 | ("Cannot find config info on tape/CD"));
|
---|
[128] | 2174 | return (1);
|
---|
| 2175 | }
|
---|
| 2176 | } else {
|
---|
[1219] | 2177 | mr_asprintf(&mounted_cfgf_path, "%s/%s", mountpt, cfg_file);
|
---|
[128] | 2178 | if (!does_file_exist(mounted_cfgf_path)) {
|
---|
[1419] | 2179 | mr_msg(2,
|
---|
[1408] | 2180 | "gcffa --- Plan B, a.k.a. untarring some file from all.tar.gz");
|
---|
[1219] | 2181 | mr_asprintf(&command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, "tmp/i-want-my-lvm"); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary
|
---|
[128] | 2182 | run_program_and_log_output(command, TRUE);
|
---|
[1219] | 2183 | mr_free(command);
|
---|
| 2184 |
|
---|
[128] | 2185 | if (!does_file_exist(MONDO_CFG_FILE_STUB)) {
|
---|
| 2186 | fatal_error
|
---|
| 2187 | ("Please reinsert the disk/CD and try again.");
|
---|
| 2188 | }
|
---|
| 2189 | }
|
---|
[1219] | 2190 | mr_free(mounted_cfgf_path);
|
---|
[1] | 2191 | }
|
---|
[128] | 2192 | }
|
---|
[1219] | 2193 | mr_free(mountpt);
|
---|
| 2194 |
|
---|
[128] | 2195 | if (does_file_exist(MONDO_CFG_FILE_STUB)) {
|
---|
[1108] | 2196 | mr_msg(1, "gcffa --- great! We've got the config file");
|
---|
[1219] | 2197 | mr_asprintf(&tmp, "%s/%s",
|
---|
[128] | 2198 | call_program_and_get_last_line_of_output("pwd"),
|
---|
| 2199 | MONDO_CFG_FILE_STUB);
|
---|
[1219] | 2200 | mr_asprintf(&command, "cp -f %s %s", tmp, cfg_file);
|
---|
[128] | 2201 | iamhere(command);
|
---|
[1219] | 2202 |
|
---|
[128] | 2203 | if (strcmp(tmp, cfg_file)
|
---|
| 2204 | && run_program_and_log_output(command, 1)) {
|
---|
[1108] | 2205 | mr_msg(1,
|
---|
[128] | 2206 | "... but an error occurred when I tried to move it to %s",
|
---|
| 2207 | cfg_file);
|
---|
| 2208 | } else {
|
---|
[1108] | 2209 | mr_msg(1, "... and I moved it successfully to %s", cfg_file);
|
---|
[128] | 2210 | }
|
---|
[1219] | 2211 | mr_free(command);
|
---|
| 2212 |
|
---|
| 2213 | mr_asprintf(&command, "cp -f %s/%s %s",
|
---|
[128] | 2214 | call_program_and_get_last_line_of_output("pwd"),
|
---|
| 2215 | MOUNTLIST_FNAME_STUB, mountlist_file);
|
---|
| 2216 | iamhere(command);
|
---|
| 2217 | if (strcmp(tmp, cfg_file)
|
---|
| 2218 | && run_program_and_log_output(command, 1)) {
|
---|
[1108] | 2219 | mr_msg(1, "Failed to get mountlist");
|
---|
[128] | 2220 | } else {
|
---|
[1108] | 2221 | mr_msg(1, "Got mountlist too");
|
---|
[1219] | 2222 | mr_free(command);
|
---|
| 2223 | mr_asprintf(&command, "cp -f %s %s", mountlist_file,
|
---|
[128] | 2224 | g_mountlist_fname);
|
---|
| 2225 | if (run_program_and_log_output(command, 1)) {
|
---|
[1108] | 2226 | mr_msg(1, "Failed to copy mountlist to /tmp");
|
---|
[128] | 2227 | } else {
|
---|
[1108] | 2228 | mr_msg(1, "Copied mountlist to /tmp as well OK");
|
---|
[1219] | 2229 | mr_free(command);
|
---|
| 2230 | mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");
|
---|
[128] | 2231 | run_program_and_log_output(command, 1);
|
---|
| 2232 | }
|
---|
| 2233 | }
|
---|
[1219] | 2234 | mr_free(command);
|
---|
| 2235 | mr_free(tmp);
|
---|
[128] | 2236 | }
|
---|
| 2237 | run_program_and_log_output("umount " MNT_CDROM, FALSE);
|
---|
| 2238 | if (!does_file_exist(cfg_file)) {
|
---|
| 2239 | iamhere(cfg_file);
|
---|
[1108] | 2240 | mr_msg(1, "%s not found", cfg_file);
|
---|
[128] | 2241 | log_to_screen
|
---|
[1219] | 2242 | (_
|
---|
| 2243 | ("Oh dear. Unable to recover configuration file from boot disk"));
|
---|
[128] | 2244 | return (1);
|
---|
| 2245 | }
|
---|
[1] | 2246 |
|
---|
[1219] | 2247 | log_to_screen(_("Recovered mondo-restore.cfg"));
|
---|
[128] | 2248 | if (!does_file_exist(MOUNTLIST_FNAME_STUB)) {
|
---|
[1219] | 2249 | log_to_screen(_("...but not mountlist.txt - a pity, really..."));
|
---|
[128] | 2250 | }
|
---|
[1] | 2251 | /* start SAH */
|
---|
[128] | 2252 | else {
|
---|
[1219] | 2253 | mr_asprintf(&command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB,
|
---|
[128] | 2254 | bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);
|
---|
| 2255 | run_program_and_log_output(command, FALSE);
|
---|
[1219] | 2256 | mr_free(command);
|
---|
[128] | 2257 | }
|
---|
[1] | 2258 | /* end SAH */
|
---|
| 2259 |
|
---|
[1219] | 2260 | mr_asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);
|
---|
| 2261 | mr_free(cfg_file);
|
---|
[128] | 2262 | run_program_and_log_output(command, FALSE);
|
---|
[1219] | 2263 | mr_free(command);
|
---|
| 2264 |
|
---|
| 2265 | mr_asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);
|
---|
| 2266 | mr_free(mountlist_file);
|
---|
[128] | 2267 | run_program_and_log_output(command, FALSE);
|
---|
[1219] | 2268 | mr_free(command);
|
---|
| 2269 |
|
---|
| 2270 | mr_asprintf(&command, "cp -f etc/raidtab /etc/");
|
---|
[128] | 2271 | run_program_and_log_output(command, FALSE);
|
---|
[1219] | 2272 | mr_free(command);
|
---|
| 2273 |
|
---|
| 2274 | mr_asprintf(&command, "cp -f tmp/i-want-my-lvm /tmp/");
|
---|
[128] | 2275 | run_program_and_log_output(command, FALSE);
|
---|
[1219] | 2276 | mr_free(command);
|
---|
| 2277 |
|
---|
[128] | 2278 | g_backup_media_type = bkpinfo->backup_media_type;
|
---|
[1267] | 2279 | strncpy(bkpinfo->backup_media_string,bkptype_to_string(bkpinfo->backup_media_type), (size_t)63);
|
---|
[1219] | 2280 | g_backup_media_string = bkpinfo->backup_media_string;
|
---|
[128] | 2281 | return (retval);
|
---|
[1] | 2282 | }
|
---|
| 2283 | /**************************************************************************
|
---|
| 2284 | *END_GET_CFG_FILE_FROM_ARCHIVE *
|
---|
| 2285 | **************************************************************************/
|
---|
| 2286 | /* @} - end restoreUtilityGroup */
|
---|
| 2287 |
|
---|
| 2288 |
|
---|
[1251] | 2289 | void wait_until_software_raids_are_prepped(int wait_for_percentage)
|
---|
[1] | 2290 | {
|
---|
[1219] | 2291 | struct raidlist_itself *raidlist = NULL;
|
---|
| 2292 | int unfinished_mdstat_devices = 9999, i = 0;
|
---|
| 2293 | char *screen_message = NULL;
|
---|
[1] | 2294 |
|
---|
[1102] | 2295 | raidlist = (struct raidlist_itself *)mr_malloc(sizeof(struct raidlist_itself));
|
---|
[128] | 2296 |
|
---|
| 2297 | assert(wait_for_percentage <= 100);
|
---|
[799] | 2298 | iamhere("wait_until_software_raids_are_prepped");
|
---|
[128] | 2299 | while (unfinished_mdstat_devices > 0) {
|
---|
[558] | 2300 | // FIXME: Prefix '/dev/' should really be dynamic!
|
---|
| 2301 | if (parse_mdstat(raidlist, "/dev/")) {
|
---|
| 2302 | log_to_screen("Sorry, cannot read %s", MDSTAT_FILE);
|
---|
[1219] | 2303 | mr_msg(1, "Sorry, cannot read %s", MDSTAT_FILE);
|
---|
[128] | 2304 | return;
|
---|
[1] | 2305 | }
|
---|
[558] | 2306 | for (unfinished_mdstat_devices = i = 0; i <= raidlist->entries; i++) {
|
---|
| 2307 | if (raidlist->el[i].progress < wait_for_percentage) {
|
---|
[128] | 2308 | unfinished_mdstat_devices++;
|
---|
[704] | 2309 | if (raidlist->el[i].progress == -1) // delayed while another partition inits
|
---|
| 2310 | {
|
---|
| 2311 | continue;
|
---|
| 2312 | }
|
---|
[1108] | 2313 | mr_msg(1,"Sync'ing %s (i=%d)", raidlist->el[i].raid_device, i);
|
---|
[1219] | 2314 | mr_asprintf(&screen_message, "Sync'ing %s",
|
---|
[558] | 2315 | raidlist->el[i].raid_device);
|
---|
[128] | 2316 | open_evalcall_form(screen_message);
|
---|
[1219] | 2317 | mr_free(screen_message);
|
---|
| 2318 |
|
---|
[558] | 2319 | while (raidlist->el[i].progress < wait_for_percentage) {
|
---|
[1108] | 2320 | mr_msg(1,"Percentage sync'ed: %d", raidlist->el[i].progress);
|
---|
[558] | 2321 | update_evalcall_form(raidlist->el[i].progress);
|
---|
[128] | 2322 | sleep(2);
|
---|
[558] | 2323 | // FIXME: Prefix '/dev/' should really be dynamic!
|
---|
| 2324 | if (parse_mdstat(raidlist, "/dev/")) {
|
---|
[128] | 2325 | break;
|
---|
| 2326 | }
|
---|
| 2327 | }
|
---|
| 2328 | close_evalcall_form();
|
---|
| 2329 | }
|
---|
[1] | 2330 | }
|
---|
[128] | 2331 | }
|
---|
[1124] | 2332 | mr_free(raidlist);
|
---|
[1] | 2333 | }
|
---|