Changeset 89 in MondoRescue
- Timestamp:
- Oct 27, 2005, 10:45:34 PM (20 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mindi/parted2fdisk.pl
r30 r89 1 1 #!/usr/bin/perl -w 2 2 # 3 # $Id$ 4 # 3 5 # parted2fdisk: fdisk like interface for parted 4 # [developped for mindi/mondo http:// www.mondorescue.org]6 # [developped for mindi/mondo http://mondorescue.berlios.de] 5 7 # 6 8 # Aims to be architecture independant (i386/ia64) … … 34 36 my %flags; 35 37 my $arch; 38 my $fake = 0; 36 39 37 40 # Determine on which arch we're running … … 57 60 my $args = ""; 58 61 my $device = ""; 62 my $endmax = ""; 59 63 60 64 if ($#ARGV < 0) { … … 104 108 } 105 109 110 if ($args =~ /-n/) { 111 print FLOG "Fake mode. Nothing will be really done\n"; 112 $fake = 1; 113 } 114 106 115 print FLOG "Called with device $device and arg $args\n"; 107 116 … … 117 126 } elsif ($args =~ /-s/) { 118 127 fdisk_list($device,$wpart,\%start,\%end); 119 } elsif ( $args =~ /-/) {128 } elsif (($args =~ /-/) and ($fake == 0)) { 120 129 printf FLOG "Option not supported ($args) ...\n"; 121 130 printf FLOG "Please report to the author\n"; … … 134 143 print FLOG "Forcing GPT type of disk label\n"; 135 144 print FLOG "mklabel gpt\n"; 136 system "$parted -s $device mklabel gpt\n" ;145 system "$parted -s $device mklabel gpt\n" if ($fake != 0); 137 146 $type = "gpt"; 138 147 } … … 160 169 } 161 170 } 171 $start = 1 if ($start < 1); 162 172 print FLOG "start cyl : $start\n"; 173 $un = get_un($device); 174 # parted needs MB 175 $start = $start * $un / 1048576; 176 # this is a size in B/KB/MB/GB 177 $endmax = get_max($device); 163 178 $end = <STDIN>; 164 179 chomp($end); 165 180 if ((not (defined $end)) || ($end eq "")) { 166 181 print FLOG "no end cyl given for creation... assuming full disk)\n"; 167 $end = get_max($device); 168 } 169 $un = get_un($device); 182 $end = $endmax; 183 } 170 184 # Handles end syntaxes (+, K, M, ...) 185 # to give cylinders 171 186 if ($end =~ /^\+/) { 172 187 $end =~ s/^\+//; … … 181 196 $end *= 1000000000; 182 197 } 198 # This gives the number of cyl 183 199 $end /= $un; 184 $end = int($end)+1;200 $end = sprintf("%d",$end); 185 201 $end += $start - 0.001; 202 # We now have the end cyl 186 203 } 187 204 print FLOG "end cyl : $end\n"; 188 print FLOG "n $l $part $start $end => mkpart primary $start $end\n"; 189 system "$parted -s $device mkpart primary ext2 $start $end\n"; 205 # parted needs MB 206 $end = $end * $un / 1048576; 207 $end = $endmax if ($end > $endmax); 208 print FLOG "n $l $part => mkpart primary $start $end\n"; 209 system "$parted -s $device mkpart primary ext2 $start $end\n" if ($fake != 0); 190 210 } 191 211 elsif ($i =~ /^d$/) { … … 197 217 chomp($part); 198 218 print FLOG "d $part => rm $part\n"; 199 system "$parted -s $device rm $part\n" ;219 system "$parted -s $device rm $part\n" if ($fake != 0); 200 220 get_parted($device,undef,\%start,\%end,undef,undef); 201 221 } … … 221 241 } 222 242 print FLOG "t $part => mkfs $part $pnum{$l}\n"; 223 system "$parted -s $device mkfs $part $pnum{$l}\n" ;243 system "$parted -s $device mkfs $part $pnum{$l}\n" if ($fake != 0); 224 244 } 225 245 elsif ($i =~ /^a$/) { … … 231 251 chomp($part); 232 252 print FLOG "a $part => set $part boot on\n"; 233 system "$parted -s $device set $part boot on\n" ;253 system "$parted -s $device set $part boot on\n" if ($fake != 0); 234 254 } 235 255 elsif ($i =~ /^q$/) { … … 323 343 324 344 my $un; 345 my $endmax; 325 346 my $d; 326 347 my $n; … … 367 388 # Keep Fdisk headers 368 389 # 390 # this will return bytes 369 391 $un = get_un ($device,$wpart); 392 $endmax = get_max($device); 393 # This will return MB 370 394 get_parted ($device,$start,$end,\%type,\%flags); 371 395 … … 373 397 # Print infos fdisk like 374 398 $part = ${device}.$n; 375 $mstart = sprintf("%d",int($$start{$n})); 376 $mend = sprintf("%d",int($$end{$n})); 377 $length = sprintf("%d",($mend-$mstart+1)*$un/1048576); 399 # start and end are in cylinder in fdisk format 400 # so return in MB * 1MB / what represents 1 cyl in B 401 $mstart = sprintf("%d",$$start{$n}*1048576/$un); 402 $mstart = 1 if ($mstart < 1); 403 $mend = sprintf("%d",$$end{$n}*1048576/$un - 1); 404 $mend = $endmax if ($mend > $endmax); 405 # length is in 1K blocks 406 $length = sprintf("%d",($mend-$mstart+1)*$un/1024); 378 407 $pid = $pid{$type{$n}}; 379 408 $cmt = $cmt{$type{$n}}; … … 404 433 } else { 405 434 # manage the -s option of fdisk here 406 my $s = int(eval("$length/1048576*$un*1024")); 407 print "$s\n" if ($part eq $wpart); 408 print FLOG "$part has $s Bytes\n" if ($part eq $wpart); 435 print "$length\n" if ($part eq $wpart); 436 print FLOG "$part has $length KBytes\n" if ($part eq $wpart); 409 437 } 410 438 } … … 424 452 open (FDISK, "$fdisk -l $device |") || die "Unable to read from $fdisk"; 425 453 while (<FDISK>) { 426 if ($_ =~ / ^Disk/) {427 ($foo, $un , $foo) = split /=/;428 $max = ~ s/.*sectors,([0-9]+) cylinders/$1/g;429 $max = eval($max);454 if ($_ =~ /heads/) { 455 chomp; 456 $max = $_; 457 $max =~ s/.* ([0-9]+) cylinders/$1/; 430 458 } 431 459 } … … 436 464 437 465 # 438 # Get units from fdisk 466 # Get units from fdisk (cylinder size) 439 467 # 440 468 sub get_un { … … 459 487 } 460 488 489 # 490 # Parted gives info in MB 491 # 461 492 sub get_parted { 462 493 -
trunk/mondo/mondo/common/X-specific.h
r59 r89 64 64 struct Event { 65 65 enum EventType { None, Show, Hide, New, SetProgress, SetTotal, 66 SetText, InsLine, PopupWithButtons, InfoMsg, ErrorMsg, 67 GetInfo } type; 66 SetText, InsLine, PopupWithButtons, InfoMsg, ErrorMsg, 67 GetInfo 68 } type; 68 69 QWidget *data; 69 70 // union { -
trunk/mondo/mondo/common/libmondo-archive.c
r87 r89 1214 1214 1215 1215 asprintf(&command, "rm -f %s/%s/%s-[1-9]*.iso", bkpinfo->isodir, 1216 1216 bkpinfo->nfs_remote_dir, bkpinfo->prefix); 1217 1217 paranoid_system(command); 1218 1218 paranoid_free(command); … … 3379 3379 log_msg(2, tmp); 3380 3380 /* BERLIOS: center_string is now broken 3381 center_string(tmp, 80);3382 */3381 center_string(tmp, 80); 3382 */ 3383 3383 #ifndef _XWIN 3384 3384 if (!g_text_mode) { -
trunk/mondo/mondo/common/libmondo-devices.c
r87 r89 2103 2103 } 2104 2104 // check whether already mounted - we better remove 2105 2106 strip_spaces 2105 // surrounding spaces and trailing '/' for this 2106 strip_spaces(bkpinfo->nfs_mount); 2107 2107 if (bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] == '/') 2108 2108 bkpinfo->nfs_mount[strlen(bkpinfo->nfs_mount) - 1] = '\0'; 2109 2109 sprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", 2110 2110 bkpinfo->nfs_mount); 2111 2111 strcpy(bkpinfo->isodir, 2112 2112 call_program_and_get_last_line_of_output(command)); … … 2122 2122 } 2123 2123 if (!is_this_device_mounted(bkpinfo->nfs_mount)) { 2124 sprintf(bkpinfo->isodir, "/tmp/isodir.mondo.%d", (int)(random()%32768)); 2125 sprintf(command, "mkdir -p %s", bkpinfo->isodir); 2126 run_program_and_log_output(command, 5); 2127 sprintf(tmp, "mount %s -t nfs %s", bkpinfo->nfs_mount, bkpinfo->isodir); 2128 run_program_and_log_output(tmp, 5); 2129 malloc_string(g_selfmounted_isodir); 2130 strcpy(g_selfmounted_isodir, bkpinfo->isodir); 2124 sprintf(bkpinfo->isodir, "/tmp/isodir.mondo.%d", 2125 (int) (random() % 32768)); 2126 sprintf(command, "mkdir -p %s", bkpinfo->isodir); 2127 run_program_and_log_output(command, 5); 2128 sprintf(tmp, "mount %s -t nfs %s", bkpinfo->nfs_mount, 2129 bkpinfo->isodir); 2130 run_program_and_log_output(tmp, 5); 2131 malloc_string(g_selfmounted_isodir); 2132 strcpy(g_selfmounted_isodir, bkpinfo->isodir); 2131 2133 } 2132 2134 if (!is_this_device_mounted(bkpinfo->nfs_mount)) { … … 2144 2146 strcpy(bkpinfo->nfs_remote_dir, tmp); 2145 2147 // check whether writable - we better remove surrounding spaces for this 2146 strip_spaces (bkpinfo->nfs_remote_dir); 2147 sprintf (command, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir, 2148 bkpinfo->nfs_remote_dir); 2149 while (run_program_and_log_output (command, FALSE)) { 2150 strcpy(tmp, bkpinfo->nfs_remote_dir); 2151 asprintf (&prompt, 2152 "Directory '%s' under mountpoint '%s' does not exist or is not writable. You can fix this or change the directory and retry or cancel the backup.", 2153 bkpinfo->nfs_remote_dir, bkpinfo->isodir); 2154 if(!popup_and_get_string ("Directory", prompt, tmp, MAX_STR_LEN)) { 2155 log_to_screen("User has chosen not to backup the PC"); 2156 finish(1); 2157 } 2158 strcpy(bkpinfo->nfs_remote_dir, tmp); 2159 // check whether writable - we better remove surrounding spaces for this */ 2160 strip_spaces (bkpinfo->nfs_remote_dir); 2161 asprintf (&command, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir, 2162 bkpinfo->nfs_remote_dir); 2148 strip_spaces(bkpinfo->nfs_remote_dir); 2149 sprintf(command, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir, 2150 bkpinfo->nfs_remote_dir); 2151 while (run_program_and_log_output(command, FALSE)) { 2152 strcpy(tmp, bkpinfo->nfs_remote_dir); 2153 asprintf(&prompt, 2154 "Directory '%s' under mountpoint '%s' does not exist or is not writable. You can fix this or change the directory and retry or cancel the backup.", 2155 bkpinfo->nfs_remote_dir, bkpinfo->isodir); 2156 if (!popup_and_get_string 2157 ("Directory", prompt, tmp, MAX_STR_LEN)) { 2158 log_to_screen("User has chosen not to backup the PC"); 2159 finish(1); 2160 } 2161 strcpy(bkpinfo->nfs_remote_dir, tmp); 2162 // check whether writable - we better remove surrounding spaces for this */ 2163 strip_spaces(bkpinfo->nfs_remote_dir); 2164 asprintf(&command, "echo hi > %s/%s/.dummy.txt", 2165 bkpinfo->isodir, bkpinfo->nfs_remote_dir); 2163 2166 } 2164 2167 for (i = 0; i <= MAX_NOOF_MEDIA; i++) { … … 2908 2911 } 2909 2912 #endif 2910 log_msg(1, "Using %s", fdisk);2913 log_msg(1, "Using %s", fdisk); 2911 2914 sprintf(command, "%s -l %s | grep 'EFI GPT'", fdisk, drive); 2912 2915 strcpy(tmp, call_program_and_get_last_line_of_output(command)); -
trunk/mondo/mondo/common/libmondo-fork.c
r68 r89 477 477 res = pclose(fin); 478 478 /* Log actual pclose errors. */ 479 if (errno) log_msg(5, "pclose err: %d", errno); 479 if (errno) 480 log_msg(5, "pclose err: %d", errno); 480 481 /* Check if we have a valid status. If we do, extract the called program's exit code. */ 481 482 /* If we don't, highlight this fact by returning -1. */ 482 483 if (WIFEXITED(res)) { 483 retval = WEXITSTATUS(res);484 retval = WEXITSTATUS(res); 484 485 } else { 485 486 retval = -1; 486 487 } 487 488 close_evalcall_form(); … … 681 682 */ 682 683 int dynamically_create_pipes_and_copy_from_them_to_output_file(char 683 *input_device, 684 char 684 *input_device, char 685 685 *output_fname) 686 686 { -
trunk/mondo/mondo/common/libmondo-string.c
r87 r89 43 43 assert(partno >= 0); 44 44 45 p = strcpy(partition, drive); 45 asprintf(&partition, "%s", drive); 46 p = partition; 46 47 /* is this a devfs device path? */ 47 48 c = strrchr(partition, '/'); 48 49 if (c && strncmp(c, "/disc", 5) == 0) { 49 50 /* yup it's devfs, return the "part" path */ 51 /* format /dev/.../disc */ 50 52 strcpy(c + 1, "part"); 51 p = c + 5;52 53 } else { 53 54 p += strlen(p); 54 55 if (isdigit(p[-1])) { 55 *p++ =56 p = partition; 56 57 #ifdef BSD 57 's';58 asprintf(&partition, "%ss", p); 58 59 #else 59 'p'; 60 /* format /dev/cciss/c0d0 */ 61 asprintf(&partition, "%sp", p); 60 62 #endif 63 paranoid_free(p); 61 64 } 62 65 } 63 sprintf(p, "%d", partno); 66 p = partition; 67 asprintf(&partition, "%s%d", p, partno); 68 paranoid_free(p); 64 69 return (partition); 65 70 } … … 658 663 numA = atol(stringA + start_of_numbers_in_A); 659 664 numB = atol(stringB + start_of_numbers_in_B); 660 /*661 sprintf(tmp,"Comparing %s and %s --> %ld,%ld\n",stringA,stringB,numA,numB);662 log_to_screen(tmp);663 */664 665 return ((int) (numA - numB)); 665 666 } … … 882 883 sev = 2; 883 884 asprintf(&reason, 884 "/var's contents will change regularly, inevitably.");885 "/var's contents will change regularly, inevitably."); 885 886 } 886 887 if (!strncmp(filename, "/home", 5)) { 887 888 sev = 2; 888 889 asprintf(&reason, 889 "It's in your /home partiton. Therefore, it is important.");890 "It's in your /home partiton. Therefore, it is important."); 890 891 } 891 892 if (!strncmp(filename, "/usr/", 5)) { 892 893 sev = 3; 893 894 asprintf(&reason, 894 "You may have installed/removed software during the backup.");895 "You may have installed/removed software during the backup."); 895 896 } 896 897 if (!strncmp(filename, "/etc/", 5)) { 897 898 sev = 3; 898 899 asprintf(&reason, 899 "Do not edit config files while backing up your PC.");900 "Do not edit config files while backing up your PC."); 900 901 } 901 902 if (!strcmp(filename, "/etc/adjtime") … … 906 907 if (!strncmp(filename, "/root/", 6)) { 907 908 sev = 3; 908 asprintf(&reason, "Were you compiling/editing something in /root?"); 909 asprintf(&reason, 910 "Were you compiling/editing something in /root?"); 909 911 } 910 912 if (!strncmp(filename, "/root/.", 7)) { … … 923 925 sev = 1; 924 926 asprintf(&reason, 925 "The 'update' daemon ran during backup. This does not affect the integrity of your backup.");927 "The 'update' daemon ran during backup. This does not affect the integrity of your backup."); 926 928 } 927 929 if (!strncmp(filename, "/var/log/", 9) … … 930 932 sev = 1; 931 933 asprintf(&reason, 932 "Log files change frequently as the computer runs. Fret not.");934 "Log files change frequently as the computer runs. Fret not."); 933 935 } 934 936 if (!strncmp(filename, "/var/spool", 10)) { 935 937 sev = 1; 936 938 asprintf(&reason, 937 "Background processes or printers were active. This does not affect the integrity of your backup.");939 "Background processes or printers were active. This does not affect the integrity of your backup."); 938 940 } 939 941 if (!strncmp(filename, "/var/spool/mail", 10)) { … … 944 946 sev = 1; 945 947 asprintf(&reason, 946 "Backup copy of another file which was modified recently.");948 "Backup copy of another file which was modified recently."); 947 949 } 948 950 if (strstr(filename, "cache")) { 949 951 sev = 1; 950 952 asprintf(&reason, 951 "Part of a cache of data. Caches change from time to time. Don't worry.");953 "Part of a cache of data. Caches change from time to time. Don't worry."); 952 954 } 953 955 if (!strncmp(filename, "/var/run/", 9) … … 957 959 sev = 1; 958 960 asprintf(&reason, 959 "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence.");961 "Temporary file (a lockfile, perhaps) used by software such as X or KDE to register its presence."); 960 962 } 961 963 paranoid_free(filename); … … 964 966 sev = 3; 965 967 asprintf(&reason, 966 "Changed since backup. Consider running a differential backup in a day or two.");968 "Changed since backup. Consider running a differential backup in a day or two."); 967 969 } 968 970 … … 1024 1026 asprintf(&tmp, "%lld", g_tape_posK); 1025 1027 asprintf(&outstr, "Volume %d: %s kilobytes archived so far", 1026 g_current_media_number, commarize(tmp));1028 g_current_media_number, commarize(tmp)); 1027 1029 paranoid_free(tmp); 1028 1030 return (outstr); … … 1040 1042 bkpinfo->media_size[g_current_media_number]); 1041 1043 asprintf(&prepstr, "%s %d: [", 1042 media_descriptor_string(bkpinfo->backup_media_type),1043 g_current_media_number);1044 media_descriptor_string(bkpinfo->backup_media_type), 1045 g_current_media_number); 1044 1046 } 1045 1047 if (percentage > 100) { 1046 1048 percentage = 100; 1047 1049 } 1048 j = trunc(percentage /5);1049 tmp1 = (char *) malloc((j + 1) * sizeof(char));1050 for (i = 0, p = tmp1 ; i < j; i++, p++) {1051 1050 j = trunc(percentage / 5); 1051 tmp1 = (char *) malloc((j + 1) * sizeof(char)); 1052 for (i = 0, p = tmp1; i < j; i++, p++) { 1053 *p = '*'; 1052 1054 } 1053 1055 *p = '\0'; 1054 1056 1055 tmp2 = (char *) malloc((20 - j + 1) * sizeof(char));1056 for (i = 0, p = tmp2 ; i < 20 - j; i++, p++) {1057 1057 tmp2 = (char *) malloc((20 - j + 1) * sizeof(char)); 1058 for (i = 0, p = tmp2; i < 20 - j; i++, p++) { 1059 *p = '.'; 1058 1060 } 1059 1061 *p = '\0'; … … 1063 1065 * like this it creates a huge number. Memory pb somewhere */ 1064 1066 /* 1065 log_it("percentage: %d", percentage); 1066 asprintf(&outstr, "%s%s%s] %3d%% used", prepstr, tmp1, tmp2, percentage); 1067 */ 1068 asprintf(&outstr, "%s%s%s] %3d percent used", prepstr, tmp1, tmp2, percentage); 1067 log_it("percentage: %d", percentage); 1068 asprintf(&outstr, "%s%s%s] %3d%% used", prepstr, tmp1, tmp2, percentage); 1069 */ 1070 asprintf(&outstr, "%s%s%s] %3d percent used", prepstr, tmp1, tmp2, 1071 percentage); 1069 1072 paranoid_free(prepstr); 1070 1073 paranoid_free(tmp1); -
trunk/mondo/mondo/common/libmondo-tools.c
r87 r89 562 562 extra_cdrom_params, bkpinfo->media_device); 563 563 } 564 if (getenv ("SUDO_COMMAND")) { 565 fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - please see the growisofs manpage for details."); 564 if (getenv("SUDO_COMMAND")) { 565 fatal_error 566 ("Can't write DVDs as sudo because growisofs doesn't support this - please see the growisofs manpage for details."); 566 567 } 567 568 log_msg(2, "call_make_iso (DVD res) is ... %s", … … 712 713 } 713 714 } 714 store_nfs_config 715 store_nfs_config(bkpinfo); 715 716 } 716 717 -
trunk/mondo/mondo/common/my-stuff.h
r87 r89 214 214 /** 215 215 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image. 216 */// -b images/mindi-boot.2880.img216 */// -b images/mindi-boot.2880.img 217 217 #define MONDO_GROWISOFS_REGULAR_ELILO "growisofs -use-the-force-luke -no-emul-boot -b images/mindi-boot.2880.img -c boot.cat -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v" 218 218 219 219 /** 220 220 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image. 221 */// -b images/mindi-boot.2880.img221 */// -b images/mindi-boot.2880.img 222 222 #define MONDO_GROWISOFS_REGULAR_LILO "growisofs -no-emul-boot -b isolinux.bin -c boot.cat -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v" 223 223 -
trunk/mondo/mondo/common/newt-specific.c
r87 r89 62 62 */ 63 63 char **err_log_lines = NULL, ///< The list of log lines to show on the screen. 64 *g_blurb_str_1, ///< The string for line 1 of the blurb in the progress form65 *g_blurb_str_2, ///< The string for line 2 of the blurb in the progress form66 *g_blurb_str_3; ///< The string for line 3 (updated continuously) of the blurb in the progress form64 *g_blurb_str_1, ///< The string for line 1 of the blurb in the progress form 65 *g_blurb_str_2, ///< The string for line 2 of the blurb in the progress form 66 *g_blurb_str_3; ///< The string for line 3 (updated continuously) of the blurb in the progress form 67 67 newtComponent g_isoform_main = NULL, ///< The evalcall form component itself 68 68 g_isoform_header = NULL, ///< The component for the evalcall form title … … 86 86 bool g_called_by_xmondo = FALSE; ///< @bug Unneeded w/current XMondo. 87 87 char *g_erase_tmpdir_and_scratchdir; ///< The command to run to erase the tmpdir and scratchdir at the end of Mondo. 88 char *g_selfmounted_isodir;///< Holds the NFS mountpoint if mounted via mondoarchive.88 char *g_selfmounted_isodir; ///< Holds the NFS mountpoint if mounted via mondoarchive. 89 89 90 90 /* @} - end of globalGroup */ … … 300 300 301 301 if (g_selfmounted_isodir) { 302 303 304 305 302 asprintf(&command, "umount %s", g_selfmounted_isodir); 303 run_program_and_log_output(command, 5); 304 asprintf(&command, "rmdir %s", g_selfmounted_isodir); 305 run_program_and_log_output(command, 5); 306 306 } 307 307 … … 316 316 ("cat /var/log/mondo-archive.log | gzip -9 > /tmp/MA.log.gz 2> /dev/null"); 317 317 if (!strstr(g_version, "cvs") && !strstr(g_version, "svn")) { 318 printf 319 ("Please try the latest SVN version "); 318 printf("Please try the latest SVN version "); 320 319 printf 321 320 ("to see if that fixes the problem.\nPlease don't bother the mailing list with"); … … 358 357 void 359 358 finish(int signal) { 360 361 362 363 359 char *command; 360 malloc_string(command); 361 362 /* if (signal==0) { popup_and_OK("Please press <enter> to quit."); } */ 364 363 365 364 /* newtPopHelpLine(); */ … … 374 373 } 375 374 if (g_selfmounted_isodir) { 376 377 378 379 375 asprintf(&command, "umount %s", g_selfmounted_isodir); 376 run_program_and_log_output(command, 1); 377 asprintf(&command, "rmdir %s", g_selfmounted_isodir); 378 run_program_and_log_output(command, 1); 380 379 } 381 380 // iamhere("foo"); … … 793 792 printf("%s (%s or %s) --> ", p, button1, button2); 794 793 } 795 for (asprintf(&tmp, "");794 for (asprintf(&tmp, ""); 796 795 strcmp(tmp, button1) && (strlen(button2) == 0 797 796 || strcmp(tmp, button2));) { … … 945 944 percentage = 1; 946 945 } else { 947 percentage = (int) trunc(num);946 percentage = (int) trunc(num); 948 947 } 949 948 … … 965 964 g_isoform_old_progress = percentage; 966 965 asprintf(&timeline_str, 967 "%2ld:%02ld taken %2ld:%02ld remaining",968 time_taken / 60, time_taken % 60, time_remaining / 60,969 time_remaining % 60);966 "%2ld:%02ld taken %2ld:%02ld remaining", 967 time_taken / 60, time_taken % 60, time_remaining / 60, 968 time_remaining % 60); 970 969 if (percentage < 3) { 971 tmp1 = (char *)malloc(g_mysterious_dot_counter * sizeof(char)); 972 for (i = 0, p = tmp1 ; i < g_mysterious_dot_counter - 1 ; i++, p++) { 973 *p = '.'; 970 tmp1 = 971 (char *) malloc(g_mysterious_dot_counter * 972 sizeof(char)); 973 for (i = 0, p = tmp1; i < g_mysterious_dot_counter - 1; 974 i++, p++) { 975 *p = '.'; 974 976 } 975 977 *p = '\0'; 976 978 977 979 /* BERLIOS: 27 should be a parameter */ 978 tmp2 = (char *)malloc(27-g_mysterious_dot_counter * sizeof(char)); 979 for (i = 0, p = tmp2 ; i < 27 - g_mysterious_dot_counter - 1 ; i++, p++) { 980 *p = ' '; 980 tmp2 = 981 (char *) malloc(27 - 982 g_mysterious_dot_counter * 983 sizeof(char)); 984 for (i = 0, p = tmp2; 985 i < 27 - g_mysterious_dot_counter - 1; i++, p++) { 986 *p = ' '; 981 987 } 982 988 *p = '\0'; 983 989 984 asprintf(&pcline_str, " Working%s%s %c", tmp1, tmp2, special_dot_char(g_mysterious_dot_counter)); 990 asprintf(&pcline_str, " Working%s%s %c", tmp1, tmp2, 991 special_dot_char(g_mysterious_dot_counter)); 985 992 paranoid_free(tmp1); 986 993 paranoid_free(tmp2); 987 994 } else { 988 asprintf(&pcline_str, " %3d%% done %3d%% to go", 989 percentage, 100 - percentage); 995 asprintf(&pcline_str, 996 " %3d%% done %3d%% to go", 997 percentage, 100 - percentage); 990 998 } 991 999 if (g_text_mode) { 992 j = trunc(percentage /5);993 tmp1 = (char *) malloc((j + 1) * sizeof(char));994 for (i = 0, p = tmp1 ; i < j; i++, p++) {995 1000 j = trunc(percentage / 5); 1001 tmp1 = (char *) malloc((j + 1) * sizeof(char)); 1002 for (i = 0, p = tmp1; i < j; i++, p++) { 1003 *p = '*'; 996 1004 } 997 1005 *p = '\0'; 998 1006 999 tmp2 = (char *) malloc((20 - j + 1) * sizeof(char));1000 for (i = 0, p = tmp2 ; i < 20 - j; i++, p++) {1001 1007 tmp2 = (char *) malloc((20 - j + 1) * sizeof(char)); 1008 for (i = 0, p = tmp2; i < 20 - j; i++, p++) { 1009 *p = '.'; 1002 1010 } 1003 1011 *p = '\0'; 1004 1012 1005 1013 if (percentage >= 3) { 1006 asprintf(&taskprogress, "TASK: [%s%s] %3d%% done; %2ld:%02ld to go", tmp1, tmp2, percentage, time_remaining / 60, time_remaining % 60); 1014 asprintf(&taskprogress, 1015 "TASK: [%s%s] %3d%% done; %2ld:%02ld to go", 1016 tmp1, tmp2, percentage, time_remaining / 60, 1017 time_remaining % 60); 1007 1018 printf("---evalcall---1--- %s\r\n", 1008 1019 g_isoform_header_str); … … 1091 1102 if (g_current_progress > g_maximum_progress) { 1092 1103 asprintf(&tmp, 1093 "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld",1094 blurb1, blurb2, blurb3, g_current_progress,1095 g_maximum_progress);1104 "update_progress_form_full(%s,%s,%s) --- g_current_progress=%ld; g_maximum_progress=%ld", 1105 blurb1, blurb2, blurb3, g_current_progress, 1106 g_maximum_progress); 1096 1107 log_msg(0, tmp); 1097 1108 paranoid_free(tmp); … … 1118 1129 //g_mysterious_dot_counter = (g_mysterious_dot_counter + 1) % 27; 1119 1130 asprintf(&timeline_str, 1120 "%2ld:%02ld taken %2ld:%02ld remaining ", 1121 time_taken / 60, time_taken % 60, time_remaining / 60, 1122 time_remaining % 60); 1123 asprintf(&percentline_str, " %3d%% done %3d%% to go", 1124 percentage, 100 - percentage); 1131 "%2ld:%02ld taken %2ld:%02ld remaining ", 1132 time_taken / 60, time_taken % 60, time_remaining / 60, 1133 time_remaining % 60); 1134 asprintf(&percentline_str, 1135 " %3d%% done %3d%% to go", percentage, 1136 100 - percentage); 1125 1137 1126 1138 if (g_text_mode) { … … 1130 1142 printf("---progress-form---E---\n"); 1131 1143 1132 j = trunc(percentage /5);1133 tmp1 = (char *) malloc((j + 1) * sizeof(char));1134 for (i = 0, p = tmp1 ; i < j; i++, p++) {1135 1144 j = trunc(percentage / 5); 1145 tmp1 = (char *) malloc((j + 1) * sizeof(char)); 1146 for (i = 0, p = tmp1; i < j; i++, p++) { 1147 *p = '*'; 1136 1148 } 1137 1149 *p = '\0'; 1138 1150 1139 tmp2 = (char *) malloc((20 - j + 1) * sizeof(char));1140 for (i = 0, p = tmp2 ; i < 20 - j; i++, p++) {1141 1151 tmp2 = (char *) malloc((20 - j + 1) * sizeof(char)); 1152 for (i = 0, p = tmp2; i < 20 - j; i++, p++) { 1153 *p = '.'; 1142 1154 } 1143 1155 *p = '\0'; … … 1146 1158 log_msg(2, "percentage = %d", percentage); 1147 1159 } 1148 asprintf(&taskprogress, "TASK: [%s%s] %3d%% done; %2ld:%02ld to go", tmp1, tmp2, percentage, time_remaining / 60, time_remaining % 60); 1160 asprintf(&taskprogress, 1161 "TASK: [%s%s] %3d%% done; %2ld:%02ld to go", tmp1, 1162 tmp2, percentage, time_remaining / 60, 1163 time_remaining % 60); 1149 1164 1150 1165 printf("---progress-form---4--- %s\r\n", taskprogress); … … 1233 1248 if (restoring) { 1234 1249 asprintf(&title_sz, 1235 1250 "Please choose the backup media from which you want to read data."); 1236 1251 asprintf(&minimsg_sz, "Read from:"); 1237 1252 } else { 1238 1253 asprintf(&title_sz, 1239 1254 "Please choose the backup media to which you want to archive data."); 1240 1255 asprintf(&minimsg_sz, "Backup to:"); 1241 1256 } … … 1524 1539 } 1525 1540 asprintf(&differ_sz, 1526 " %d files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.",1527 i);1541 " %d files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", 1542 i); 1528 1543 newtPushHelpLine(differ_sz); 1529 1544 paranoid_free(differ_sz); … … 1531 1546 bClose = newtCompactButton(10, 15, " Close "); 1532 1547 bSelect = newtCompactButton(30, 15, " Select "); 1533 asprintf(&tmp, "%-10s %-20s", "Priority", "Filename"); 1548 asprintf(&tmp, "%-10s %-20s", "Priority", 1549 "Filename"); 1534 1550 headerMsg = newtLabel(2, 1, tmp); 1535 1551 paranoid_free(tmp); … … 1556 1572 filename, reason); 1557 1573 asprintf(&tmp, "%s --- %s", 1558 filelist->el[currline].filename, reason);1574 filelist->el[currline].filename, reason); 1559 1575 popup_and_OK(tmp); 1560 1576 paranoid_free(tmp); -
trunk/mondo/mondo/mondorestore/mondo-prep.c
r86 r89 1803 1803 MONDO_LOGFILE); 1804 1804 1805 /* BERLIOS: shoould not be called each time */ 1806 part_table_fmt = which_partition_format(drive); 1805 1807 output[0] = '\0'; 1806 1808 /* make it a primary/extended/logical */ … … 1808 1810 sprintf(output + strlen(output), "n\np\n%d\n", partno); 1809 1811 } else { 1810 if (partno == 5) { 1811 part_table_fmt = which_partition_format(drive); 1812 /* MBR needs an extended partition if more than 4 partitions */ 1813 if (strcmp(part_table_fmt,"MBR") == 0) { 1814 if (partno == 5) { 1815 if (prev_partno >= 4) { 1816 log_to_screen("You need to leave at least one partition free, for 'extended/logical'"); 1817 paranoid_free(program); 1818 paranoid_free(partition_name); 1819 paranoid_free(tmp); 1820 paranoid_free(logfile); 1821 paranoid_free(output); 1822 return (1); 1823 } else { 1824 sprintf(output + strlen(output), "n\ne\n%d\n\n\n", prev_partno + 1); 1825 } 1826 } 1827 strcat(output + strlen(output), "n\nl\n"); 1828 } else { 1812 1829 /* GPT allows more than 4 primary partitions */ 1813 if ((prev_partno >= 4) && (strcmp(part_table_fmt, "MBR") == 0)) { 1814 log_to_screen 1815 ("You need to leave at least one partition free, for 'extended/logical'"); 1816 paranoid_free(program); 1817 paranoid_free(partition_name); 1818 paranoid_free(tmp); 1819 paranoid_free(logfile); 1820 paranoid_free(output); 1821 return (1); 1822 } else { 1823 sprintf(output + strlen(output), "n\ne\n%d\n\n\n", 1824 prev_partno + 1); 1825 } 1826 } 1827 strcat(output + strlen(output), "n\nl\n"); 1830 sprintf(output + strlen(output), "n\np\n%d\n", partno); 1831 } 1828 1832 } 1829 1833 strcat(output + strlen(output), "\n"); /*start block (ENTER for next free blk */
Note:
See TracChangeset
for help on using the changeset viewer.