Changeset 2326 in MondoRescue
- Timestamp:
- Aug 18, 2009, 3:19:54 PM (15 years ago)
- Location:
- branches/2.2.10/mondo/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2325 r2326 616 616 } 617 617 618 if (!bkpinfo->nonbootable_backup 619 && (bkpinfo->boot_loader == '\0' 620 || bkpinfo->boot_device[0] == '\0')) { 618 if (!bkpinfo->nonbootable_backup && (bkpinfo->boot_loader == '\0' || bkpinfo->boot_device == NULL)) { 621 619 622 620 #ifdef __FreeBSD__ … … 660 658 bkpinfo->boot_loader = ch; 661 659 } 662 if (bkpinfo->boot_device [0] != '\0') {660 if (bkpinfo->boot_device != NULL) { 663 661 log_msg(2, "User specified boot device. It is '%s'.", bkpinfo->boot_device); 664 662 } else { 665 strcpy(bkpinfo->boot_device, bootdev);663 mr_asprintf(bkpinfo->boot_device, "%s", bootdev); 666 664 } 667 665 } -
branches/2.2.10/mondo/src/common/libmondo-cli.c
r2325 r2326 1326 1326 1327 1327 if (flag_set['f']) { 1328 strncpy(bkpinfo->boot_device, 1329 resolve_softlinks_to_get_to_actual_device_file(flag_val 1330 ['f']), 1331 MAX_STR_LEN / 4); 1328 mr_free(bkpinfo->boot_device); 1329 mr_asprintf(bkpinfo->boot_device, "%s", resolve_softlinks_to_get_to_actual_device_file(flag_val['f'])); 1332 1330 } 1333 1331 -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2325 r2326 1823 1823 if (archiving_to_media) { 1824 1824 1825 mr_free(bkpinfo->boot_device); 1825 1826 #ifdef __FreeBSD__ 1826 strcpy(bkpinfo->boot_device, 1827 call_program_and_get_last_line_of_output 1828 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 1827 #define EXAMPLEBD "/dev/ad0" 1828 mr_asprintf(bkpinfo->boot_device, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'")); 1829 1829 #else 1830 strcpy(bkpinfo->boot_device, 1831 call_program_and_get_last_line_of_output 1832 ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 1830 #define EXAMPLEBD "/dev/hda" 1831 mr_asprintf(bkpinfo->boot_device, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'")); 1833 1832 #endif 1834 1833 i = which_boot_loader(bkpinfo->boot_device); … … 1836 1835 { 1837 1836 1838 #ifdef __FreeBSD__ 1839 p = popup_and_get_string("Boot device", "What is your boot device? (e.g. /dev/ad0)", bkpinfo->boot_device); 1840 if (!p == NULL) { 1841 log_to_screen("User has chosen not to backup the PC"); 1842 finish(1); 1843 } 1844 strcpy(bkpinfo->boot_device, p); 1845 mr_free(p); 1846 i = which_boot_loader(bkpinfo->boot_device); 1847 #else 1848 p = popup_and_get_string("Boot device", "What is your boot device? (e.g. /dev/hda)", bkpinfo->boot_device); 1837 p = popup_and_get_string("Boot device", "What is your boot device? (e.g. "EXAMPLEBD")", bkpinfo->boot_device); 1838 #undef EXAMPLEBD 1849 1839 if (p == NULL) { 1850 1840 log_to_screen("User has chosen not to backup the PC"); 1851 1841 finish(1); 1852 1842 } 1853 strcpy(bkpinfo->boot_device, p); 1854 mr_free(p); 1855 1843 mr_free(bkpinfo->boot_device); 1844 bkpinfo->boot_device = p; 1845 #ifdef __FreeBSD__ 1846 i = which_boot_loader(bkpinfo->boot_device); 1847 #else 1856 1848 if (does_string_exist_in_boot_block(bkpinfo->boot_device, "LILO")) { 1857 1849 i = 'L'; … … 1867 1859 #endif 1868 1860 if (i == 'U') { 1869 if (ask_me_yes_or_no 1870 ("Unidentified boot loader. Shall I restore it byte-for-byte at restore time and hope for the best?")) 1871 { 1861 if (ask_me_yes_or_no("Unidentified boot loader. Shall I restore it byte-for-byte at restore time and hope for the best?")) { 1872 1862 i = 'R'; // raw 1873 1863 } else { 1874 log_to_screen 1875 ("I cannot find your boot loader. Please run mondoarchive with parameters."); 1864 log_to_screen("I cannot find your boot loader. Please run mondoarchive with parameters."); 1876 1865 finish(1); 1877 1866 } -
branches/2.2.10/mondo/src/common/libmondo-tools.c
r2325 r2326 478 478 479 479 if (bkpinfo->use_lzo) { 480 strcpy(bkpinfo->zip_exe, "lzop");480 mr_asprintf(bkpinfo->zip_exe, "lzop"); 481 481 strcpy(bkpinfo->zip_suffix, "lzo"); 482 482 } else if (bkpinfo->use_gzip) { 483 strcpy(bkpinfo->zip_exe, "gzip");483 mr_asprintf(bkpinfo->zip_exe, "gzip"); 484 484 strcpy(bkpinfo->zip_suffix, "gz"); 485 485 } else if (bkpinfo->compression_level != 0) { 486 strcpy(bkpinfo->zip_exe, "bzip2");486 mr_asprintf(bkpinfo->zip_exe, "bzip2"); 487 487 strcpy(bkpinfo->zip_suffix, "bz2"); 488 } else {489 bkpinfo->zip_exe[0] = bkpinfo->zip_suffix[0] = '\0';490 488 } 491 489 … … 798 796 799 797 mr_free(bkpinfo->media_device); 798 mr_free(bkpinfo->boot_device); 799 mr_free(bkpinfo->zip_exe); 800 800 mr_free(bkpinfo->isodir); 801 801 mr_free(bkpinfo->prefix); … … 827 827 } 828 828 bkpinfo->boot_loader = '\0'; 829 bkpinfo->boot_device [0] = '\0';830 bkpinfo->zip_exe [0] = '\0';829 bkpinfo->boot_device = NULL; 830 bkpinfo->zip_exe = NULL; 831 831 bkpinfo->zip_suffix[0] = '\0'; 832 832 bkpinfo->image_devs[0] = '\0'; … … 1223 1223 * If this is a distribution like Gentoo that doesn't keep /boot mounted, mount it. 1224 1224 */ 1225 void mount_boot_if_necessary() 1226 { 1225 void mount_boot_if_necessary() { 1227 1226 char *tmp = NULL; 1228 1227 char *command = NULL; … … 1238 1237 1239 1238 log_msg(4, "tmp = '%s'", tmp); 1240 if (tmp[0]) { 1241 log_it("/boot is at %s according to /etc/fstab", tmp); 1242 mr_asprintf(command, "mount | grep -Ew '/boot'"); 1243 mr_free(tmp); 1244 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 1245 mr_free(command); 1246 1247 if (!strcmp(tmp,"")) { 1248 if ((strstr(tmp, "LABEL=") || strstr(tmp,"UUID="))) { 1249 if (!run_program_and_log_output("mount /boot", 5)) { 1250 strcpy(g_boot_mountpt, "/boot"); 1251 log_msg(1, "Mounted /boot"); 1252 } else { 1253 log_it("...ignored cos it's a label or uuid :-)"); 1239 log_it("/boot is at %s according to /etc/fstab", tmp); 1240 mr_asprintf(command, "mount | grep -Ew '/boot'"); 1241 mr_free(tmp); 1242 mr_asprintf(tmp, call_program_and_get_last_line_of_output(command)); 1243 mr_free(command); 1244 1245 if (!strcmp(tmp,"")) { 1246 if ((strstr(tmp, "LABEL=") || strstr(tmp,"UUID="))) { 1247 if (!run_program_and_log_output("mount /boot", 5)) { 1248 strcpy(g_boot_mountpt, "/boot"); 1249 log_msg(1, "Mounted /boot"); 1250 } else { 1251 log_it("...ignored cos it's a label or uuid :-)"); 1252 } 1253 } else { 1254 mr_asprintf(command, "mount | grep -E '^%s'", tmp); 1255 log_msg(3, "command = %s", command); 1256 if (run_program_and_log_output(command, 5)) { 1257 strcpy(g_boot_mountpt, tmp); 1258 mr_free(tmp); 1259 log_it("%s (your /boot partition) is not mounted. I'll mount it before backing up", g_boot_mountpt); 1260 1261 mr_asprintf(tmp, "mount %s", g_boot_mountpt); 1262 if (run_program_and_log_output(tmp, 5)) { 1263 g_boot_mountpt[0] = '\0'; 1264 log_msg(1, "Plan B"); 1265 if (!run_program_and_log_output("mount /boot", 5)) { 1266 strcpy(g_boot_mountpt, "/boot"); 1267 log_msg(1, "Plan B worked"); 1268 } else { 1269 log_msg(1, 1270 "Plan B failed. Unable to mount /boot for backup purposes. This probably means /boot is mounted already, or doesn't have its own partition."); 1271 } 1254 1272 } 1255 } else {1256 mr_asprintf(command, "mount | grep -E '^%s'", tmp);1257 log_msg(3, "command = %s", command);1258 if (run_program_and_log_output(command, 5)) {1259 strcpy(g_boot_mountpt, tmp);1260 mr_free(tmp);1261 log_it("%s (your /boot partition) is not mounted. I'll mount it before backing up", g_boot_mountpt);1262 1263 mr_asprintf(tmp, "mount %s", g_boot_mountpt);1264 if (run_program_and_log_output(tmp, 5)) {1265 g_boot_mountpt[0] = '\0';1266 log_msg(1, "Plan B");1267 if (!run_program_and_log_output("mount /boot", 5)) {1268 strcpy(g_boot_mountpt, "/boot");1269 log_msg(1, "Plan B worked");1270 } else {1271 log_msg(1,1272 "Plan B failed. Unable to mount /boot for backup purposes. This probably means /boot is mounted already, or doesn't have its own partition.");1273 }1274 }1275 mr_free(tmp);1276 }1277 mr_free(command);1278 1273 } 1279 } 1280 } 1274 mr_free(command); 1275 } 1276 } 1277 mr_free(tmp); 1281 1278 log_msg(1, "Ended sub"); 1282 1279 } -
branches/2.2.10/mondo/src/common/libmondo-verify.c
r2325 r2326 204 204 * - @c restore_path 205 205 * - @c use_lzo 206 * - @c zip_exe207 206 * - @c zip_suffix 208 207 * @param mtpt The mountpoint the CD/DVD/ISO is mounted on. … … 432 431 mr_asprintf(outlog, "%s/afio.log", bkpinfo->tmpdir); 433 432 /* if programmer forgot to say which compression thingy to use then find out */ 434 if (strstr(tarball_fname, ".lzo") 435 && strcmp(bkpinfo->zip_suffix, "lzo")) { 433 if (strstr(tarball_fname, ".lzo") && strcmp(bkpinfo->zip_suffix, "lzo")) { 436 434 log_msg(2, "OK, I'm going to start using lzop."); 437 strcpy(bkpinfo->zip_exe, "lzop"); 435 mr_free(bkpinfo->zip_exe); 436 mr_asprintf(bkpinfo->zip_exe, "lzop"); 438 437 strcpy(bkpinfo->zip_suffix, "lzo"); 439 438 bkpinfo->use_lzo = TRUE; 440 439 bkpinfo->use_gzip = FALSE; 441 440 } 442 if (strstr(tarball_fname, ".gz") 443 && strcmp(bkpinfo->zip_suffix, "gz")) { 441 if (strstr(tarball_fname, ".gz") && strcmp(bkpinfo->zip_suffix, "gz")) { 444 442 log_msg(2, "OK, I'm going to start using gzip."); 445 strcpy(bkpinfo->zip_exe, "gzip"); 443 mr_free(bkpinfo->zip_exe); 444 mr_asprintf(bkpinfo->zip_exe, "gzip"); 446 445 strcpy(bkpinfo->zip_suffix, "gz"); 447 446 bkpinfo->use_lzo = FALSE; 448 447 bkpinfo->use_gzip = TRUE; 449 448 } 450 if (strstr(tarball_fname, ".bz2") 451 && strcmp(bkpinfo->zip_suffix, "bz2")) { 449 if (strstr(tarball_fname, ".bz2") && strcmp(bkpinfo->zip_suffix, "bz2")) { 452 450 log_msg(2, "OK, I'm going to start using bzip2."); 453 strcpy(bkpinfo->zip_exe, "bzip2"); 451 mr_free(bkpinfo->zip_exe); 452 mr_asprintf(bkpinfo->zip_exe, "bzip2"); 454 453 strcpy(bkpinfo->zip_suffix, "bz2"); 455 454 bkpinfo->use_lzo = FALSE; … … 463 462 } else { 464 463 bkpinfo->use_star = FALSE; 465 mr_asprintf(command, "afio -r -P %s -Z %s >> %s 2>> %s", bkpinfo->zip_exe, tarball_fname, outlog, outlog); 464 /* Here we suppose that there is always a compression program called */ 465 if (bkpinfo->zip_exe) { 466 mr_asprintf(command, "afio -r -P %s -Z %s >> %s 2>> %s", bkpinfo->zip_exe, tarball_fname, outlog, outlog); 467 } else { 468 mr_asprintf(command, "afio -r -Z %s >> %s 2>> %s", tarball_fname, outlog, outlog); 469 } 466 470 } 467 471 log_msg(6, "command=%s", command); -
branches/2.2.10/mondo/src/common/mondostructures.h
r2325 r2326 369 369 * to take truncate_to_drive_name() of where_is_root_mounted(). 370 370 */ 371 char boot_device[MAX_STR_LEN / 4];371 char *boot_device; 372 372 373 373 /** … … 376 376 * compression_level is 0. 377 377 */ 378 char zip_exe[MAX_STR_LEN / 4];378 char *zip_exe; 379 379 380 380 /** -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2325 r2326 895 895 mr_free(value); 896 896 897 bkpinfo->zip_ exe[0] = bkpinfo->zip_suffix[0] = '\0';897 bkpinfo->zip_suffix[0] = '\0'; 898 898 value = read_cfg_var(cfg_file, "use-lzo"); 899 899 if (value && strstr(value, "yes")) { 900 900 bkpinfo->use_lzo = TRUE; 901 901 bkpinfo->use_gzip = FALSE; 902 strcpy(bkpinfo->zip_exe, "lzop"); 902 mr_free(bkpinfo->zip_exe); 903 mr_asprintf(bkpinfo->zip_exe, "lzop"); 903 904 strcpy(bkpinfo->zip_suffix, "lzo"); 904 905 } … … 909 910 bkpinfo->use_lzo = FALSE; 910 911 bkpinfo->use_gzip = TRUE; 911 strcpy(bkpinfo->zip_exe, "gzip"); 912 mr_free(bkpinfo->zip_exe); 913 mr_asprintf(bkpinfo->zip_exe, "gzip"); 912 914 strcpy(bkpinfo->zip_suffix, "gz"); 913 915 } … … 918 920 bkpinfo->use_lzo = FALSE; 919 921 bkpinfo->use_gzip = FALSE; 920 strcpy(bkpinfo->zip_exe, "bzip2"); 922 mr_free(bkpinfo->zip_exe); 923 mr_asprintf(bkpinfo->zip_exe, "bzip2"); 921 924 strcpy(bkpinfo->zip_suffix, "bz2"); 922 925 } -
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2325 r2326 1488 1488 } 1489 1489 1490 if ( !bkpinfo->zip_exe[0]) {1490 if (bkpinfo->zip_exe == NULL) { 1491 1491 mr_asprintf(command, "cat > \"%s\"", file_to_openout); 1492 1492 } else { … … 1549 1549 paranoid_pclose(pout); 1550 1550 1551 if (bkpinfo->zip_exe [0]) {1551 if (bkpinfo->zip_exe != NULL) { 1552 1552 if (strcmp(bkpinfo->zip_exe, "gzip") == 0) { 1553 1553 /* Re-enable SIGPIPE for gzip */
Note:
See TracChangeset
for help on using the changeset viewer.