Changeset 1185 in MondoRescue for trunk/mondo/src/common/libmondo-tools.c
- Timestamp:
- Feb 19, 2007, 1:51:26 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/src/common/libmondo-tools.c
r1106 r1185 10 10 #include "my-stuff.h" 11 11 #include "mr_mem.h" 12 #include "mr_msg.h" 12 13 #include "mr_file.h" 13 14 … … 24 25 #include <arpa/inet.h> 25 26 #endif 26 #include "mr_mem.h"27 27 28 28 /*@unused@*/ … … 199 199 200 200 201 char *get_architecture( )201 char *get_architecture(void) 202 202 { 203 203 #ifdef __IA32__ … … 205 205 #endif 206 206 #ifdef __X86_64__ 207 return ("x86 -64");207 return ("x86_64"); 208 208 #endif 209 209 #ifdef __IA64__ … … 215 215 216 216 217 double get_kernel_version( )217 double get_kernel_version(void) 218 218 { 219 219 char *p, *tmp; … … 242 242 243 243 244 245 246 247 244 /** 248 245 * Get the current time. 249 246 * @return number of seconds since the epoch. 250 247 */ 251 long get_time( )248 long get_time(void) 252 249 { 253 250 return (long) time((void *) 0); 254 251 } 255 256 257 258 259 260 252 261 253 … … 298 290 } 299 291 #endif 300 301 302 292 303 293 … … 354 344 char *mondo_mkisofs_sz = NULL; 355 345 char *command = NULL; 356 char *hostname = NULL, *ip_address = NULL; 346 char *hostname = NULL; 347 char *ip_address = NULL; 357 348 int retval = 0; 358 349 long avm = 0; … … 363 354 char *call_before_iso_user = NULL; 364 355 int rdsiz_MB; 356 char *iso_dev = NULL; 357 char *iso_mnt = NULL; 358 char *iso_tmp = NULL; 365 359 char *iso_path = NULL; 366 360 FILE *fd1 = NULL; … … 400 394 avm += atol(tmp); 401 395 mr_free(tmp); 402 tmp = call_program_and_get_last_line_of_output396 tmp1 = call_program_and_get_last_line_of_output 403 397 ("swapinfo | grep -v Device | tr -s ' ' | cut -d' ' -f4 | tr '\n' '+' | sed 's/+$//' | bc"); 404 398 avm += atol(tmp); … … 412 406 mr_free(tmp); 413 407 mr_asprintf(&command, "mount /dev/shm -t tmpfs %s -o size=%d%c", 414 408 g_tmpfs_mountpt, rdsiz_MB, 'm'); 415 409 run_program_and_log_output("cat /proc/cpuinfo", 5); 416 410 /* BERLIOS: rpm is not necessarily there ! */ … … 495 489 popup_and_OK("Fatal Error: Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details."); 496 490 fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details."); 497 } 491 } 498 492 mr_free(tmp); 499 493 mr_free(command); … … 507 501 || bkpinfo->backup_media_type == cdr) { 508 502 if (!bkpinfo->manual_cd_tray) { 509 mr_ asprintf(&extra_cdrom_params, "-waiti ");503 mr_strcat(extra_cdrom_params, "-waiti "); 510 504 } 511 505 if (bkpinfo->backup_media_type == cdrw) { 512 if (extra_cdrom_params != NULL) { 513 mr_asprintf(&tmp, extra_cdrom_params); 514 mr_free(extra_cdrom_params); 515 mr_asprintf(&extra_cdrom_params, "%s blank=fast ", tmp); 516 } else { 517 mr_asprintf(&extra_cdrom_params, "blank=fast "); 518 } 506 mr_strcat(extra_cdrom_params, "blank=fast "); 519 507 } 520 508 tmp = find_home_of_exe("cdrecord"); … … 600 588 601 589 fd1 = mr_fopen(MONDORESTORECFG, "a"); 602 mr_fprintf(fd1, "iso-dev 590 mr_fprintf(fd1, "iso-dev=%s\n", iso_dev); 603 591 604 592 mr_asprintf(&command, "mount | grep -w %s | tail -n1 | cut -d' ' -f3", … … 611 599 612 600 log_it("res of it = %s", iso_mnt); 613 mr_fprintf(fd1, "iso-mnt 601 mr_fprintf(fd1, "iso-mnt=%s\n", iso_mnt); 614 602 log_it("isomnt: %s, %d", iso_mnt, strlen(iso_mnt)); 615 603 … … 617 605 if (strlen(iso_tmp) >= strlen(iso_mnt)) { 618 606 mr_asprintf(&iso_path, "%s", iso_tmp + strlen(iso_mnt)); 607 } else { 608 mr_asprintf(&iso_path, ""); 619 609 } 620 610 mr_free(iso_tmp); … … 622 612 623 613 log_it("isodir: %s", iso_path); 624 mr_fprintf(fd1, "isodir 614 mr_fprintf(fd1, "isodir=%s\n", iso_path); 625 615 mr_free(iso_path); 626 616 627 617 log_it("iso-prefix: %s", bkpinfo->prefix); 628 mr_fprintf(fd1, "iso-prefix 618 mr_fprintf(fd1, "iso-prefix=%s\n", bkpinfo->prefix); 629 619 630 620 mr_fclose(fd1); … … 648 638 } else { 649 639 mr_asprintf(&ip_address, "%s%s", inet_ntoa((struct in_addr) 650 *((struct in_addr 651 *) hent-> 652 h_addr)), 653 strchr(bkpinfo->nfs_mount, ':')); 640 *((struct in_addr *) hent->h_addr)), 641 strchr(bkpinfo->nfs_mount, ':')); 654 642 mr_allocstr(bkpinfo->nfs_mount, ip_address); 655 643 mr_free(ip_address); … … 684 672 return (retval); 685 673 } 686 687 674 688 675 … … 710 697 } 711 698 712 unlink(MONDO_TRACEFILE);713 699 run_program_and_log_output("rm -Rf /tmp/changed.files*", FALSE); 714 700 if ((g_mondo_home = find_and_store_mondoarchives_home()) == NULL) { … … 811 797 char *command = NULL; 812 798 char *out_sz = NULL; 813 long res ;799 long res = 0L; 814 800 815 801 assert_string_is_neither_NULL_nor_zerolength(partition); … … 822 808 823 809 mr_asprintf(&command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4", 824 810 partition); 825 811 out_sz = call_program_and_get_last_line_of_output(command); 826 812 mr_free(command); 813 827 814 if (strlen(out_sz) == 0) { 828 815 return (-1); … … 832 819 return (res); 833 820 } 834 835 821 836 822 … … 1062 1048 return (0); 1063 1049 */ } else { 1064 mr_asprintf(&command, "grep '%s .*' %s| cut -d' 1050 mr_asprintf(&command, "grep '%s .*' %s| cut -d'=' -f2,3,4,5", 1065 1051 label, config_file); 1066 1052 value = call_program_and_get_last_line_of_output(command); … … 1110 1096 void mount_boot_if_necessary() 1111 1097 { 1112 char *tmp ;1113 char *tmp1 ;1114 char *command ;1098 char *tmp = NULL; 1099 char *tmp1 = NULL; 1100 char *command = NULL; 1115 1101 1116 1102 mr_msg(1, "Started sub"); … … 1140 1126 mr_asprintf(&g_boot_mountpt, tmp); 1141 1127 mr_asprintf(&tmp1, 1142 1143 1128 "%s (your /boot partition) is not mounted. I'll mount it before backing up", 1129 g_boot_mountpt); 1144 1130 log_it(tmp1); 1145 1131 mr_free(tmp1); … … 1190 1176 1191 1177 1192 1193 1178 /** 1194 1179 * Write a line to a configuration file. Writes a line of the form, … … 1202 1187 { 1203 1188 /*@ buffers ***************************************************** */ 1204 char *command ;1205 char *tempfile ;1206 char *tmp ;1189 char *command = NULL; 1190 char *tempfile = NULL; 1191 char *tmp = NULL; 1207 1192 1208 1193 … … 1238 1223 return (0); 1239 1224 } 1225 1240 1226 1241 1227 /**
Note:
See TracChangeset
for help on using the changeset viewer.