- Timestamp:
- Jun 28, 2008, 12:41:33 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/mondorestore/mondo-rstr-tools.c
r1106 r1994 6 6 #include <unistd.h> 7 7 #include "my-stuff.h" 8 #include "../common/mondostructures.h" 9 #include "../common/libmondo.h" 8 #include "mr_mem.h" 9 #include "mr_msg.h" 10 #include "mr_str.h" 11 12 #include "mondostructures.h" 13 #include "libmondo.h" 10 14 #include "mr-externs.h" 11 15 #include "mondo-rstr-tools.h" … … 13 17 #include <pthread.h> 14 18 #endif 15 #include "mr_mem.h"16 19 17 20 extern bool g_sigpipe_caught; … … 36 39 extern char *g_mondo_cfg_file; // where m*ndo-restore.cfg (the config file) is stored 37 40 extern char *g_mountlist_fname; // where mountlist.txt (the mountlist file) is stored 38 extern char *g_mondo_home; // homedir of Mondo; usually /usr/local/share/mondo39 extern struct s_bkpinfo *g_bkpinfo_DONTUSETHIS;40 41 41 42 extern t_bkptype g_backup_media_type; … … 63 64 mr_free(g_mondo_cfg_file); 64 65 mr_free(g_mountlist_fname); 65 mr_free(g_mondo_home);66 66 mr_free(g_tmpfs_mountpt); 67 67 mr_free(g_isodir_device); … … 254 254 mr_free(tmp); 255 255 } 256 mr_asprintf(&tmp, 257 "Checking to see if f=%s, file=%s, is in the list of biggiefiles", 256 mr_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles", 258 257 f, file); 259 mr_msg(2, tmp);260 mr_free(tmp);261 262 258 mr_asprintf(&command, "grep -E '^%s$' %s", file, list_fname); 263 259 mr_free(file); … … 299 295 read_cfg_var(g_mondo_cfg_file, "iso-dev", g_isodir_device); 300 296 if (bkpinfo->disaster_recovery) { 301 /* Patch Conor Daly 26-june-2004302 * Don't let this clobber an existing bkpinfo->isodir */297 /* Patch Conor Daly 26-june-2004 298 * Don't let this clobber an existing bkpinfo->isodir */ 303 299 if (!bkpinfo->isodir) { 304 300 mr_allocstr(bkpinfo->isodir, "/tmp/isodir"); … … 328 324 } 329 325 run_program_and_log_output("df -m", FALSE); 330 mr_asprintf(&tmp, 331 "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?", 326 mr_msg(1, "The 'mount' command is '%s'. PLEASE report this command to be if you have problems, ok?", 332 327 mount_isodir_command); 333 mr_msg(1, tmp);334 mr_free(tmp);335 336 328 if (run_program_and_log_output(mount_isodir_command, FALSE)) { 337 329 popup_and_OK … … 350 342 } 351 343 i = what_number_cd_is_this(bkpinfo); /* has the side-effect of calling mount_cdrom() */ 352 mr_ asprintf(&tmp, "%s #%d has been mounted via loopback mount",344 mr_msg(1, "%s #%d has been mounted via loopback mount", 353 345 bkpinfo->backup_media_string, i); 354 mr_msg(1, tmp);355 mr_free(tmp);356 357 346 if (i < 0) { 358 347 popup_and_OK … … 371 360 void kill_petris(void) 372 361 { 373 char *command ;362 char *command = NULL; 374 363 mr_asprintf(&command, 375 364 "kill `ps 2> /dev/null | grep petris 2> /dev/null | grep -v grep | cut -d' ' -f2` 2> /dev/null"); … … 394 383 int res = 0; 395 384 396 char *tmp = NULL;397 385 char *command = NULL; 398 386 char *mountdir = NULL; 399 387 char *mountpoint = NULL; 400 388 char *additional_parameters = NULL; 401 char *p1 = NULL; 402 char *p2 = NULL; 403 char *p3 = NULL; 404 389 405 390 assert_string_is_neither_NULL_nor_zerolength(device); 406 391 assert_string_is_neither_NULL_nor_zerolength(mpt); … … 422 407 return (0); 423 408 } 424 mr_asprintf(&tmp, "Mounting device %s ", device); 425 mr_msg(1, tmp); 426 409 mr_msg(1, "Mounting device %s ", device); 427 410 if (writeable) { 428 mr_asprintf(&p1, "-o rw"); 429 } else { 430 mr_asprintf(&p1, "-o ro"); 431 } 432 tmp = find_home_of_exe("setfattr"); 433 if (tmp) { 434 mr_asprintf(&p2, ",user_xattr"); 435 } else { 436 mr_asprintf(&p2, "%s", ""); 437 } 438 mr_free(tmp); 439 440 tmp = find_home_of_exe("setfacl"); 441 if (tmp) { 442 mr_asprintf(&p3, ",acl"); 443 } else { 444 mr_asprintf(&p3, "%s", ""); 445 } 446 mr_free(tmp); 447 448 mr_asprintf(&additional_parameters, "%s%s%s", p1, p2, p3); 449 mr_free(p1); 450 mr_free(p2); 451 mr_free(p3); 411 mr_asprintf(&additional_parameters, "-o rw"); 412 } else { 413 mr_asprintf(&additional_parameters, "-o ro"); 414 } 415 if (find_home_of_exe("setfattr")) { 416 mr_strcat(additional_parameters, ",user_xattr"); 417 } 418 if (find_home_of_exe("setfacl")) { 419 mr_strcat(additional_parameters, ",acl"); 420 } 452 421 453 422 if (!strcmp(mountpoint, "swap")) { … … 483 452 mr_msg(1, "command was '%s'", command); 484 453 if (!strcmp(mountpoint, "swap")) { 485 log_to_screen(tmp); 454 log_to_screen("Unable to mount device %s (type %s) at %s", device, 455 format, mountdir); 486 456 } else { 487 457 mr_msg(2, "Retrying w/o the '-t' switch"); … … 500 470 } 501 471 } 502 mr_free(tmp);503 472 mr_free(command); 504 473 mr_free(mountdir); … … 516 485 *END_MOUNT_DEVICE * 517 486 **************************************************************************/ 518 519 487 520 488 … … 553 521 "Again with the /proc - why is this in your mountlist?"); 554 522 } else if (is_this_device_mounted(mountlist->el[lino].device)) { 555 mr_asprintf(&tmp,_("%s is already mounted"),523 log_to_screen(_("%s is already mounted"), 556 524 mountlist->el[lino].device); 557 log_to_screen(tmp);558 mr_free(tmp);559 525 } else if (strcmp(mountlist->el[lino].mountpoint, "none") 560 526 && strcmp(mountlist->el[lino].mountpoint, "lvm") … … 576 542 if (res) { 577 543 if (these_failed != NULL) { /* not the first time */ 578 mr_asprintf(&tmp, "%s %s", these_failed, mountlist->el[lino].device); 579 mr_free(these_failed); 580 these_failed = tmp; 544 mr_strcat(these_failed, " %s", mountlist->el[lino].device); 581 545 } else { /* The first time */ 582 mr_asprintf(&these_failed, "%s 546 mr_asprintf(&these_failed, "%s", mountlist->el[lino].device); 583 547 } 584 548 } … … 620 584 } 621 585 run_program_and_log_output("df -m", 3); 622 mr_free( (void*)mountlist);586 mr_free(mountlist); 623 587 return (retval); 624 588 } … … 640 604 { 641 605 char *mount_cmd = NULL; 642 int i , res;606 int i = 0, res = 0; 643 607 #ifdef __FreeBSD__ 644 608 char *mddev = NULL; … … 895 859 mr_free(value); 896 860 897 mr_ asprintf(&tmp, "Backup medium is TAPE --- dev=%s",861 mr_msg(2, "Backup medium is TAPE --- dev=%s", 898 862 bkpinfo->media_device); 899 mr_msg(2, tmp);900 mr_free(tmp);901 863 } else { 902 864 mr_allocstr(bkpinfo->media_device, "/dev/cdrom"); … … 990 952 991 953 read_cfg_var(g_mondo_cfg_file, "please-dont-eject", tmp); 992 #ifdef __FreeBSD__993 tmp1 = call_program_and_get_last_line_of_output("cat /tmp/cmdline");994 #else995 954 tmp1 = call_program_and_get_last_line_of_output("cat /proc/cmdline"); 996 #endif997 955 if ((tmp != NULL) || strstr(tmp1,"donteject")) { 998 956 bkpinfo->please_dont_eject = TRUE; … … 1088 1046 mr_free(iso_mnt); 1089 1047 mr_free(iso_path); 1090 mr_asprintf(&iso_mnt, "%s", ""); 1091 mr_asprintf(&iso_path, "%s", ""); 1092 1048 mr_asprintf(&iso_mnt, ""); 1049 mr_asprintf(&iso_path, ""); 1093 1050 if (mount_cdrom(bkpinfo)) { 1094 1051 fatal_error … … 1119 1076 media_specified_by_user = bkpinfo->backup_media_type; 1120 1077 get_cfg_file_from_archive(bkpinfo); 1121 /*1122 if (media_specified_by_user != cdr && media_specified_by_user == cdrw)1123 { g_restoring_live_from_cd = FALSE; }1124 */1125 1078 } 1126 1079 } … … 1150 1103 s_node *process_filelist_and_biggielist(struct s_bkpinfo *bkpinfo) 1151 1104 { 1152 struct s_node *filelist ;1105 struct s_node *filelist = NULL; 1153 1106 1154 1107 char *command = NULL; … … 1252 1205 mr_msg(1, "Warning - %s does not exist", g_filelist_full); 1253 1206 } 1254 // popup_and_OK("Wonderful.");1255 1207 1256 1208 mr_msg(2, "Forking"); … … 1262 1214 1263 1215 case 0: 1264 log_to_screen( ("Pre-processing filelist"));1216 log_to_screen(_("Pre-processing filelist")); 1265 1217 if (!does_file_exist(g_biggielist_txt)) { 1266 1218 mr_asprintf(&command, "> %s", g_biggielist_txt); … … 1268 1220 mr_free(command); 1269 1221 } 1270 mr_asprintf(&command, "grep -E '^/dev/.*$' %s > %s",1222 mr_asprintf(&command, "grep -E '^/dev/.*' %s > %s", 1271 1223 g_biggielist_txt, g_filelist_imagedevs); 1272 1224 paranoid_system(command); … … 1356 1308 int run_boot_loader(bool offer_to_hack_scripts) 1357 1309 { 1358 int res ;1310 int res = 0; 1359 1311 int retval = 0; 1360 1312 … … 1369 1321 read_cfg_var(g_mondo_cfg_file, "bootloader.device", device); 1370 1322 read_cfg_var(g_mondo_cfg_file, "bootloader.name", name); 1371 mr_asprintf(&tmp, "run_boot_loader: device='%s', name='%s'", device, name); 1372 mr_msg(2, tmp); 1373 mr_free(tmp); 1374 1323 mr_msg(2, "run_boot_loader: device='%s', name='%s'", device, name); 1375 1324 sync(); 1376 1325 if (!strcmp(name, "LILO")) { … … 1379 1328 res = run_elilo(offer_to_hack_scripts); 1380 1329 } else if (!strcmp(name, "GRUB")) { 1381 // if ( does_file_exist(DO_MBR_PLEASE) || (offer_to_hack_scripts && ask_me_yes_or_no("Because of bugs in GRUB, you're much better off running mondorestore --mbr after this program terminates. Are you sure you want to install GRUB right now?")))1382 // {1383 1330 res = run_grub(offer_to_hack_scripts, device); 1384 // unlink(DO_MBR_PLEASE);1385 // }1386 // else1387 // {1388 // mr_msg(1, "Not running run_grub(). Was a bad idea anyway.");1389 // res = 1;1390 // }1391 1331 } else if (!strcmp(name, "RAW")) { 1392 1332 res = run_raw_mbr(offer_to_hack_scripts, device); … … 1487 1427 1488 1428 assert_string_is_neither_NULL_nor_zerolength(bd); 1429 editor = find_my_editor(); 1489 1430 1490 1431 if (offer_to_run_stabgrub … … 1518 1459 newtSuspend(); 1519 1460 } 1520 editor = find_my_editor();1521 1461 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1522 1462 paranoid_system(tmp); … … 1524 1464 1525 1465 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/grub.conf", editor); 1526 mr_free(editor);1527 1528 1466 paranoid_system(tmp); 1529 1467 mr_free(tmp); … … 1578 1516 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 1579 1517 } 1518 mr_free(editor); 1580 1519 return (res); 1581 1520 } … … 1599 1538 int done = 0; 1600 1539 1540 editor = find_my_editor(); 1601 1541 if (offer_to_run_stabelilo 1602 1542 && ask_me_yes_or_no(_("Did you change the mountlist?"))) … … 1620 1560 newtSuspend(); 1621 1561 } 1622 editor = find_my_editor();1623 1562 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1624 1563 paranoid_system(tmp); … … 1626 1565 1627 1566 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/elilo.conf", editor); 1628 mr_free(editor);1629 1630 1567 paranoid_system(tmp); 1631 1568 mr_free(tmp); … … 1648 1585 res = TRUE; 1649 1586 } 1587 mr_free(editor); 1650 1588 return (res); 1651 1589 } … … 1676 1614 } 1677 1615 1616 editor = find_my_editor(); 1678 1617 if (offer_to_run_stablilo 1679 1618 && ask_me_yes_or_no(_("Did you change the mountlist?"))) { … … 1695 1634 newtSuspend(); 1696 1635 } 1697 editor = find_my_editor();1698 1636 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1699 1637 paranoid_system(tmp); … … 1701 1639 1702 1640 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor); 1703 mr_free(editor);1704 1705 1641 paranoid_system(tmp); 1706 1642 mr_free(tmp); … … 1709 1645 newtResume(); 1710 1646 } 1711 // newtCls();1712 1647 if (ask_me_yes_or_no(_("Edit them again?"))) { 1713 1648 continue; … … 1761 1696 " lilo -M /dev/sda", 3); 1762 1697 } 1698 mr_free(editor); 1763 1699 return (res); 1764 1700 } … … 1785 1721 assert_string_is_neither_NULL_nor_zerolength(bd); 1786 1722 1723 editor = find_my_editor(); 1787 1724 if (offer_to_hack_scripts 1788 1725 && ask_me_yes_or_no(_("Did you change the mountlist?"))) { … … 1797 1734 newtSuspend(); 1798 1735 } 1799 editor = find_my_editor();1800 1736 mr_asprintf(&tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1801 mr_free(editor);1802 1803 1737 paranoid_system(tmp); 1804 1738 mr_free(tmp); … … 1807 1741 newtResume(); 1808 1742 } 1809 // newtCls();1810 1743 } 1811 1744 popup_and_get_string(_("Boot device"), 1812 _ 1813 ("Please confirm/enter the boot device. If in doubt, try /dev/hda"), bd); 1745 _("Please confirm/enter the boot device. If in doubt, try /dev/hda"), bd); 1814 1746 mr_asprintf(&command, "stabraw-me %s", bd); 1815 1747 res = run_program_and_log_output(command, 3); … … 1826 1758 /* nuke mode */ 1827 1759 mvaddstr_and_log_it(g_currentY, 0, 1828 _ 1829 ("Restoring MBR... ")); 1760 _("Restoring MBR... ")); 1830 1761 mr_asprintf(&command, "raw-MR %s /tmp/mountlist.txt", bd); 1831 1762 mr_msg(2, "run_raw_mbr() --- command='%s'", command); … … 1841 1772 mvaddstr_and_log_it(g_currentY++, 74, _("Done.")); 1842 1773 } 1774 mr_free(editor); 1843 1775 return (res); 1844 1776 } … … 1954 1886 { 1955 1887 log_to_screen 1956 (_ 1957 ("Mondorestore is terminating in response to a signal from the OS")); 1888 (_("Mondorestore is terminating in response to a signal from the OS")); 1958 1889 paranoid_MR_finish(254); 1959 1890 } … … 2092 2023 mr_free(command); 2093 2024 } else { 2094 mr_asprintf(&tmp1, "%s%s", tmp, _("...not mounted anyway :-) OK")); 2095 mr_free(tmp); 2096 tmp = tmp1; 2025 mr_strcat(tmp, _("...not mounted anyway :-) OK")); 2097 2026 res = 0; 2098 2027 } 2099 2028 g_current_progress++; 2100 2029 if (res) { 2101 mr_asprintf(&tmp1, "%s%s", tmp, _("...Failed")); 2102 mr_free(tmp); 2103 tmp = tmp1; 2030 mr_strcat(tmp, _("...Failed")); 2104 2031 retval++; 2105 2032 log_to_screen(tmp); … … 2120 2047 log_to_screen(_("All partitions were unmounted OK.")); 2121 2048 } 2122 mr_free( (void*)mountlist);2049 mr_free(mountlist); 2123 2050 return (retval); 2124 2051 } … … 2182 2109 int res = 0; 2183 2110 2184 bool try_plan_B ;2111 bool try_plan_B = FALSE; 2185 2112 2186 2113 assert(bkpinfo != NULL); … … 2235 2162 mr_msg(2, 2236 2163 "Mounted floppy OK but I don't trust it because the archives might contain more up-to-date config file than the floppy does."); 2237 // NB: If busybox does not support 'mount -o loop' then Plan A WILL NOT WORK.2164 // NB: If busybox does not support 'mount -o loop' then Plan A WILL NOT WORK. 2238 2165 mr_msg(2, "Processing floppy (plan A?)"); 2239 2166 mr_asprintf(&ramdisk_fname, "%s/mindi.rdz", mountpt); … … 2355 2282 mr_free(command); 2356 2283 2357 mr_asprintf(&command, "cp -f %s/%s %s",tmp1, 2284 mr_asprintf(&command, "cp -f %s/%s %s", 2285 tmp1, 2358 2286 MOUNTLIST_FNAME_STUB, mountlist_file); 2359 2287 mr_free(tmp1); … … 2405 2333 mr_asprintf(&command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB); 2406 2334 mr_free(cfg_file); 2407 2408 2335 run_program_and_log_output(command, FALSE); 2409 2336 mr_free(command); … … 2411 2338 mr_asprintf(&command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB); 2412 2339 mr_free(mountlist_file); 2413 2414 2340 run_program_and_log_output(command, FALSE); 2415 2341 mr_free(command); … … 2451 2377 return; 2452 2378 } 2453 for (unfinished_mdstat_devices = i = 0; i <= raidlist->entries; 2454 i++) { 2379 for (unfinished_mdstat_devices = i = 0; i <= raidlist->entries; i++) { 2455 2380 if (raidlist->el[i].progress < wait_for_percentage) { 2456 2381 unfinished_mdstat_devices++;
Note:
See TracChangeset
for help on using the changeset viewer.