Changeset 2323 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-devices.c
- Timestamp:
- Aug 18, 2009, 3:05:43 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2322 r2323 111 111 bool is_this_a_ramdisk = FALSE; 112 112 113 mr_asprintf( &tmp, "%s", where_is_root_mounted());114 mr_asprintf( &comment, "root is currently mounted at %s\n", tmp);113 mr_asprintf(tmp, "%s", where_is_root_mounted()); 114 mr_asprintf(comment, "root is currently mounted at %s\n", tmp); 115 115 log_msg(0, comment); 116 116 mr_free(comment); … … 210 210 if (IS_THIS_A_STREAMING_BACKUP(g_backup_media_type) 211 211 && g_backup_media_type != udev) { 212 mr_asprintf( &command, "mt -f %s offline", dev);212 mr_asprintf(command, "mt -f %s offline", dev); 213 213 res1 = run_program_and_log_output(command, 1); 214 214 mr_free(command); … … 219 219 #ifdef __FreeBSD__ 220 220 if (strstr(dev, "acd")) { 221 mr_asprintf( &command, "cdcontrol -f %s eject", dev);221 mr_asprintf(command, "cdcontrol -f %s eject", dev); 222 222 } else { 223 mr_asprintf( &command, "camcontrol eject `echo %s | sed 's|/dev/||'`",223 mr_asprintf(command, "camcontrol eject `echo %s | sed 's|/dev/||'`", 224 224 dev); 225 225 } 226 226 #else 227 mr_asprintf( &command, "eject %s", dev);227 mr_asprintf(command, "eject %s", dev); 228 228 #endif 229 229 … … 250 250 #ifdef __FreeBSD__ 251 251 if (strstr(dev, "acd")) { 252 mr_asprintf( &command, "cdcontrol -f %s close", dev);252 mr_asprintf(command, "cdcontrol -f %s close", dev); 253 253 } else { 254 mr_asprintf( &command, "camcontrol load `echo %s | sed 's|/dev/||'`", dev);254 mr_asprintf(command, "camcontrol load `echo %s | sed 's|/dev/||'`", dev); 255 255 } 256 256 #else 257 mr_asprintf( &command, "eject -t %s", dev);257 mr_asprintf(command, "eject -t %s", dev); 258 258 #endif 259 259 i = run_program_and_log_output(command, FALSE); … … 277 277 assert_string_is_neither_NULL_nor_zerolength(device); 278 278 279 mr_asprintf( &tmp, "ls %s > /dev/null 2> /dev/null", device);279 mr_asprintf(tmp, "ls %s > /dev/null 2> /dev/null", device); 280 280 281 281 if (system(tmp)) { … … 336 336 // We assume here that this is running from mondorestore. (It is.) 337 337 tmp = build_partition_name(drive, partno); 338 mr_asprintf( &program, "ls %s %s >/dev/null 2>&1", drive, tmp);338 mr_asprintf(program, "ls %s %s >/dev/null 2>&1", drive, tmp); 339 339 mr_free(tmp); 340 340 … … 347 347 #endif 348 348 349 mr_asprintf( &program, "parted2fdisk -l %s 2> /dev/null", drive);349 mr_asprintf(program, "parted2fdisk -l %s 2> /dev/null", drive); 350 350 fin = popen(program, "r"); 351 351 if (!fin) { … … 394 394 assert_string_is_neither_NULL_nor_zerolength(str); 395 395 396 mr_asprintf( &command, "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, str);396 mr_asprintf(command, "dd if=%s bs=446 count=1 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, str); 397 397 i = system(command); 398 398 mr_free(command); … … 418 418 int i; 419 419 420 mr_asprintf( &command, "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, n, str);420 mr_asprintf(command, "dd if=%s bs=512 count=%i 2> /dev/null | strings | grep \"%s\" > /dev/null 2> /dev/null", dev, n, str); 421 421 i = system(command); 422 422 mr_free(command); … … 517 517 run_program_and_log_output("insmod ide-scsi", -1); 518 518 if (find_home_of_exe("cdrecord")) { 519 mr_asprintf( &cdr_exe, "cdrecord");519 mr_asprintf(cdr_exe, "cdrecord"); 520 520 } else { 521 mr_asprintf( &cdr_exe, "dvdrecord");521 mr_asprintf(cdr_exe, "dvdrecord"); 522 522 } 523 523 if (find_home_of_exe(cdr_exe)) { 524 mr_asprintf( &command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", cdr_exe);525 mr_asprintf( &tmp, "%s", call_program_and_get_last_line_of_output(command));524 mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", cdr_exe); 525 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 526 526 mr_free(command); 527 527 } … … 532 532 } else { 533 533 strcpy(cdrw_device, tmp); 534 mr_asprintf( &comment, "Found CDRW device - %s", cdrw_device);534 mr_asprintf(comment, "Found CDRW device - %s", cdrw_device); 535 535 log_it(comment); 536 536 strcpy(g_cdrw_drive_is_here, cdrw_device); … … 586 586 phrase_two[0] = '\0'; 587 587 #ifndef __FreeBSD__ 588 mr_asprintf( &dvd_last_resort, "%s", "");;588 mr_asprintf(dvd_last_resort, "%s", "");; 589 589 #endif 590 590 … … 606 606 } 607 607 608 mr_asprintf( &mountpoint, "%s/cd.mnt", bkpinfo->tmpdir);608 mr_asprintf(mountpoint, "%s/cd.mnt", bkpinfo->tmpdir); 609 609 make_hole_for_dir(mountpoint); 610 610 611 611 if (find_home_of_exe("cdrecord")) { 612 mr_asprintf( &cdr_exe, "cdrecord");612 mr_asprintf(cdr_exe, "cdrecord"); 613 613 } else { 614 mr_asprintf( &cdr_exe, "dvdrecord");614 mr_asprintf(cdr_exe, "dvdrecord"); 615 615 } 616 616 tmp[0] = '\0'; … … 628 628 } 629 629 630 mr_asprintf( &command, "%s -scanbus 2> /dev/null", cdr_exe);630 mr_asprintf(command, "%s -scanbus 2> /dev/null", cdr_exe); 631 631 fin = popen(command, "r"); 632 632 log_msg(4, "command=%s", command); … … 668 668 log_msg(4, "Not running phase two. String is empty."); 669 669 } else { 670 mr_asprintf( &command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two);670 mr_asprintf(command, "dmesg | grep \"%s\" 2> /dev/null", phrase_two); 671 671 fin = popen(command, "r"); 672 672 mr_free(command); … … 684 684 if (strstr(tmp, "DVD")) { 685 685 mr_free(dvd_last_resort); 686 mr_asprintf( &dvd_last_resort, "/dev/%s", tmp);686 mr_asprintf(dvd_last_resort, "/dev/%s", tmp); 687 687 log_msg(4, 688 688 "Ignoring '%s' because it's a DVD drive", … … 815 815 found_it = FALSE; 816 816 } else { 817 mr_asprintf( &command, "umount %s", output);817 mr_asprintf(command, "umount %s", output); 818 818 paranoid_system(command); 819 819 mr_free(command); … … 838 838 } 839 839 840 mr_asprintf( &command, "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", cdr_exe, g_cdrw_drive_is_here);840 mr_asprintf(command, "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", cdr_exe, g_cdrw_drive_is_here); 841 841 log_msg(1, "command=%s", command); 842 mr_asprintf( &tmp1, "%s", call_program_and_get_last_line_of_output(command));842 mr_asprintf(tmp1, "%s", call_program_and_get_last_line_of_output(command)); 843 843 mr_free(command); 844 844 … … 876 876 } 877 877 878 mr_asprintf( &tmp, "%s", call_program_and_get_last_line_of_output878 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output 879 879 ("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1") 880 880 ); … … 882 882 if (!tmp[0]) 883 883 mr_free(tmp); 884 mr_asprintf( &tmp, "%s", call_program_and_get_last_line_of_output884 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output 885 885 ("cdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1") 886 886 ); … … 1026 1026 assert_string_is_neither_NULL_nor_zerolength(format); 1027 1027 1028 mr_asprintf( &format_sz, "%s ", format);1028 mr_asprintf(format_sz, "%s ", format); 1029 1029 1030 1030 #ifdef __FreeBSD__ 1031 mr_asprintf( &command, "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '");1031 mr_asprintf(command, "lsvfs | tr -s '\t' ' ' | grep -v Filesys | grep -v -- -- | cut -d' ' -f1 | tr -s '\n' ' '"); 1032 1032 #else 1033 mr_asprintf( &command, "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");1033 mr_asprintf(command, "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '"); 1034 1034 #endif 1035 1035 … … 1094 1094 log_msg(1, "%s needs to have a '/' prefixed - I'll do it", 1095 1095 device_raw); 1096 mr_asprintf( &tmp, "/%s", device_raw);1096 mr_asprintf(tmp, "/%s", device_raw); 1097 1097 } else { 1098 mr_asprintf( &tmp, "%s", device_raw);1098 mr_asprintf(tmp, "%s", device_raw); 1099 1099 } 1100 1100 log_msg(1, "Is %s mounted?", tmp); … … 1105 1105 return(FALSE); 1106 1106 } 1107 mr_asprintf( &device_with_tab, "%s\t", tmp);1108 mr_asprintf( &device_with_space, "%s ", tmp);1107 mr_asprintf(device_with_tab, "%s\t", tmp); 1108 mr_asprintf(device_with_space, "%s ", tmp); 1109 1109 mr_free(tmp); 1110 1110 … … 1126 1126 mr_free(device_with_space); 1127 1127 paranoid_pclose(fin); 1128 mr_asprintf( &tmp, "%s | grep -E \"^%s\" > /dev/null 2> /dev/null", SWAPLIST_COMMAND, device_with_space);1128 mr_asprintf(tmp, "%s | grep -E \"^%s\" > /dev/null 2> /dev/null", SWAPLIST_COMMAND, device_with_space); 1129 1129 log_msg(4, "tmp (command) = '%s'", tmp); 1130 1130 if (!system(tmp)) { … … 1193 1193 (call_program_and_get_last_line_of_output 1194 1194 ("/sbin/sysctl -n kern.osreldate")) < 500000) { 1195 mr_asprintf( &command, "vnconfig -d %s", dname);1195 mr_asprintf(command, "vnconfig -d %s", dname); 1196 1196 } else { 1197 mr_asprintf( &command, "mdconfig -d -u %s", dname);1197 mr_asprintf(command, "mdconfig -d -u %s", dname); 1198 1198 } 1199 1199 res = system(command); … … 1227 1227 1228 1228 #ifdef __FreeBSD__ 1229 mr_asprintf( &command, "mount_vfat %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE);1229 mr_asprintf(command, "mount_vfat %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE); 1230 1230 1231 1231 #else 1232 mr_asprintf( &command, "mount %s -t vfat %s 2>> %s", device, mountpoint, MONDO_LOGFILE);1232 mr_asprintf(command, "mount %s -t vfat %s 2>> %s", device, mountpoint, MONDO_LOGFILE); 1233 1233 #endif 1234 1234 … … 1267 1267 } 1268 1268 #ifndef __FreeBSD__ 1269 mr_asprintf( &options, "ro");1269 mr_asprintf(options, "ro"); 1270 1270 #endif 1271 1271 … … 1273 1273 1274 1274 #ifdef __FreeBSD__ 1275 mr_asprintf( &dev, "%s", make_vn(device));1275 mr_asprintf(dev, "%s", make_vn(device)); 1276 1276 if (!dev) { 1277 mr_asprintf( &command, "Unable to mount ISO (make_vn(%s) failed)", device);1277 mr_asprintf(command, "Unable to mount ISO (make_vn(%s) failed)", device); 1278 1278 fatal_error(command); 1279 1279 } … … 1290 1290 1291 1291 #ifdef __FreeBSD__ 1292 mr_asprintf( &command, "mount_cd9660 -r %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE);1292 mr_asprintf(command, "mount_cd9660 -r %s %s 2>> %s", device, mountpoint, MONDO_LOGFILE); 1293 1293 1294 1294 #else 1295 mr_asprintf( &command, "mount %s -o %s -t iso9660 %s 2>> %s", device, options, mountpoint, MONDO_LOGFILE);1295 mr_asprintf(command, "mount %s -o %s -t iso9660 %s 2>> %s", device, options, mountpoint, MONDO_LOGFILE); 1296 1296 paranoid_free(options); 1297 1297 #endif … … 1334 1334 /*@ buffers ********************************************************* */ 1335 1335 char *tmp = NULL; 1336 char *p = NULL; 1336 1337 char *mds = NULL; 1337 1338 char *request = NULL; … … 1347 1348 return; 1348 1349 } 1349 mr_asprintf( &tmp, "mkdir -p " MNT_CDROM);1350 mr_asprintf(tmp, "mkdir -p " MNT_CDROM); 1350 1351 run_program_and_log_output(tmp, 5); 1351 1352 mr_free(tmp); … … 1360 1361 run_program_and_log_output("umount " MNT_CDROM, 5); 1361 1362 } 1362 mr_asprintf( &tmp, "mkdir -p %s/isodir &> /dev/null", bkpinfo->tmpdir);1363 mr_asprintf(tmp, "mkdir -p %s/isodir &> /dev/null", bkpinfo->tmpdir); 1363 1364 (void)system(tmp); 1364 1365 mr_free(tmp); 1365 1366 1366 mr_asprintf( &tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want);1367 mr_asprintf(tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want); 1367 1368 if (!does_file_exist(tmp)) { 1368 1369 mr_free(tmp); 1369 mr_asprintf( &tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want);1370 mr_asprintf(tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, bkpinfo->nfs_remote_dir, bkpinfo->prefix, cd_number_i_want); 1370 1371 if (does_file_exist(tmp)) { 1371 1372 log_msg(1, "FIXME - hacking bkpinfo->isodir from '%s' to %s/isodir", bkpinfo->isodir, bkpinfo->tmpdir); 1372 sprintf(bkpinfo->isodir, "%s/isodir", bkpinfo->tmpdir); 1373 mr_free(bkpinfo->isodir); 1374 mr_asprintf(p, "%s/isodir", bkpinfo->tmpdir); 1375 bkpinfo->isodir = p; 1373 1376 } 1374 1377 } … … 1384 1387 cd_number_i_want); 1385 1388 mds = media_descriptor_string(bkpinfo->backup_media_type); 1386 mr_asprintf( &tmp, "Insisting on %s #%d", mds, cd_number_i_want);1387 mr_asprintf( &request, "Please insert %s #%d and press Enter.", mds, cd_number_i_want);1389 mr_asprintf(tmp, "Insisting on %s #%d", mds, cd_number_i_want); 1390 mr_asprintf(request, "Please insert %s #%d and press Enter.", mds, cd_number_i_want); 1388 1391 mr_free(mds); 1389 1392 log_msg(3, tmp); … … 1499 1502 } 1500 1503 mds = media_descriptor_string(bkpinfo->backup_media_type); 1501 mr_asprintf( &comment, "What speed is your %s (re)writer?", mds);1504 mr_asprintf(comment, "What speed is your %s (re)writer?", mds); 1502 1505 if (bkpinfo->backup_media_type == dvd) { 1503 1506 find_dvd_device(bkpinfo->media_device, FALSE); 1504 strcpy(tmp1, "1");1505 mr_asprintf( &sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB1507 mr_asprintf(tmp, "1"); 1508 mr_asprintf(sz_size, "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4482 MB 1506 1509 log_msg(1, "Setting to DVD defaults"); 1507 1510 } else { 1508 1511 strcpy(bkpinfo->media_device, VANILLA_SCSI_CDROM); 1509 strcpy(tmp1, "4");1510 mr_asprintf( &sz_size, "%d", 650);1512 mr_asprintf(tmp, "4"); 1513 mr_asprintf(sz_size, "%d", 650); 1511 1514 log_msg(1, "Setting to CD defaults"); 1512 1515 } … … 1527 1530 bkpinfo->cdrw_speed = atoi(tmp1); // if DVD then this shouldn't ever be used anyway :) 1528 1531 1529 mr_asprintf( &comment, "How much data (in Megabytes) will each %s store?", mds);1532 mr_asprintf(comment, "How much data (in Megabytes) will each %s store?", mds); 1530 1533 mr_free(mds); 1531 1534 p = popup_and_get_string("Size", comment, sz_size); … … 1567 1570 log_msg(1, "bkpinfo->media_device = %s", 1568 1571 bkpinfo->media_device); 1569 mr_asprintf( &comment, "Please specify your %s drive's /dev entry", mds);1572 mr_asprintf(comment, "Please specify your %s drive's /dev entry", mds); 1570 1573 p = popup_and_get_string("Device?", comment, bkpinfo->media_device); 1571 1574 mr_free(comment); … … 1585 1588 if (bkpinfo->media_device[0]) { 1586 1589 if (bkpinfo->backup_media_type == usb) { 1587 mr_asprintf( &tmp, "I think your %s media corresponds to %s. Is this correct?", mds, bkpinfo->media_device);1590 mr_asprintf(tmp, "I think your %s media corresponds to %s. Is this correct?", mds, bkpinfo->media_device); 1588 1591 } else { 1589 mr_asprintf( &tmp, "I think I've found your %s burner at SCSI node %s. Is this correct? (Say no if you have an IDE burner and you are running a 2.6 kernel. You will then be prompted for further details.)", mds, bkpinfo->media_device);1592 mr_asprintf(tmp, "I think I've found your %s burner at SCSI node %s. Is this correct? (Say no if you have an IDE burner and you are running a 2.6 kernel. You will then be prompted for further details.)", mds, bkpinfo->media_device); 1590 1593 } 1591 1594 if (!ask_me_yes_or_no(tmp)) { … … 1648 1651 } 1649 1652 if (bkpinfo->media_device[0]) { 1650 mr_asprintf( &tmp, "I think I've found your tape streamer at %s; am I right on the money?", bkpinfo->media_device);1653 mr_asprintf(tmp, "I think I've found your tape streamer at %s; am I right on the money?", bkpinfo->media_device); 1651 1654 if (!ask_me_yes_or_no(tmp)) { 1652 1655 bkpinfo->media_device[0] = '\0'; … … 1663 1666 mr_free(p); 1664 1667 } 1665 mr_asprintf( &tmp, "ls -l %s", bkpinfo->media_device);1668 mr_asprintf(tmp, "ls -l %s", bkpinfo->media_device); 1666 1669 if (run_program_and_log_output(tmp, FALSE)) { 1667 1670 log_to_screen("User has not specified a valid /dev entry"); … … 1726 1729 if (bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] == '/') 1727 1730 bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] = '\0'; 1728 mr_asprintf( &command, "mount | grep \"%s \" | cut -d' ' -f3",1729 bkpinfo->nfs_mount);1730 strcpy(bkpinfo->isodir,1731 call_program_and_get_last_line_of_output(command));1731 mr_asprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", bkpinfo->nfs_mount); 1732 mr_free(bkpinfo->isodir); 1733 mr_asprintf(p, "%s", call_program_and_get_last_line_of_output(command)); 1734 bkpinfo->isodir = p; 1732 1735 mr_free(command); 1733 1736 1734 1737 if (!bkpinfo->restore_data) { 1735 mr_asprintf( &comment, "How much data (in Megabytes) will each media store?");1738 mr_asprintf(comment, "How much data (in Megabytes) will each media store?"); 1736 1739 // BERLIOS: 4480 shouldn't be hardcoded here 1737 1740 sz_size = popup_and_get_string("Size", comment, "4480"); … … 1742 1745 } 1743 1746 } else { 1744 mr_asprintf( &sz_size, "0");1747 mr_asprintf(sz_size, "0"); 1745 1748 } 1746 1749 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { … … 1754 1757 } 1755 1758 if (bkpinfo->disaster_recovery) { 1756 mr_asprintf( &command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir);1759 mr_asprintf(command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir); 1757 1760 (void)system(command); 1758 1761 mr_free(command); … … 1767 1770 } 1768 1771 /* Initiate bkpinfo isodir path from running environment if mount already done */ 1772 mr_free(bkpinfo->isodir); 1769 1773 if (is_this_device_mounted(bkpinfo->nfs_mount)) { 1770 strcpy(bkpinfo->isodir,1771 call_program_and_get_last_line_of_output1772 ("mount | grep \":\" | cut -d' ' -f3 | head -n1")); 1774 mr_asprintf(p, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1")); 1775 bkpinfo->isodir = p; 1776 1773 1777 } else { 1774 sprintf(bkpinfo->isodir, "%s/nfsdir", bkpinfo->tmpdir); 1775 mr_asprintf(&command, "mkdir -p %s", bkpinfo->isodir); 1778 mr_asprintf(p, "%s/nfsdir", bkpinfo->tmpdir); 1779 bkpinfo->isodir = p; 1780 mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir); 1776 1781 run_program_and_log_output(command, 5); 1777 1782 mr_free(command); 1778 1783 1779 mr_asprintf( &tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount, bkpinfo->isodir);1784 mr_asprintf(tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount, bkpinfo->isodir); 1780 1785 run_program_and_log_output(tmp, 3); 1781 1786 mr_free(tmp); … … 1820 1825 finish(1); 1821 1826 } 1822 strcpy(bkpinfo->isodir,p); 1823 mr_free(p); 1827 bkpinfo->isodir = p; 1824 1828 1825 1829 if (archiving_to_media) { … … 1918 1922 bkpinfo->boot_loader = i; 1919 1923 mr_free(bkpinfo->include_paths); 1920 mr_asprintf( &p, "/");1924 mr_asprintf(p, "/"); 1921 1925 bkpinfo->include_paths = p; 1922 1926 … … 1929 1933 bkpinfo->include_paths = p; 1930 1934 1931 mr_asprintf( &tmp, "%s", list_of_NFS_mounts_only());1935 mr_asprintf(tmp, "%s", list_of_NFS_mounts_only()); 1932 1936 if (strlen(tmp) > 2) { 1933 1937 mr_strcat(bkpinfo->exclude_paths, " %s",tmp); … … 1935 1939 mr_free(tmp); 1936 1940 // NTFS 1937 strcpy(tmp1, call_program_and_get_last_line_of_output("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'"));1938 if (strlen(tmp 1) > 2) {1941 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'")); 1942 if (strlen(tmp) > 2) { 1939 1943 p = popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp); 1940 1944 … … 2008 2012 #else 2009 2013 if (bkpinfo->backup_media_type == nfs) { 2010 log_msg(3, "I think the NFS mount is mounted at %s", 2011 bkpinfo->isodir); 2014 log_msg(3, "I think the NFS mount is mounted at %s", bkpinfo->isodir); 2012 2015 } 2013 2016 log_it("isodir = %s", bkpinfo->isodir); … … 2061 2064 static char result_sz[1024]; 2062 2065 2063 mr_asprintf( &exclude_these_directories,"%s",list_of_NFS_mounts_only());2064 mr_asprintf( &exclude_these_devices,"%s", call_program_and_get_last_line_of_output("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'"));2066 mr_asprintf(exclude_these_directories,"%s",list_of_NFS_mounts_only()); 2067 mr_asprintf(exclude_these_devices,"%s", call_program_and_get_last_line_of_output("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'")); 2065 2068 snprintf(result_sz, 1023, "%s %s", exclude_these_directories, exclude_these_devices); 2066 2069 mr_free(exclude_these_devices); … … 2083 2086 static char result_sz[512]; 2084 2087 2085 mr_asprintf( &exclude_these_directories,"%s", call_program_and_get_last_line_of_output("mount -t coda,ncpfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'"));2088 mr_asprintf(exclude_these_directories,"%s", call_program_and_get_last_line_of_output("mount -t coda,ncpfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'")); 2086 2089 snprintf(result_sz, 511, "%s", exclude_these_directories); 2087 2090 mr_free(exclude_these_directories); … … 2112 2115 make_hole_for_file(store_name_here); 2113 2116 mkfifo(store_name_here, S_IRWXU | S_IRWXG); 2114 mr_asprintf( &tmp, "chmod 770 %s", store_name_here);2117 mr_asprintf(tmp, "chmod 770 %s", store_name_here); 2115 2118 paranoid_system(tmp); 2116 2119 mr_free(tmp); … … 2135 2138 2136 2139 #ifdef __FreeBSD__ 2137 mr_asprintf( &tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));2140 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'")); 2138 2141 #else 2139 mr_asprintf( &tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x vfat -x ntfs -x ntfs-3g -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660| sed 's/ /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));2142 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x vfat -x ntfs -x ntfs-3g -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660| sed 's/ /devdev/' | tr -s '\t' ' ' | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'")); 2140 2143 #endif 2141 2144 2142 2145 if (tmp[0] != '/') { 2143 mr_asprintf( &sz, "%s", tmp);2146 mr_asprintf(sz, "%s", tmp); 2144 2147 mr_free(tmp); 2145 mr_asprintf( &tmp, "/%s", sz);2148 mr_asprintf(tmp, "/%s", sz); 2146 2149 mr_free(sz); 2147 2150 } … … 2149 2152 fatal_error("I couldn't figure out the scratchdir!"); 2150 2153 } 2151 mr_asprintf( &sz, "%s/mondo.scratch.%d", tmp, (int) (random() % 32768));2154 mr_asprintf(sz, "%s/mondo.scratch.%d", tmp, (int) (random() % 32768)); 2152 2155 mr_free(bkpinfo->scratchdir); 2153 2156 bkpinfo->scratchdir = sz; 2154 2157 log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir); 2155 2158 2156 mr_asprintf( &command, "rm -Rf %s/mondo.scratch.*", tmp);2159 mr_asprintf(command, "rm -Rf %s/mondo.scratch.*", tmp); 2157 2160 mr_free(tmp); 2158 2161 … … 2192 2195 return (FALSE); 2193 2196 } 2194 mr_asprintf( &command, "dd bs=%ld count=1 if=%s of=/dev/null &> /dev/null", 512L, dev);2197 mr_asprintf(command, "dd bs=%ld count=1 if=%s of=/dev/null &> /dev/null", 512L, dev); 2195 2198 if (!run_program_and_log_output(command, FALSE) 2196 2199 && !run_program_and_log_output(command, FALSE)) { … … 2227 2230 // log_it("Asking what_number_cd_is_this"); 2228 2231 if (g_ISO_restore_mode) { 2229 mr_asprintf( &tmp, "mount | grep iso9660 | awk '{print $3;}'");2230 2231 mr_asprintf( &mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER");2232 mr_asprintf(tmp, "mount | grep iso9660 | awk '{print $3;}'"); 2233 2234 mr_asprintf(mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER"); 2232 2235 cd_number = atoi(last_line_of_file(mountdev)); 2233 2236 paranoid_free(mountdev); … … 2237 2240 } 2238 2241 2239 mr_asprintf( &mountdev, "%s", bkpinfo->media_device);2242 mr_asprintf(mountdev, "%s", bkpinfo->media_device); 2240 2243 if (!mountdev[0]) { 2241 2244 log_it … … 2370 2373 assert(which_device != NULL); 2371 2374 2372 mr_asprintf( &list_drives_cmd, "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", where_is_root_mounted());2375 mr_asprintf(list_drives_cmd, "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", where_is_root_mounted()); 2373 2376 log_it("list_drives_cmd = %s", list_drives_cmd); 2374 2377 … … 2412 2415 } else { 2413 2416 // We need to look on each partition then 2414 mr_asprintf( &list_drives_cmd, "parted2fdisk -l 2>/dev/null | grep -E \"^/dev/\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/");2417 mr_asprintf(list_drives_cmd, "parted2fdisk -l 2>/dev/null | grep -E \"^/dev/\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/"); 2415 2418 log_it("list_drives_cmd = %s", list_drives_cmd); 2416 2419 … … 2513 2516 while (S_ISLNK(statbuf.st_mode)) { 2514 2517 log_msg(1, "curr_fname = %s", curr_fname); 2515 mr_asprintf( &command, "file %s", curr_fname);2516 mr_asprintf( &tmp, "%s", call_program_and_get_last_line_of_output(command));2518 mr_asprintf(command, "file %s", curr_fname); 2519 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 2517 2520 mr_free(command); 2518 2521 for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' '; 2519 2522 p--); 2520 2523 p++; 2521 mr_asprintf( &scratch, "%s", p);2524 mr_asprintf(scratch, "%s", p); 2522 2525 for (p = scratch; *p != '\0' && *p != '\''; p++); 2523 2526 *p = '\0'; … … 2563 2566 #endif 2564 2567 log_msg(0, "Looking for partition table format type"); 2565 mr_asprintf( &fdisk, "/sbin/parted2fdisk");2568 mr_asprintf(fdisk, "/sbin/parted2fdisk"); 2566 2569 log_msg(1, "Using %s", fdisk); 2567 mr_asprintf( &command, "%s -l %s | grep 'EFI GPT'", fdisk, drive);2570 mr_asprintf(command, "%s -l %s | grep 'EFI GPT'", fdisk, drive); 2568 2571 mr_free(fdisk); 2569 2572 2570 mr_asprintf( &tmp, "%s", call_program_and_get_last_line_of_output(command));2573 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 2571 2574 mr_free(command); 2572 2575
Note:
See TracChangeset
for help on using the changeset viewer.