Changeset 783 in MondoRescue for trunk/mondo/mondo/mondorestore/mondo-prep.c
- Timestamp:
- Aug 31, 2006, 5:09:20 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/mondorestore/mondo-prep.c
r764 r783 9 9 10 10 11 #include " ../common/my-stuff.h"11 #include "my-stuff.h" 12 12 #include "../common/mondostructures.h" 13 13 #include "mondoprep.h" … … 53 53 char *command; 54 54 int lino; 55 int i;56 55 FILE *fout; 57 56 char *buf; 58 const int blocksize = 512;59 57 struct list_of_disks *drivelist = NULL; 60 58 // If LVMs are present and a zero-and-reboot wasn't recently undertaken 61 59 // then zero & insist on reboot. 62 buf = malloc(blocksize);63 60 if (does_file_exist("/tmp/i-want-my-lvm")) // FIXME - cheating :) 64 61 { … … 89 86 log_to_screen("Please hit 'Enter' to reboot."); 90 87 for (lino = 0; lino < drivelist->entries; lino++) { 91 for (i = 0; i < blocksize; i++) { 92 buf[i] = 0; 93 } 94 sprintf(buf, "%s\n", MONDO_WAS_HERE); 88 asprintf(&buf, "%s\n", MONDO_WAS_HERE); 95 89 fout = fopen(drivelist->el[lino].device, "w+"); 96 90 if (!fout) { … … 98 92 drivelist->el[lino].device); 99 93 } else { 100 if (1 != fwrite(buf, blocksize, 1, fout)) {94 if (1 != fwrite(buf, strlen(buf)+1, 1, fout)) { 101 95 log_msg(1, "Failed to wipe %s", 102 96 drivelist->el[lino].device); … … 107 101 fclose(fout); 108 102 } 103 paranoid_free(buf); 109 104 } 110 105 sync(); … … 257 252 for (getline(&incoming, &n1, fin); !feof(fin); getline(&incoming, &n1, fin)) { 258 253 fgetpos(fin, &orig_pos); 259 /* BERLIOS : Strange no ?*/254 /* we want to execute lines begining with a # */ 260 255 if (incoming[0] != '#') { 261 256 continue; … … 268 263 } 269 264 if ((p = strstr(incoming, "vgcreate"))) { 270 // include next line(s) if they end in /dev (cos we've got a broken i-want-my-lvm)265 // include next line(s) if they end in /dev (cos we've got a broken i-want-my-lvm) 271 266 for (getline(&tmp, &n, fin); !feof(fin); getline(&tmp, &n, fin)) { 272 267 if (tmp[0] == '#') { … … 287 282 } 288 283 } 289 malloc_string(tmp1); 290 strcpy(tmp1, p + strlen("vgcreate") + 1); 284 asprintf(&tmp1, p + strlen("vgcreate") + 1); 291 285 for (q = tmp1; *q > 32; q++); 292 286 *q = '\0'; … … 294 288 asprintf(&tmp, "rm -Rf /dev/%s", tmp1); 295 289 paranoid_free(tmp1); 290 296 291 run_program_and_log_output(tmp, 1); 297 292 paranoid_free(tmp); … … 304 299 } 305 300 for (p = incoming + 1; *p == ' '; p++); 306 paranoid_free(command); 307 asprintf(&command, p); 301 paranoid_alloc(command,p); 308 302 for (p = command; *p != '\0'; p++); 309 303 for (; *(p - 1) < 32; p--); 310 304 *p = '\0'; 305 306 /* BERLIOS: we should rather define LVMv1 or v2 and use it */ 311 307 res = run_program_and_log_output(command, 5); 312 308 if (res > 0 && (p = strstr(command, "lvm "))) { … … 338 334 log_msg(5, "p='%s' --> extents=%ld", p, extents); 339 335 paranoid_free(tmp); 336 340 337 p = strstr(command, "-L"); 341 338 if (!p) { … … 349 346 *q = ' '; 350 347 } 348 /* BERLIOS: Dangerous: no size control !! */ 351 349 sprintf(p, "%ld", extents); 352 350 i = strlen(p); … … 359 357 *(q - 1) = ' '; 360 358 } 359 /* BERLIOS: Dangerous: no size control !! */ 361 360 sprintf(p, "%ld%c", extents, 'm'); 362 361 i = strlen(p); … … 673 672 char *tmp = NULL; 674 673 char *tmp1 = NULL; 674 #ifdef __FreeBSD__ 675 675 char *line = NULL; 676 676 char *status = NULL; … … 679 679 size_t n = 0; 680 680 size_t n1 = 0; 681 #endif 681 682 682 683 /** end ****************************************************************/ … … 1525 1526 // If so, then we just call label_drive_or_slice() and return. 1526 1527 char c; 1528 char *command; 1529 1527 1530 if (current_devno == 1) { 1528 1531 // try DangerouslyDedicated mode … … 1538 1541 drivename, 1539 1542 0); 1540 char command[MAX_STR_LEN]; 1541 sprintf(command, "disklabel -B %s", 1543 asprintf(&command, "disklabel -B %s", 1542 1544 basename(drivename)); 1543 1545 if (system(command)) { … … 1546 1548 ("Warning! Unable to make the drive bootable.")); 1547 1549 } 1550 paranoid_free(command); 1548 1551 paranoid_free(device_str); 1549 1552 … … 2077 2080 asprintf(&partcode, "8e"); 2078 2081 } else if (format[0] == '\0') { /* LVM physical partition */ 2079 asprintf(&partcode, " ");2082 asprintf(&partcode, "%s", ""); 2080 2083 } else if (strlen(format) >= 1 && strlen(format) <= 2) { 2081 2084 asprintf(&partcode, format); … … 2375 2378 2376 2379 assert_string_is_neither_NULL_nor_zerolength(format); 2377 assert(program != NULL);2378 2380 2379 2381 if (strcmp(format, "swap") == 0) { 2380 2382 #ifdef __FreeBSD__ 2381 strcpy(program, "true");2383 asprintf(&program, "true"); 2382 2384 #else 2383 strcpy(program, "mkswap");2385 asprintf(&program, "mkswap"); 2384 2386 #endif 2385 2387 } else if (strcmp(format, "vfat") == 0) { 2386 strcpy(program, "format-and-kludge-vfat");2388 asprintf(&program, "format-and-kludge-vfat"); 2387 2389 #ifndef __FreeBSD__ 2388 2390 } else if (strcmp(format, "reiserfs") == 0) { 2389 strcpy(program, "mkreiserfs -ff");2391 asprintf(&program, "mkreiserfs -ff"); 2390 2392 } else if (strcmp(format, "xfs") == 0) { 2391 strcpy(program, "mkfs.xfs -f -q");2393 asprintf(&program, "mkfs.xfs -f -q"); 2392 2394 } else if (strcmp(format, "jfs") == 0) { 2393 strcpy(program, "mkfs.jfs");2395 asprintf(&program, "mkfs.jfs"); 2394 2396 } else if (strcmp(format, "ext3") == 0) { 2395 strcpy(program, "mkfs -t ext2 -F -j -q");2397 asprintf(&program, "mkfs -t ext2 -F -j -q"); 2396 2398 } else if (strcmp(format, "minix") == 0) { 2397 strcpy(program, "mkfs.minix");2399 asprintf(&program, "mkfs.minix"); 2398 2400 #endif 2399 2401 } else if (strcmp(format, "ext2") == 0) { 2400 strcpy(program, "mke2fs -F -q");2402 asprintf(&program, "mke2fs -F -q"); 2401 2403 } else { 2402 2404 #ifdef __FreeBSD__ 2403 sprintf(program, "newfs_%s", format);2405 asprintf(&program, "newfs_%s", format); 2404 2406 #else 2405 sprintf(program, "mkfs -t %s -c", format); // -c checks for bad blocks2407 asprintf(&program, "mkfs -t %s -c", format); // -c checks for bad blocks 2406 2408 #endif 2407 2409 asprintf(&tmp, "Unknown format (%s) - assuming '%s' will do", format, … … 2504 2506 } 2505 2507 2506 /*2507 sprintf (tmp, "cp -f %s %s.pre-resize", g_mountlist_fname, g_mountlist_fname);2508 run_program_and_log_output (tmp, FALSE);2509 */2510 2511 2508 current_size_of_drive = get_phys_size_of_drive(drive_name); 2512 2509 … … 2600 2597 assert(mountlist != NULL); 2601 2598 2602 if (g_mountlist_fname [0] == '\0') {2599 if (g_mountlist_fname == NULL) { 2603 2600 log_it 2604 2601 ("resize_mountlist_prop...() - warning - mountlist fname is blank"); … … 2648 2645 if (c && strncmp(c, "/disc", 5) == 0) { 2649 2646 /* yup its devfs, change the "disc" to "part" so the existing code works */ 2650 str cpy(c + 1, "part");2647 strncpy(c + 1, "part", (size_t)5); 2651 2648 } 2652 2649 drivemntlist->entries = 0;
Note:
See TracChangeset
for help on using the changeset viewer.