Changeset 3147 in MondoRescue for branches/3.1/mondo/src/common
- Timestamp:
- Jun 19, 2013, 8:34:46 AM (11 years ago)
- Location:
- branches/3.1/mondo/src/common
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/mondo/src/common/libmondo-archive.c
r2937 r3147 213 213 paranoid_free(tmp); 214 214 215 mr_asprintf(command, "star H=exustar list=%s -c " STAR_ACL_SZ " file=%s", filelist, fname);215 mr_asprintf(command, "star H=exustar list=%s -c -sparse " STAR_ACL_SZ " file=%s", filelist, fname); 216 216 if (bkpinfo->use_lzo) { 217 217 mr_free(command); … … 511 511 char *use_star_sz = NULL; 512 512 char *bootldr_str = NULL; 513 char *bootldr_ver = NULL; 513 514 char *tape_device = NULL; 514 515 char *broken_bios_sz = NULL; … … 682 683 run_program_and_log_output("ln -sf /boot/grub/grub.conf /boot/grub/menu.lst", 5); 683 684 } 684 if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg"))) { 685 fatal_error("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst or /boot/grub/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?"); 686 } 685 if ((!does_file_exist("/boot/grub/menu.lst")) && (!does_file_exist("/boot/grub/grub.cfg")) && (!does_file_exist("/boot/grub2/grub.cfg"))) { 686 fatal_error("The de facto standard location for your boot loader's config file is /boot/grub/menu.lst, /boot/grub/grub.cfg, or /boot/grub2/grub.cfg but I cannot find it there. What is wrong with your Linux distribution?"); 687 } 688 mr_asprintf(&bootldr_ver, "%s", call_program_and_get_last_line_of_output("grub --version")); 687 689 } else if (bkpinfo->boot_loader == 'E') { 688 690 mr_asprintf(bootldr_str, "ELILO"); … … 719 721 } 720 722 log_to_screen("Your boot loader is %s and it boots from %s", bootldr_str, bkpinfo->boot_device); 723 if (bootldr_ver != NULL) { 724 mr_asprintf(&tmp, "Boot loader version string: %s", bootldr_ver); 725 log_to_screen(tmp); 726 mr_free(tmp); 727 } 721 728 722 729 mr_asprintf(tmp, "%s/BOOTLOADER.DEVICE", bkpinfo->tmpdir); … … 927 934 char *curr_acl_list_fname = NULL; 928 935 929 struct s_bkpinfo *bkpinfo_bis;930 936 char *tmp = NULL; 931 937 int res = 0, retval = 0; … … 940 946 p_next_set_to_archive = (int *) (inbuf + 8); 941 947 p_list_of_fileset_flags = (char *) (inbuf + 12); 942 bkpinfo_bis = (struct s_bkpinfo *) (inbuf + BKPINFO_LOC_OFFSET);943 948 944 949 mr_asprintf(archiving_filelist_fname, FILELIST_FNAME_RAW_SZ, bkpinfo->tmpdir, 0L); … … 1474 1479 1475 1480 log_msg(2, "make_usb_fs --- scratchdir=%s", bkpinfo->scratchdir); 1476 (void)getcwd(old_pwd, MAX_STR_LEN - 1);1481 tmp1 = getcwd(old_pwd, MAX_STR_LEN - 1); 1477 1482 mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir); 1478 1483 run_program_and_log_output(tmp, FALSE); 1479 1484 mr_free(tmp); 1480 (void)chdir(bkpinfo->scratchdir); 1485 if (chdir(bkpinfo->scratchdir)) { 1486 // FIXME 1487 } 1481 1488 1482 1489 mds = media_descriptor_string(bkpinfo->backup_media_type); … … 1542 1549 } 1543 1550 1544 (void)chdir(old_pwd); 1551 if (chdir(old_pwd)) { 1552 // FIXME 1553 } 1545 1554 if (retval) { 1546 1555 log_msg(1, "WARNING - make_usb_fs returned an error"); … … 1599 1608 1600 1609 log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", bkpinfo->scratchdir, destfile); 1601 (void)getcwd(old_pwd, MAX_STR_LEN - 1);1610 tmp2 = getcwd(old_pwd, MAX_STR_LEN - 1); 1602 1611 mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir); 1603 1612 run_program_and_log_output(tmp, FALSE); 1604 1613 mr_free(tmp); 1605 1614 1606 chdir(bkpinfo->scratchdir); 1615 if (chdir(bkpinfo->scratchdir)) { 1616 // FIXME 1617 } 1607 1618 1608 1619 if (bkpinfo->call_before_iso) { … … 1813 1824 } 1814 1825 1815 chdir(old_pwd); 1826 if (chdir(old_pwd)) { 1827 // FIXME 1828 } 1816 1829 if (retval) { 1817 1830 log_msg(1, "WARNING - make_iso_fs returned an error"); … … 1866 1879 /*@ pointers ******************************************* */ 1867 1880 FILE *fin = NULL; 1881 char *q; 1868 1882 1869 1883 /*@ buffers ******************************************** */ … … 2411 2425 /*@ long long ****************************************************** */ 2412 2426 off_t length_of_incoming_file = (off_t)0; 2413 t_archtype type;2414 2427 va_list ap; 2415 2428 … … 2433 2446 write_header_block_to_stream(length_of_incoming_file, curr_file, 2434 2447 start_chr); 2435 if (strstr(curr_file, ".afio.") || strstr(curr_file, ".star.")) {2436 type = fileset;2437 } else if (strstr(curr_file, "slice")) {2438 type = biggieslice;2439 } else {2440 type = other;2441 }2442 2448 res = write_file_to_stream_from_file(curr_file); 2443 2449 retval += res; … … 2798 2804 mr_free(tmp); 2799 2805 2800 (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout); 2801 fclose(fout); 2802 2806 res = fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout); 2807 if (fout != NULL) { 2808 paranoid_fclose(fout); 2809 } 2803 2810 log_msg(1, "Opening in %s; slicing it and writing to CD/tape", file_to_openin); 2804 2811 if (!(fin = fopen(file_to_openin, "r"))) { … … 2839 2846 if (blksize > 0) { 2840 2847 totalread = totalread + blksize; 2841 (void)fwrite(tempblock, 1, blksize, fout);2848 res = fwrite(tempblock, 1, blksize, fout); 2842 2849 } else { 2843 2850 break; … … 3131 3138 log_to_screen("Please reboot from the 1st %s in Compare Mode, as a precaution.", mds); 3132 3139 mr_free(mds); 3133 chdir("/"); 3140 if (chdir("/")) { 3141 // FIXME 3142 } 3134 3143 log_it("Before calling verification of image()"); 3135 3144 if (bkpinfo->backup_media_type == usb) { … … 3209 3218 assert(bkpinfo != NULL); 3210 3219 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 3211 chdir("/"); 3220 if (chdir("/")) { 3221 // FIXME 3222 } 3212 3223 mvaddstr_and_log_it(g_currentY, 0, 3213 3224 "Verifying archives against live filesystem"); … … 3232 3243 bkpinfo->media_device = find_cdrom_device(FALSE); // replace 0,0,0 with /dev/cdrom 3233 3244 } 3234 chdir("/"); 3245 if (chdir("/")) { 3246 // FIXME 3247 } 3235 3248 for (cdno = 1; cdno < 99 && bkpinfo->verify_data; cdno++) { 3236 3249 if (cdno != g_current_media_number) { … … 3253 3266 } 3254 3267 mr_asprintf(tmp, "grep 'afio: ' %s | sed 's/afio: //' | grep -vE '^/dev/.*$' >> %s/changed.files", MONDO_LOGFILE, MONDO_CACHE); 3255 (void)system(tmp);3268 res = system(tmp); 3256 3269 mr_free(tmp); 3257 3270 3258 3271 mr_asprintf(tmp, "grep 'star: ' %s | sed 's/star: //' | grep -vE '^/dev/.*$' >> %s/changed.files", MONDO_LOGFILE, MONDO_CACHE); 3259 (void)system(tmp);3272 res = system(tmp); 3260 3273 mr_free(tmp); 3261 3274 run_program_and_log_output("umount " MNT_CDROM, FALSE); -
branches/3.1/mondo/src/common/libmondo-cli.c
r2937 r3147 20 20 extern int g_loglevel; 21 21 extern bool g_text_mode; 22 extern bool g_fail_immediately; 22 23 extern char g_startdir[MAX_STR_LEN]; ///< ????? @bug ????? 23 24 extern char *MONDO_OPTIONS; … … 53 54 54 55 extern void free_MR_global_filenames(void); 56 57 long g_max_biggie_size = BIGGIEMAXSIZE; 55 58 56 59 /** … … 101 104 mr_free(tmp); 102 105 106 /* Before erasing dirs go into a safe place */ 107 if (chdir("/tmp")) { 108 // FIXME 109 } 110 mr_asprintf(tmp, "rm -Rf %s/tmp.mondo.*", bkpinfo->tmpdir); 111 paranoid_system(tmp); 112 mr_free(tmp); 113 103 114 mr_asprintf(tmp, "mkdir -p %s", bkpinfo->scratchdir); 104 115 paranoid_system(tmp); … … 162 173 int i = 0; 163 174 int retval = 0; 164 int percent = 0;165 int lastpos = 0;166 175 167 176 /*@ buffers ** */ … … 355 364 mr_free(p); 356 365 log_to_screen("You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']); 357 percent = 0;358 366 } 359 367 … … 498 506 if (strstr(bkpinfo->netfs_proto, "sshfs")) { 499 507 mr_asprintf(tmp1, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount); 508 } else if (strstr(bkpinfo->netfs_proto, "smbfs")) { 509 sprintf(tmp, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user); 500 510 } else if (strstr(bkpinfo->netfs_proto, "nfs")) { 501 511 mr_asprintf(tmp1, "mount %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount); … … 507 517 if (strstr(bkpinfo->netfs_proto, "sshfs")) { 508 518 mr_asprintf(tmp1, "sshfs %s", bkpinfo->netfs_mount); 519 } else if (strstr(bkpinfo->netfs_proto, "smbfs")) { 520 sprintf(tmp, "mount -t cifs %s", bkpinfo->netfs_mount); 509 521 } else if (strstr(bkpinfo->netfs_proto, "nfs")) { 510 522 mr_asprintf(tmp1, "mount %s", bkpinfo->netfs_mount); … … 629 641 } 630 642 mr_free(tmp1); 631 lastpos = 0;632 643 633 644 mr_make_devlist_from_pathlist(flag_val['E'], 'E'); … … 637 648 if (flag_set['e']) { 638 649 bkpinfo->please_dont_eject = TRUE; 650 } 651 652 if (flag_set['M']) { 653 g_max_biggie_size = atol(flag_val['M']); 654 log_msg(1, "Max size for biggie file is now %ld KB", g_max_biggie_size); 639 655 } 640 656 … … 778 794 /* Before changing remove old ones if any */ 779 795 if (bkpinfo->scratchdir) { 780 chdir("/tmp"); 796 if (chdir("/tmp")) { 797 // FIXME 798 } 781 799 mr_asprintf(tmp1, "rm -Rf %s", bkpinfo->scratchdir); 782 800 paranoid_system(tmp1); … … 859 877 log_to_screen("Please install LZOP. You can't use '-L' until you do.\n"); 860 878 } 879 } 880 881 if (flag_set['F']) { 882 log_msg(3, "-F means we will fail immediately at the first interaction request"); 883 g_fail_immediately = TRUE; 861 884 } 862 885 -
branches/3.1/mondo/src/common/libmondo-devices.c
r2937 r3147 331 331 char *searchstr = NULL; 332 332 char *tmp = NULL; 333 char *p; 333 334 334 335 /*@ ints ******************************************************* */ … … 816 817 } 817 818 818 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);819 mr_asprintf(command, "%s -scanbus | grep \"[0-9],[0-9],[0-9]\" | grep -E \"[D|C][V|D]\" | grep -n \"\" | grep \"%s\" | cut -d':' -f2", cdr_exe, g_cdrw_drive_is_here); 819 820 mr_free(cdr_exe); 820 821 … … 848 849 } 849 850 850 tmp = call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\"| grep -E '[D|C][V|D]' | cut -d':' -f1",TRUE);851 tmp = call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep -E '\)\ \'' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1",TRUE); 851 852 log_msg(5, "tmp = '%s'", tmp); 852 853 if (!tmp[0]) 853 854 mr_free(tmp); 854 tmp = call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep \ ") '\" | grep -n \"\"| grep -E '[D|C][V|D]' | cut -d':' -f1",TRUE);855 tmp = call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep \)\ \' | grep -n '' | grep -E '[D|C][V|D]' | cut -d':' -f1",TRUE); 855 856 if (tmp[0]) { 856 857 devno = atoi(tmp) - 1; … … 886 887 #if linux 887 888 unsigned long long s = 0; 888 int fileid, cylinders = 0 , cylindersleft = 0;889 int fileid, cylinders = 0; 889 890 int cylindersize = 0; 890 891 int gotgeo = 0; … … 935 936 if (ioctl(fileid, HDIO_GETGEO, &hdgeo) != -1) { 936 937 if (hdgeo.cylinders && hdgeo.heads && hdgeo.sectors) { 937 cylindersleft = cylinders = hdgeo.cylinders;938 938 cylindersize = hdgeo.heads * hdgeo.sectors / 2; 939 939 outvalA = cylindersize * cylinders / 1024; … … 983 983 char *command = NULL; 984 984 char *format_sz = NULL; 985 char *p; 985 986 986 987 FILE *pin; … … 1822 1823 1823 1824 /* Check for LVM */ 1824 mr_asprintf(command, "pvdisplay -c %s | grep '%s:' 2> /dev/null", partitions[i], partitions[i]);1825 mr_asprintf(command, "pvdisplay -c %s 2> /dev/null", partitions[i]); 1825 1826 log_msg(5, " Running: %s", command); 1826 1827 tmp = call_program_and_get_last_line_of_output(command,TRUE); … … 2638 2639 char *p = NULL; 2639 2640 char *q = NULL; 2641 char *tmpro = NULL; 2642 char *tmp1 = NULL; 2640 2643 char *mds = NULL; 2641 2644 char *sz_size = NULL; … … 2873 2876 bkpinfo->media_size[i] = bkpinfo->media_size[0]; 2874 2877 } 2878 bkpinfo->use_obdr = ask_me_yes_or_no 2879 ("Do you want to activate OBDR support for your tapes ?"); 2880 if (bkpinfo->use_obdr) { 2881 log_msg(4, "obdr mode = TRUE"); 2882 } else { 2883 log_msg(4, "obdr mode = FALSE"); 2884 } 2875 2885 if (archiving_to_media) { 2876 2886 if ((compression_type = which_compression_type()) == NULL) { … … 2968 2978 if (bkpinfo->disaster_recovery) { 2969 2979 mr_asprintf(command ,"umount %s/isodir 2> /dev/null", bkpinfo->tmpdir); 2970 (void)system(command);2980 paranoid_system(command); 2971 2981 mr_free(command); 2972 2982 2973 2983 } 2974 p = popup_and_get_string("Network protocol", "Which Network protocol should I use?", bkpinfo->netfs_proto); 2984 <<<<<<< .courant 2985 p = popup_and_get_string("Network protocol", "Which Network protocol should I use (nfs/sshfs/smbfs) ?", bkpinfo->netfs_proto); 2975 2986 if (p == NULL) { 2976 2987 log_to_screen("User has chosen not to backup the PC"); … … 3016 3027 3017 3028 if (bkpinfo->restore_data) { 3029 /* mount th FS read-only in restore mode to avoid any erase of whatever */ 3030 mr_asprintf(tmpro, "-o ro"); 3031 } else { 3032 mr_asprintf(tmpro, ""); 3033 } 3034 3035 /* Build the mount string */ 3036 if (strstr(bkpinfo->netfs_proto, "smbfs")) { 3037 mr_asprintf(tmp, "mount -t cifs %s %s %s",bkpinfo->netfs_mount, bkpinfo->isodir,tmpro); 3038 if (bkpinfo->netfs_user) { 3039 mr_strcat(tmp, " -o user=%s", bkpinfo->netfs_user); 3040 } 3041 else { 3018 3042 if (strstr(bkpinfo->netfs_proto, "sshfs")) { 3019 mr_asprintf(tmp, "sshfs -o ro");3043 mr_asprintf(tmp, "sshfs %s ",tmpro); 3020 3044 } else { 3021 mr_asprintf(tmp, "mount -t %s -o nolock ,ro", bkpinfo->netfs_proto);3045 mr_asprintf(tmp, "mount -t %s -o nolock %s ", bkpinfo->netfs_proto,tmpro); 3022 3046 } 3023 } else { 3024 if (strstr(bkpinfo->netfs_proto, "sshfs")) { 3025 mr_asprintf(tmp, "sshfs"); 3026 } else { 3027 mr_asprintf(tmp, "mount -t %s -o nolock", bkpinfo->netfs_proto); 3047 if (bkpinfo->netfs_user) { 3048 mr_strcat(tmp, "%s@", bkpinfo->netfs_user); 3028 3049 } 3029 } 3030 if (bkpinfo->netfs_user) { 3031 mr_strcat(tmp, "%s@", bkpinfo->netfs_user); 3032 } 3033 mr_strcat(tmp, "%s %s", bkpinfo->netfs_mount, bkpinfo->isodir); 3050 mr_strcat(tmp, "%s %s", bkpinfo->netfs_mount, bkpinfo->isodir); 3051 } 3034 3052 run_program_and_log_output(tmp, 3); 3035 3053 mr_free(tmp); … … 3037 3055 malloc_string(g_selfmounted_isodir); 3038 3056 strcpy(g_selfmounted_isodir, bkpinfo->isodir); 3057 } 3039 3058 } 3040 3059 if (!is_this_device_mounted(bkpinfo->netfs_mount)) { … … 3193 3212 } 3194 3213 3195 3196 3214 p = popup_and_get_string("Exclude paths", "Please enter paths which you do NOT want to backup. Separate them with '|'. NB: /tmp and /proc are always excluded. :-) Just hit 'Enter' if you want to do a full system backup.", bkpinfo->exclude_paths); 3197 3215 if (p == NULL) { -
branches/3.1/mondo/src/common/libmondo-filelist.c
r2937 r3147 30 30 31 31 extern char *MONDO_LOGFILE; 32 33 extern long g_max_biggie_size; 32 34 33 35 /* Reference to global bkpinfo */ … … 195 197 /*@ long ****************************************/ 196 198 long lino = 0; 197 long max_sane_size_for_a_file;199 // A big file has more than 64 MB of real content 198 200 long curr_set_size; 199 201 long noof_lines; … … 221 223 assert_string_is_neither_NULL_nor_zerolength(filelist); 222 224 assert(maxsetsizeK > 0); 223 224 max_sane_size_for_a_file = 64L * 1024L;225 // max_sane_size_for_a_file = maxsetsizeK*2;226 // if (max_sane_size_for_a_file > 32*1024)227 // { max_sane_size_for_a_file = 32*1024; }228 225 229 226 log_it("filelist=%s;", filelist); … … 269 266 siz = 0; 270 267 } else { 271 siz = (long) (buf.st_size >> 10); 272 } 273 if (siz > max_sane_size_for_a_file) { 274 log_msg(10, "Adding %s to big files\n", incoming); 268 // blocks are 512 bytes long - cf man 2 stat - Pass to the previous unit (MB => kB e.g.) 269 // use blocks instead of size to allow sparse file correct handling as much as possible 270 siz = (long) ((buf.st_blocks*512) >> 10); 271 } 272 if (siz > g_max_biggie_size) { 273 log_msg(10, "Adding %s to big files (size = %ld)\n", incoming, siz); 275 274 fprintf(fbig, "%s\n", incoming); 276 275 } else { 277 276 curr_set_size += siz; 278 log_msg(10, "Adding %s to filelist %d \n", incoming, curr_set_no);277 log_msg(10, "Adding %s to filelist %d (size = %ld)\n", incoming, curr_set_no, siz); 279 278 fprintf(fout, "%s\n", incoming); 280 279 if (curr_set_size > maxsetsizeK) { … … 400 399 char *tmp = NULL; 401 400 401 char *p; 402 402 403 pattr = popen(syscall, "r"); 403 404 if (!pattr) { … … 431 432 char *strtmp = NULL; 432 433 char *tmp = NULL; 434 char *p = NULL; 433 435 int i; 434 436 … … 517 519 int retval = 0; 518 520 int i; 519 char *p, *q ;521 char *p, *q, *r; 520 522 char *tmp = NULL; 521 523 FILE *pin, *pout, *faclin; … … 1323 1325 char *skip_these = NULL; 1324 1326 char *new_with_pipe; 1325 char *strtmp ;1326 char *token ;1327 char *strtmp = NULL; 1328 char *token = NULL; 1327 1329 char *find_excludes = NULL; 1328 1330 char *name_of_evalcall_form = NULL; … … 1374 1376 1375 1377 log_msg(5, "find command = %s", strtmp); 1376 (void)system(strtmp);1378 paranoid_system(strtmp); 1377 1379 mr_free(strtmp); 1378 1380 … … 1510 1512 char *sz_filelist; 1511 1513 char *exclude_paths = NULL; 1512 int i;1513 1514 FILE *fout; 1514 1515 char *command = NULL; … … 1597 1598 fatal_error("Cannot openout to sz_filelist"); 1598 1599 } 1599 i = 0;1600 1600 if ((!include_paths) || (strlen(include_paths) == 0)) { 1601 1601 log_msg(1, "Including only '/' in %s", sz_filelist); … … 1697 1697 { 1698 1698 /*@ int ******************************************************** */ 1699 int noof_chars;1700 1699 static int depth = 0; 1701 1700 static char original_string[MAX_STR_LEN]; … … 1715 1714 assert(startnode != NULL); 1716 1715 assert(string_to_find != NULL); 1717 1718 noof_chars = strlen(string_to_find) + 1; /* we include the '\0' */1719 1716 1720 1717 log_msg(7, "starting --- str=%s", string_to_find); -
branches/3.1/mondo/src/common/libmondo-files.c
r2937 r3147 51 51 /*@ pointers **************************************************** */ 52 52 char *p = NULL; 53 char *q; 53 54 FILE *fin; 54 55 … … 126 127 char *command = NULL; 127 128 char *incoming = NULL; 129 char *q; 128 130 129 131 /*@ long ******************************************************** */ … … 204 206 char *tmp = NULL; 205 207 char *incoming = NULL; 208 char *q; 206 209 207 210 /*@ int ********************************************************* */ … … 471 474 char *output = NULL; 472 475 char *command = NULL; 476 char *p = NULL; 473 477 474 478 /*@ pointers **************************************************** */ … … 540 544 char *curr_cksum = NULL; 541 545 char *tmp = NULL; 546 char *q; 542 547 543 548 /*@ long [long] ************************************************* */ … … 679 684 /*@ buffers **************************************************** */ 680 685 char *incoming = NULL; 686 char *p = NULL; 681 687 682 688 /*@ end vars *************************************************** */ … … 743 749 char *tmp = NULL; 744 750 char *command = NULL; 751 char *comment; 745 752 746 753 /*@ long ******************************************************** */ … … 972 979 return (1); 973 980 } 974 fscanf(fin, "%s\n", contents);981 res = fscanf(fin, "%s\n", contents); 975 982 i = strlen(contents); 976 983 if (i > 0 && contents[i - 1] < 32) { … … 978 985 } 979 986 paranoid_fclose(fin); 987 res = 0; 980 988 return (res); 981 989 } … … 1020 1028 if (res) { 1021 1029 fatal_error("Failed to copy Mondo's stuff to scratchdir"); 1030 } 1031 1032 mr_asprintf(command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir, bkpinfo->scratchdir); 1033 1034 if (run_program_and_log_output(command, FALSE)) { 1035 fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir"); 1022 1036 } 1023 1037 -
branches/3.1/mondo/src/common/libmondo-fork.c
r2937 r3147 42 42 char *newcall = NULL; 43 43 char *tmp = NULL; 44 char *p; 44 45 45 46 /*@ pointers **************************************************** */ … … 258 259 FILE *fin; 259 260 char *p; 261 char *q; 260 262 261 263 /*@ end vars *************************************************** */ … … 300 302 fin = fopen(tmp1, "r"); 301 303 if (fin) { 302 for ( fgets(incoming, MAX_STR_LEN, fin); !feof(fin);fgets(incoming, MAX_STR_LEN, fin)) {304 for (q = fgets(incoming, MAX_STR_LEN, fin); !feof(fin) && (q != NULL); q = fgets(incoming, MAX_STR_LEN, fin)) { 303 305 p = incoming; 304 306 while (p && *p) { … … 545 547 log_msg(1, "bytes_read_in = %ld", bytes_read_in); 546 548 547 fwrite(tmp1, 1, bytes_read_in, ftmp); 548 fread(tmp1, 1, tmpcap, fin); 549 log_msg(0, "tmp1 = '%s'", tmp1); 550 fwrite(tmp1, 1, tmpcap, ftmp); 549 if (fwrite(tmp, 1, bytes_read_in, ftmp)) { 550 fatal_error("Can't fwrite here"); 551 } 552 553 sprintf(tmp, "I am here - %lld", (long long)ftello(fin)); 554 if (fread(tmp, 1, tmpcap, fin)) { 555 fatal_error("Can't fread here"); 556 } 557 log_msg(0, "tmp = '%s'", tmp); 558 if (fwrite(tmp, 1, tmpcap, ftmp)) { 559 fatal_error("Can't fwrite there"); 560 } 551 561 fclose(ftmp); 552 562 mr_free(tmp1); -
branches/3.1/mondo/src/common/libmondo-mountlist.c
r2937 r3147 50 50 int pos = 0, npos = 0; 51 51 int res = 0; 52 int mountpoint_copies = 0;53 52 int device_copies = 0; 54 53 int i = 0; … … 112 111 } 113 112 /* does partition /dev/adXsYZ exist more than once in the mountlist? */ 114 for (i = 0, mountpoint_copies = 0,device_copies = 0;113 for (i = 0, device_copies = 0; 115 114 i < mountlist->entries; i++) { 116 115 if (!strcmp(device, mountlist->el[i].device)) { … … 214 213 } 215 214 /* does partition /dev/adXsY exist more than once in the mountlist? */ 216 for (i = 0, mountpoint_copies = 0,device_copies = 0;215 for (i = 0, device_copies = 0; 217 216 i < mountlist->entries; i++) { 218 217 if (!strcmp(device, mountlist->el[i].device)) { … … 277 276 } 278 277 /* does partition /dev/adXsYZ exist more than once in the mountlist? */ 279 for (i = 0, mountpoint_copies = 0,device_copies = 0;278 for (i = 0, device_copies = 0; 280 279 i < mountlist->entries; i++) { 281 280 if (!strcmp(device, mountlist->el[i].device)) { … … 384 383 int pos = 0; 385 384 int res = 0; 386 int mountpoint_copies = 0;387 385 int device_copies = 0; 388 386 int i = 0; … … 461 459 462 460 /* does partition /dev/hdNX exist more than once in the mountlist? */ 463 for (i = 0, mountpoint_copies = 0,device_copies = 0;461 for (i = 0, device_copies = 0; 464 462 i < mountlist->entries; i++) { 465 463 if (!strcmp(device, mountlist->el[i].device)) { … … 807 805 char *tmp = NULL; 808 806 char *p = NULL; 807 char *q = NULL; 809 808 810 809 int items = 0; … … 926 925 } 927 926 paranoid_fclose(fout); 927 if (!(fout = fopen(MONDO_MNTLISTCHG, "w"))) { 928 log_OS_error("WMTD - Cannot openout "MONDO_MNTLISTCHG); 929 return (1); 930 } 931 fprintf(fout, "the mountlist was changed by mondorestore\n"); 932 paranoid_fclose(fout); 928 933 return (0); 929 934 } -
branches/3.1/mondo/src/common/libmondo-raid-EXT.h
r558 r3147 53 53 #endif 54 54 55 extern int parse_mdstat( struct raidlist_itself *raidlist, char *device_prefix);56 extern int create_raidtab_from_mdstat(char * raidtab_fname);55 extern int parse_mdstat(char *mdstat_fname, struct raidlist_itself *raidlist, char *device_prefix); 56 extern int create_raidtab_from_mdstat(char *mdstat_fname, char *raidtab_fname); -
branches/3.1/mondo/src/common/libmondo-raid.c
r2937 r3147 15 15 #include "libmondo-tools-EXT.h" 16 16 #include "libmondo-string-EXT.h" 17 #include "libmondo-fork-EXT.h" 17 18 #include "lib-common-externs.h" 18 19 #include "libmondo-raid.h" … … 429 430 char *incoming = NULL; 430 431 char *p; 432 char *q; 431 433 432 434 assert(fin != NULL); … … 604 606 return (1); 605 607 } 608 malloc_string(label); 609 malloc_string(value); 606 610 items = 0; 607 611 log_it("Loading raidtab..."); … … 615 619 strcpy(raidlist->el[items].additional_vars.el[v].label, label); 616 620 strcpy(raidlist->el[items].additional_vars.el[v].value, value); 621 log_msg(2,"Found raidtab entry Label: %s Value: %s",raidlist->el[items].additional_vars.el[v].label,raidlist->el[items].additional_vars.el[v].value); 617 622 v++; 618 623 mr_free(label); … … 690 695 raidrec->raid_level = atoi(value); 691 696 } 697 log_msg(4,"Found raid level %d",raidrec->raid_level); 692 698 } else if (!strcmp(label, "nr-raid-disks")) { /* ignore it */ 693 699 } else if (!strcmp(label, "nr-spare-disks")) { /* ignore it */ … … 710 716 log_msg(1, "Unknown RAID parity algorithm '%s'\n.", value); 711 717 } 718 log_msg(4,"Found raid parity %d",raidrec->parity); 712 719 } else if (!strcmp(label, "device")) { 713 720 get_next_raidtab_line(fin, &labelB, &valueB); … … 735 742 strcpy(raidrec->additional_vars.el[v].label, label); 736 743 strcpy(raidrec->additional_vars.el[v].value, value); 737 raidrec->additional_vars.entries = ++v; 744 log_msg(4,"Found additional raid pair #%d: %s / %s",v,raidrec->additional_vars.el[v].label,raidrec->additional_vars.el[v].value); 745 v++; 746 raidrec->additional_vars.entries = v; 738 747 } 739 748 } … … 950 959 951 960 952 int parse_mdstat(struct raidlist_itself *raidlist, char *device_prefix) { 953 954 const char delims[] = " "; 955 956 FILE *fin; 957 int res = 0, row, i, index_min; 958 int lastpos = 0; 959 size_t len = 0; 960 char *token; 961 char *string = NULL; 962 char *pos; 963 char type; 964 char *strtmp; 961 int parse_mdstat(char *mdstat_fname, struct raidlist_itself *raidlist, char *device_prefix) { 962 963 const char delims[] = " "; 964 965 FILE *fin = NULL; 966 int res = 0, row, i, index_min; 967 int v = 0; 968 int lastpos = 0; 969 size_t len = 0; 970 char *token = NULL; 971 char *string = NULL; 972 char *cmd = NULL; 973 char *pos = NULL; 974 char type; 975 char *strtmp = NULL; 976 char *strtmp2 = NULL; 965 977 966 978 // open file … … 1044 1056 raidlist->el[raidlist->entries].raid_level = 10; 1045 1057 } else { 1046 log_msg(1, "Unknown RAID level '%s'.\n", token); 1047 paranoid_free(string); 1048 paranoid_free(token); 1049 return 1; 1050 } 1051 mr_free(token); 1058 switch (row) { 1059 case 1: // device information 1060 // check whether last line of record and if so skip 1061 log_msg(8, "This is the device line\n"); 1062 pos = strcasestr(string, "unused devices: "); 1063 if (pos != NULL) { 1064 break; 1065 } 1066 // tokenise string 1067 token = mr_strtok(string, delims, &lastpos); 1068 if (token == NULL) { 1069 // should not happen ! 1070 break; 1071 } 1072 // get RAID device name 1073 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1074 strncpy(raidlist->el[raidlist->entries].raid_device, strtmp, 63); 1075 raidlist->el[raidlist->entries].raid_device[63] = '\0'; 1076 mr_free(strtmp); 1077 mr_free(token); 1078 // store the UUID value in the additional_vars structure 1079 v = raidlist->el[raidlist->entries].additional_vars.entries; 1080 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "UUID"); 1081 mr_asprintf(&cmd,"mdadm --detail %s | grep UUID | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device); 1082 mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd)); 1083 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp); 1084 mr_free(strtmp); 1085 v++; 1086 // store the Version value in the additional_vars structure 1087 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "Version"); 1088 mr_asprintf(&cmd,"mdadm --detail %s | grep Version | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device); 1089 mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd)); 1090 strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp); 1091 mr_free(strtmp); 1092 v++; 1093 raidlist->el[raidlist->entries].additional_vars.entries = v; 1094 // skip ':' and status 1095 token = mr_strtok (string, delims, &lastpos); 1096 if (token == NULL) { 1097 // should not happen ! 1098 break; 1099 } 1100 mr_free(token); 1101 token = mr_strtok (string, delims, &lastpos); 1102 if (token == NULL) { 1103 // should not happen ! 1104 break; 1105 } 1106 if (!strcmp(token, "inactive")) { 1107 log_msg(1, "RAID device '%s' inactive.\n", 1108 raidlist->el[raidlist->entries].raid_device); 1109 mr_free(string); 1110 mr_free(token); 1111 return 1; 1112 } 1113 mr_free(token); 1052 1114 1053 1115 // get RAID devices (type, index, device) … … 1097 1159 } 1098 1160 1161 // get RAID devices (type, index, device) 1162 // Note: parity disk for RAID4 is last normal disk, there is no '(P)' 1163 raidlist->el[raidlist->entries].data_disks.entries = 0; 1164 raidlist->el[raidlist->entries].spare_disks.entries = 0; 1165 raidlist->el[raidlist->entries].failed_disks.entries = 0; 1166 while((token = mr_strtok (string, delims, &lastpos))) { 1167 if ((pos = strstr(token, "("))) { 1168 type = *(pos+1); 1169 } else { 1170 type = ' '; 1171 } 1172 pos = strstr(token, "["); 1173 *pos = '\0'; 1174 switch(type) { 1175 case ' ': // normal data disks 1176 raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1); 1177 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1178 strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp); 1179 mr_free(strtmp); 1180 raidlist->el[raidlist->entries].data_disks.entries++; 1181 break; 1182 case 'S': // spare disks 1183 raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1); 1184 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1185 strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp); 1186 mr_free(strtmp); 1187 raidlist->el[raidlist->entries].spare_disks.entries++; 1188 break; 1189 case 'F': // failed disks 1190 raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1); 1191 mr_asprintf(&strtmp,"%s%s", device_prefix, token); 1192 strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp); 1193 mr_free(strtmp); 1194 raidlist->el[raidlist->entries].failed_disks.entries++; 1195 log_it("At least one failed disk found in RAID array.\n"); 1196 break; 1197 default: // error 1198 log_msg(1, "Unknown device type '%c'\n", type); 1199 mr_free(string); 1200 mr_free(token); 1201 return 1; 1202 break; 1203 } 1204 mr_free(token); 1205 } 1206 1099 1207 // adjust index for each device so that it starts with 0 for every type 1100 1208 index_min = 99; 1101 1209 for (i=0; i<raidlist->el[raidlist->entries].data_disks.entries;i++) { 1102 1103 1104 1210 if (raidlist->el[raidlist->entries].data_disks.el[i].index < index_min) { 1211 index_min = raidlist->el[raidlist->entries].data_disks.el[i].index; 1212 } 1105 1213 } 1106 1214 if (index_min > 0) { 1107 1108 1109 1215 for (i=0; i<raidlist->el[raidlist->entries].data_disks.entries;i++) { 1216 raidlist->el[raidlist->entries].data_disks.el[i].index = raidlist->el[raidlist->entries].data_disks.el[i].index - index_min; 1217 } 1110 1218 } 1111 1219 index_min = 99; 1112 1220 for (i=0; i<raidlist->el[raidlist->entries].spare_disks.entries;i++) { 1113 1114 1115 1221 if (raidlist->el[raidlist->entries].spare_disks.el[i].index < index_min) { 1222 index_min = raidlist->el[raidlist->entries].spare_disks.el[i].index; 1223 } 1116 1224 } 1117 1225 if (index_min > 0) { 1118 1119 1120 1226 for (i=0; i<raidlist->el[raidlist->entries].spare_disks.entries;i++) { 1227 raidlist->el[raidlist->entries].spare_disks.el[i].index = raidlist->el[raidlist->entries].spare_disks.el[i].index - index_min; 1228 } 1121 1229 } 1122 1230 index_min = 99; 1123 1231 for (i=0; i<raidlist->el[raidlist->entries].failed_disks.entries;i++) { 1124 1125 1126 1232 if (raidlist->el[raidlist->entries].failed_disks.el[i].index < index_min) { 1233 index_min = raidlist->el[raidlist->entries].failed_disks.el[i].index; 1234 } 1127 1235 } 1128 1236 if (index_min > 0) { 1129 1130 1131 1237 for (i=0; i<raidlist->el[raidlist->entries].failed_disks.entries;i++) { 1238 raidlist->el[raidlist->entries].failed_disks.el[i].index = raidlist->el[raidlist->entries].failed_disks.el[i].index - index_min; 1239 } 1132 1240 } 1133 1241 break; 1134 1242 case 2: // config information 1135 1243 // check for persistent super block 1136 1244 if (strcasestr(string, "super non-persistent")) { 1137 1138 } else {1139 1140 }1141 // extract chunk size1142 if (!(pos = strcasestr(string, "k chunk"))) {1143 1144 } else {1145 1146 1147 1148 1149 paranoid_free(string);1150 1151 1152 1153 1154 }1155 // extract parity if present1156 if ((pos = strcasestr(string, "algorithm"))) {1157 1158 } else {1159 1160 }1161 break;1162 1163 if (!(pos = strchr(string, '\%'))) {1164 1165 1166 1167 1168 1169 } else {1170 1171 1172 1173 1174 paranoid_free(string);1175 1176 1177 1178 1179 }1180 break;1181 1182 if (raidlist->el[raidlist->entries].progress != -1 &&1183 raidlist->el[raidlist->entries].progress != 999) {1184 log_msg(1, "Row %d should not occur in record!\n", row);1185 }1186 break;1187 1188 1189 1190 } 1191 // close file 1192 fclose(fin); 1193 // free string 1194 paranoid_free(string);1195 1196 1197 1198 } 1199 1200 1201 1202 1203 int create_raidtab_from_mdstat(char * raidtab_fname)1245 raidlist->el[raidlist->entries].persistent_superblock = 0; 1246 } else { 1247 raidlist->el[raidlist->entries].persistent_superblock = 1; 1248 } 1249 // extract chunk size 1250 if (!(pos = strcasestr(string, "k chunk"))) { 1251 raidlist->el[raidlist->entries].chunk_size = -1; 1252 } else { 1253 while (*pos != ' ') { 1254 pos -= 1; 1255 if (pos < string) { 1256 log_it("String underflow!\n"); 1257 mr_free(string); 1258 return 1; 1259 } 1260 } 1261 raidlist->el[raidlist->entries].chunk_size = atoi(pos + 1); 1262 } 1263 // extract parity if present 1264 if ((pos = strcasestr(string, "algorithm"))) { 1265 raidlist->el[raidlist->entries].parity = atoi(pos + 9); 1266 } else { 1267 raidlist->el[raidlist->entries].parity = -1; 1268 } 1269 break; 1270 case 3: // optional build status information 1271 if (!(pos = strchr(string, '\%'))) { 1272 if (strcasestr(string, "delayed")) { 1273 raidlist->el[raidlist->entries].progress = -1; // delayed (therefore, stuck at 0%) 1274 } else { 1275 raidlist->el[raidlist->entries].progress = 999; // not found 1276 } 1277 } else { 1278 while (*pos != ' ') { 1279 pos -= 1; 1280 if (pos < string) { 1281 printf("ERROR: String underflow!\n"); 1282 mr_free(string); 1283 return 1; 1284 } 1285 } 1286 raidlist->el[raidlist->entries].progress = atoi(pos); 1287 } 1288 break; 1289 default: // error or IN PROGRESS 1290 if (raidlist->el[raidlist->entries].progress != -1 && 1291 raidlist->el[raidlist->entries].progress != 999) { 1292 log_msg(1, "Row %d should not occur in record!\n", row); 1293 } 1294 break; 1295 } 1296 row++; 1297 } 1298 // free string 1299 mr_free(string); 1300 } 1301 // close file 1302 fclose(fin); 1303 // return success 1304 return 0; 1305 1306 } 1307 1308 1309 1310 1311 int create_raidtab_from_mdstat(char *mdstat_fname,char *raidtab_fname) 1204 1312 { 1205 1313 struct raidlist_itself *raidlist; … … 1209 1317 1210 1318 // FIXME: Prefix '/dev/' should really be dynamic! 1211 if (parse_mdstat( raidlist, "/dev/")) {1212 log_to_screen("Sorry, cannot read %s", MDSTAT_FILE);1319 if (parse_mdstat(mdstat_fname,raidlist, "/dev/")) { 1320 log_to_screen("Sorry, cannot read %s", mdstat_fname); 1213 1321 return (1); 1214 1322 } -
branches/3.1/mondo/src/common/libmondo-raid.h
r558 r3147 43 43 #endif 44 44 45 int create_raidtab_from_mdstat(char * raidtab_fname);46 int parse_mdstat( struct raidlist_itself *raidlist, char *device_prefix);45 int create_raidtab_from_mdstat(char *mdstat_fname, char *raidtab_fname); 46 int parse_mdstat(char *mdstat_fname, struct raidlist_itself *raidlist, char *device_prefix); -
branches/3.1/mondo/src/common/libmondo-stream.c
r2937 r3147 116 116 char *blk; 117 117 int i; 118 int j; 118 119 119 120 blk = (char *) malloc(256 * 1024); … … 131 132 } 132 133 for (i = 0; i < 8 && !feof(g_tape_stream); i++) { 133 (void) fread(blk, 1, 256 * 1024, g_tape_stream); 134 j = fread(blk, 1, 256 * 1024, g_tape_stream); 135 if (j) { 136 // FIXME 137 } 134 138 } 135 139 sleep(1); … … 185 189 } 186 190 for (i = 0; i < 4 * 8; i++) { 187 (void) fwrite(blk, 1, 256 * 1024, g_tape_stream); 191 if (fwrite(blk, 1, 256 * 1024, g_tape_stream)) { 192 //FIXME 193 } 188 194 if (should_we_write_to_next_tape 189 195 (bkpinfo->media_size[g_current_media_number], (off_t)256 * 1024)) { … … 362 368 { 363 369 int res = 0; 364 char *fname = (char *)&res; /* Should NOT be NULL */ 370 char fname_buf[PATH_MAX]; 371 char *fname = (char *)fname_buf; /* Should NOT be NULL */ 365 372 char *tmp = NULL; 366 373 … … 419 426 res = read_header_block_from_stream(ptmp_size, tmp_fname, pctrl_chr); 420 427 log_msg(1, "End of extended attributes, now looking for afioball"); 421 return ( 0);428 return (res); 422 429 } 423 430 … … 521 528 { 522 529 long long final_alleged_writeK, final_projected_certain_writeK, 523 final_actually_certain_writeK = 0,cposK, bufsize_K;530 cposK, bufsize_K; 524 531 int last, curr, i; 525 t_archtype type = other;526 532 char *command = NULL; 527 533 char *tmpdir = NULL; … … 557 563 cposK = g_tapecatalog->el[curr].tape_posK; 558 564 if (cposK < final_projected_certain_writeK) { 559 final_actually_certain_writeK = cposK;560 565 break; 561 566 } … … 835 840 g_tape_stream); 836 841 } 837 (void) fwrite(datablock, 1, (size_t) length, fout); 842 if (fwrite(datablock, 1, (size_t) length, fout)) { 843 // FIXME 844 } 838 845 g_tape_posK += length / 1024; 839 846 } … … 860 867 close_evalcall_form(); 861 868 log_it("Saved all.tar.gz to '%s'", outfname); 862 (void) getcwd(old_cwd, MAX_STR_LEN); 863 chdir(bkpinfo->tmpdir); 869 if (getcwd(old_cwd, MAX_STR_LEN)) { 870 // FIXME 871 } 872 if (chdir(bkpinfo->tmpdir)) { 873 // FIXME 874 } 864 875 mr_asprintf(tmp, "tar -zxf %s ."MINDI_CACHE"/mondorestore.cfg 2> /dev/null", outfname); 865 876 paranoid_system(tmp); … … 867 878 868 879 paranoid_system("cp -f ."MINDI_CACHE"/mondorestore.cfg . 2> /dev/null"); 869 chdir(old_cwd); 880 if (chdir(old_cwd)) { 881 // FIXME 882 } 870 883 unlink(outfname); 871 884 mr_free(outfname); … … 1049 1062 unsigned int crctt; 1050 1063 1051 bool had_to_resync = FALSE;1052 1053 1064 /*@ init ******************************************************* */ 1054 1065 malloc_string(temp_fname); … … 1062 1073 1063 1074 res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1075 if (res) { 1076 // FIXME 1077 } 1064 1078 if (orig_size != temp_size && orig_size != -1) { 1065 1079 log_to_screen("output file's size should be %ld K but is apparently %ld K", (long) size >> 10, (long) temp_size >> 10); … … 1100 1114 for (size = orig_size; size > where_I_was_before_tape_change; 1101 1115 size -= bytes_to_write) { 1102 bytes_read = 1103 fread(datablock, 1, bytes_to_read, g_tape_stream); 1116 bytes_read = fread(datablock, 1, bytes_to_read, g_tape_stream); 1104 1117 } 1105 1118 log_msg(4, "'size' is now %lld (should be %lld)", size, 1106 1119 where_I_was_before_tape_change); 1107 1120 log_to_screen("Successfully re-sync'd tape"); 1108 had_to_resync = TRUE;1109 1121 bytes_read = fread(datablock, 1, bytes_to_read, g_tape_stream); 1110 1122 } 1111 1123 1112 (void) fwrite(datablock, 1, (size_t) bytes_to_write, fout); // for blocking reasons, bytes_successfully_read_in isn't necessarily the same as bytes_to_write 1124 if (fwrite(datablock, 1, (size_t) bytes_to_write, fout)) { // for blocking reasons, bytes_successfully_read_in isn't necessarily the same as bytes_to_write 1125 // FIXME 1126 } 1113 1127 1114 1128 #ifdef EXTRA_TAPE_CHECKSUMS … … 1177 1191 } 1178 1192 while (!(*pcontrol_char = tempblock[7000])) { 1179 g_tape_posK += 1180 fread(tempblock, 1, (size_t) TAPE_BLOCK_SIZE, 1181 g_tape_stream) / 1024; 1193 g_tape_posK += fread(tempblock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream) / 1024; 1182 1194 } 1183 1195 memcpy((char *) plen, tempblock + 7001, sizeof(long long)); … … 1320 1332 ctrl_chr = -1; 1321 1333 while (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) { 1322 res = 1323 read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1334 res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1324 1335 if (ctrl_chr == BLK_START_AN_AFIO_OR_SLICE) { 1325 1336 break; … … 1330 1341 } 1331 1342 while (ctrl_chr != BLK_START_FILE) { 1332 res = 1333 read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1343 res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1334 1344 if (ctrl_chr == BLK_START_FILE) { 1335 1345 break; … … 1356 1366 bytes_to_write = 1357 1367 (size < TAPE_BLOCK_SIZE) ? (long) size : TAPE_BLOCK_SIZE; 1358 // FIXME - needs error-checking and -catching1359 fread(datablock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream);1360 }1361 res =1362 1368 if (fread(datablock, 1, (size_t) TAPE_BLOCK_SIZE, g_tape_stream)) { 1369 // FIXME - needs error-checking and -catching 1370 } 1371 } 1372 res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1363 1373 if (ctrl_chr != BLK_STOP_FILE) { 1364 1374 wrong_marker(BLK_STOP_FILE, ctrl_chr); 1365 1375 } 1366 res = 1367 read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1376 res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1368 1377 if (ctrl_chr != BLK_STOP_AN_AFIO_OR_SLICE) { 1369 1378 wrong_marker(BLK_STOP_AN_AFIO_OR_SLICE, ctrl_chr); 1370 1379 } 1371 res = 1372 read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1380 res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1373 1381 if (ctrl_chr != BLK_START_AN_AFIO_OR_SLICE) { 1374 1382 wrong_marker(BLK_START_AN_AFIO_OR_SLICE, ctrl_chr); 1375 1383 } 1376 res = 1377 read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1384 res = read_header_block_from_stream(&temp_size, temp_fname, &ctrl_chr); 1378 1385 if (ctrl_chr != BLK_START_FILE) { 1379 1386 wrong_marker(BLK_START_FILE, ctrl_chr); … … 1689 1696 bytes_to_read = TAPE_BLOCK_SIZE; 1690 1697 } 1691 (void) fread(datablock, 1, (size_t) bytes_to_read, fin); 1698 if (fread(datablock, 1, (size_t) bytes_to_read, fin)) { 1699 // FIXME 1700 } 1692 1701 g_tape_posK += 1693 1702 fwrite(datablock, 1, /*bytes_to_read */ -
branches/3.1/mondo/src/common/libmondo-string-EXT.h
r2508 r3147 23 23 extern void strip_spaces(char *in_out); 24 24 extern char *trim_empty_quotes(char *incoming); 25 extern char *truncate_to_drive_name(c har *partition);25 extern char *truncate_to_drive_name(const char *partition); 26 26 extern char *turn_raid_level_number_to_string(int raid_level); 27 27 -
branches/3.1/mondo/src/common/libmondo-string.c
r2508 r3147 665 665 */ 666 666 void strip_spaces(char *in_out) 667 { 668 /*@ buffers ***************************************************** */ 669 char *tmp = NULL; 670 671 /*@ int ******************************************************** */ 672 int i; 673 674 /*@ end vars *************************************************** */ 675 676 assert(in_out != NULL); 677 malloc_string(tmp); 678 for (i = 0; in_out[i] <= ' ' && i < (int) strlen(in_out) -1; i++); 679 strcpy(tmp, in_out + i); 680 for (i = (int) strlen(tmp) -1; i >= 0 && tmp[i] <= ' '; i--); 681 i++; 682 tmp[i] = '\0'; 683 684 // Now tmp contains the stripped string 685 strcpy(in_out,tmp); 686 paranoid_free(tmp); 687 } 688 689 /** 690 * Remove all characters whose ASCII value is less than or equal to 32 691 * (spaces and control characters) from both sides of @p in_out. 692 * @param in_out The string to strip spaces/control characters from (modified). 693 */ 694 void strip_spaces2(char *in_out) 667 695 { 668 696 /*@ buffers ***************************************************** */ … … 752 780 * @return @p partition. 753 781 */ 754 char *truncate_to_drive_name(c har *partition)782 char *truncate_to_drive_name(const char *partition) 755 783 { 756 784 int i = strlen(partition) - 1; -
branches/3.1/mondo/src/common/libmondo-string.h
r2508 r3147 21 21 void strip_spaces(char *in_out); 22 22 char *trim_empty_quotes(char *incoming); 23 char *truncate_to_drive_name(c har *partition);23 char *truncate_to_drive_name(const char *partition); 24 24 char *turn_raid_level_number_to_string(int raid_level); 25 25 void printf_silly_message(void); -
branches/3.1/mondo/src/common/libmondo-tools.c
r2937 r3147 304 304 { 305 305 #ifdef __FreeBSD__ 306 system("kldstat | grep msdosfs || kldload msdosfs 2> /dev/null");307 system("kldstat | grep ext2fs || kldload ext2fs 2> /dev/null");306 paranoid_system("kldstat | grep msdosfs || kldload msdosfs 2> /dev/null"); 307 paranoid_system("kldstat | grep ext2fs || kldload ext2fs 2> /dev/null"); 308 308 #else 309 system("modprobe -a msdos vfat loop &> /dev/null");309 paranoid_system("modprobe -a msdos vfat loop &> /dev/null"); 310 310 #endif 311 311 } … … 643 643 colon++; 644 644 hent = gethostbyname(colon); 645 mr_asprintf( bkpinfo->netfs_user,"%s", hostname);645 mr_asprintf(&(bkpinfo->netfs_user),"%s", hostname); 646 646 } else { 647 647 hent = gethostbyname(hostname); … … 713 713 } 714 714 715 /* From busybox under GPLv2 */ 716 #ifndef HAVE_MKDTEMP 717 /* This is now actually part of POSIX.1, but was only added in 2008 */ 718 char* mkdtemp(char *template) 719 { 720 if (mktemp(template) == NULL || mkdir(template, 0700) != 0) 721 return NULL; 722 return template; 723 } 724 #endif 725 715 726 void setup_tmpdir(char *path) { 716 727 … … 721 732 /* purging a potential old tmpdir */ 722 733 log_it("Purging old tmpdir %s", bkpinfo->tmpdir); 723 chdir("/tmp"); 734 if (chdir("/tmp")) { 735 // FIXME 736 } 724 737 mr_asprintf(tmp,"rm -Rf %s",bkpinfo->tmpdir); 725 738 mr_free(bkpinfo->tmpdir); 726 (void)system(tmp);739 paranoid_system(tmp); 727 740 mr_free(tmp); 728 741 } … … 1032 1045 mr_free(tmp); 1033 1046 1034 if (!run_program_and_log_output("parted2fdisk -l | grep -i raid", 1)1047 if (!run_program_and_log_output("parted2fdisk -l 2>/dev/null | grep -i raid", 1) 1035 1048 && !does_file_exist("/etc/raidtab")) { 1036 1049 log_to_screen 1037 1050 ("You have RAID partitions but no /etc/raidtab - creating one from /proc/mdstat"); 1038 create_raidtab_from_mdstat( "/etc/raidtab");1051 create_raidtab_from_mdstat(MDSTAT_FILE,"/etc/raidtab"); 1039 1052 } 1040 1053 -
branches/3.1/mondo/src/common/libmondo-verify.c
r2937 r3147 412 412 char *outlog = NULL; 413 413 char *tmp = NULL; 414 char *p = NULL; 414 415 415 416 /*@ pointers ******************************************************* */ … … 477 478 bkpinfo->use_star = TRUE; 478 479 if (strstr(tarball_fname, ".bz2")) 479 mr_asprintf(command, "star - diff diffopts=mode,size,data file=%s %s >> %s 2>> %s", tarball_fname, (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog, outlog);480 mr_asprintf(command, "star -sparse -diff diffopts=mode,size,data file=%s %s >> %s 2>> %s", tarball_fname, (strstr(tarball_fname, ".bz2")) ? "-bz" : " ", outlog, outlog); 480 481 } else { 481 482 bkpinfo->use_star = FALSE; … … 681 682 682 683 mr_asprintf(tmp, "echo \"%s\" >> %s/biggies.changed", biggie_fname, bkpinfo->tmpdir); 683 system(tmp);684 paranoid_system(tmp); 684 685 mr_free(tmp); 685 686 } … … 738 739 log_it("Grabbing the EXAT files"); 739 740 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) { 740 res = 741 read_EXAT_files_from_tape(&size, fname, &ctrl_chr, 741 res = read_EXAT_files_from_tape(&size, fname, &ctrl_chr, 742 742 curr_xattr_list_fname, 743 743 curr_acl_list_fname); … … 765 765 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) { 766 766 log_it("Reading EXAT files from tape"); 767 res = 768 read_EXAT_files_from_tape(&size, fname, &ctrl_chr, 767 res = read_EXAT_files_from_tape(&size, fname, &ctrl_chr, 769 768 curr_xattr_list_fname, 770 769 curr_acl_list_fname); … … 848 847 if (ctrl_chr == BLK_START_EXTENDED_ATTRIBUTES) { 849 848 log_it("Grabbing the EXAT biggiefiles"); 850 res = 851 read_EXAT_files_from_tape(&size, orig_fname, 849 res = read_EXAT_files_from_tape(&size, orig_fname, 852 850 &ctrl_chr, curr_xattr_list_fname, 853 851 curr_acl_list_fname); -
branches/3.1/mondo/src/common/mondostructures.h
r2816 r3147 191 191 * A type of file in the catalog of recent archives. 192 192 */ 193 typedef enum { other, ///< Some other kind of file. 193 typedef enum { 194 other, ///< Some other kind of file. 194 195 fileset, ///< An afioball (fileset), optionally compressed. 195 196 biggieslice ///< A slice of a biggiefile, optionally compressed. … … 201 202 typedef enum { 202 203 nuke = 0, /// Nuke mode 203 interactive, /// Interactive mode204 interactive, /// Interactive mode 204 205 compare, /// Compare mode 205 206 mbr, /// MBR mode -
branches/3.1/mondo/src/common/newt-specific.c
r2937 r3147 57 57 */ 58 58 bool g_exiting = FALSE; 59 60 // Decide whether we should continue to ask questions or exit (cron use case) 61 extern bool g_fail_immediately; 59 62 60 63 /** … … 122 125 char *tmp; 123 126 124 assert_string_is_neither_NULL_nor_zerolength(prompt); 125 127 assert_string_is_neither_NULL_nor_zerolength(prompt); 128 129 if (g_fail_immediately) { 130 // We consider the user aborted by using the -F option 131 log_msg(3, "Exiting at first interaction request due to -F"); 132 finish(1); 133 } 126 134 if (g_text_mode) { 127 135 while (1) { … … 163 171 /*@ buffer *********************************************************** */ 164 172 char *tmp = NULL; 173 char *p; 165 174 int i; 166 175 167 assert_string_is_neither_NULL_nor_zerolength(prompt); 176 if (g_fail_immediately) { 177 // We consider the user aborted by using the -F option 178 log_msg(3, "Exiting at first interaction request due to -F"); 179 finish(1); 180 } 168 181 169 182 if (g_text_mode) { … … 318 331 sync(); 319 332 320 chdir("/"); 333 if (chdir("/")) { 334 // FIXME 335 } 321 336 if (g_selfmounted_isodir) { 322 337 mr_asprintf(command, "umount -d %s", g_selfmounted_isodir); … … 369 384 370 385 /* Before removing dir, make sure we're out of them */ 371 chdir("/tmp"); 386 if (chdir("/tmp")) { 387 // FIXME 388 } 372 389 run_program_and_log_output("umount -d " MNT_CDROM, FALSE); 373 390 if (g_selfmounted_isodir) { … … 385 402 log_msg(8,"erasing tempdir %s",bkpinfo->tmpdir); 386 403 mr_asprintf(command, "rm -Rf %s", bkpinfo->tmpdir); 387 system(command);404 paranoid_system(command); 388 405 mr_free(command); 389 406 } … … 394 411 log_msg(8,"erasing scratchdir %s",bkpinfo->scratchdir); 395 412 mr_asprintf(command, "rm -Rf %s", bkpinfo->scratchdir); 396 system(command);413 paranoid_system(command); 397 414 mr_free(command); 398 415 } … … 424 441 char *command = NULL; 425 442 char *tmp = NULL; 443 char *p = NULL; 426 444 427 445 /*@ pointers ********************************************************* */ … … 763 781 /*@ buffers *********************************************************** */ 764 782 char *prompt = NULL; 783 char *q; 765 784 766 785 /*@ newt ************************************************************** */ … … 1130 1149 static char *possible_responses[] = { "none", "cdr", "cdrw", "dvd", "tape", "cdstream", "udev", "netfs", "iso", NULL }; 1131 1150 char *outstr = NULL; 1151 char *p; 1132 1152 t_bkptype backup_type; 1133 1153 int i; … … 1286 1306 newtPushHelpLine(" Please specify the level of compression that you want."); 1287 1307 newtCenteredWindow(34, 13, "How much compression?"); 1288 b1 = newtButton(4, 1, "Maximum ");1289 b2 = newtButton(18, 1, "Average ");1290 b3 = newtButton(4, 5, "Minimum ");1291 b4 = newtButton(18, 5, " None ");1308 b1 = newtButton(4, 1, "Maximum (9)"); 1309 b2 = newtButton(18, 1, "Average (4)"); 1310 b3 = newtButton(4, 5, "Minimum (1)"); 1311 b4 = newtButton(18, 5, " None (0) "); 1292 1312 b5 = newtButton(4, 9, " Exit "); 1293 1313 myForm = newtForm(NULL, NULL, 0); … … 1327 1347 bool done; 1328 1348 char *tmp = NULL; 1349 char *p; 1329 1350 char *tmp1 = NULL; 1330 1351 FILE *fin, *fout; … … 1563 1584 } /* extern "C" */ 1564 1585 #endif 1565 1566 1567 void wait_until_software_raids_are_prepped(char *mdstat_file, int wait_for_percentage);
Note:
See TracChangeset
for help on using the changeset viewer.