Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/fsck.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/e2fsprogs/old_e2fsprogs/fsck.c
r1765 r2725 21 21 * 2001, 2002, 2003, 2004, 2005 by Theodore Ts'o. 22 22 * 23 * %Begin-Header% 24 * This file may be redistributed under the terms of the GNU Public 25 * License. 26 * %End-Header% 23 * Licensed under GPLv2, see file LICENSE in this source tree. 27 24 */ 28 25 … … 286 283 if (!s) 287 284 return 0; 288 ret = strdup(s);285 ret = xstrdup(s); 289 286 return ret; 290 287 } … … 353 350 return; 354 351 355 for (p = q = word; *p; q++) { 356 c = *p++; 357 if (c != '\\') { 358 *q = c; 359 } else { 360 *q = bb_process_escape_sequence(&p); 361 } 362 } 363 *q = 0; 352 strcpy_and_process_escape_sequences(word, word); 364 353 } 365 354 … … 381 370 struct fs_info *fs; 382 371 383 if (!(fs = malloc(sizeof(struct fs_info)))) 384 return NULL; 372 fs = xmalloc(sizeof(struct fs_info)); 385 373 386 374 fs->device = string_copy(device); … … 478 466 struct fs_info *fs; 479 467 480 if ((f = fopen(filename, "r")) == NULL) { 481 bb_perror_msg("WARNING: cannot open %s", filename); 468 if ((f = fopen_or_warn(filename, "r")) == NULL) { 482 469 return; 483 470 } … … 535 522 static char *find_fsck(char *type) 536 523 { 537 538 539 540 541 542 543 544 545 for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {546 s = xasprintf(tpl, s, type);547 if (stat(s, &st) == 0) break;548 free(s);549 550 551 524 char *s; 525 const char *tpl; 526 char *p = string_copy(fsck_path); 527 struct stat st; 528 529 /* Are we looking for a program or just a type? */ 530 tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s"); 531 532 for (s = strtok(p, ":"); s; s = strtok(NULL, ":")) { 533 s = xasprintf(tpl, s, type); 534 if (stat(s, &st) == 0) break; 535 free(s); 536 } 537 free(p); 538 return s; 552 539 } 553 540 … … 578 565 pid_t pid; 579 566 580 inst = malloc(sizeof(struct fsck_instance)); 581 if (!inst) 582 return ENOMEM; 583 memset(inst, 0, sizeof(struct fsck_instance)); 567 inst = xzalloc(sizeof(struct fsck_instance)); 584 568 585 569 prog = xasprintf("fsck.%s", type); … … 614 598 for (i=0; i < argc; i++) 615 599 printf("%s ", argv[i]); 616 puts("");600 bb_putchar('\n'); 617 601 } 618 602 … … 621 605 pid = -1; 622 606 else if ((pid = fork()) < 0) { 623 perror(" fork");607 perror("vfork"+1); 624 608 return errno; 625 609 } else if (pid == 0) { … … 627 611 close(0); 628 612 (void) execv(s, argv); 629 bb_ perror_msg_and_die("%s",argv[0]);613 bb_simple_perror_msg_and_die(argv[0]); 630 614 } 631 615 … … 887 871 num = 0; 888 872 s = strtok(list, ","); 889 while (s) {873 while (s) { 890 874 negate = 0; 891 875 if (strncmp(s, "no", 2) == 0) { … … 932 916 933 917 s = strtok(list, ","); 934 while (s) {918 while (s) { 935 919 if (strcmp(s, opt) == 0) { 936 920 free(list); … … 1006 990 if (s == NULL) { 1007 991 if (wanted) 1008 bb_error_msg("can not check %s: fsck.%s not found",992 bb_error_msg("can't check %s: fsck.%s not found", 1009 993 fs->device, fs->type); 1010 994 return 1; … … 1175 1159 { 1176 1160 int i, j; 1177 char *arg, *dev, *tmp = 0;1161 char *arg, *dev, *tmp = NULL; 1178 1162 char options[128]; 1179 1163 int opt = 0; … … 1208 1192 */ 1209 1193 if (access("/proc/partitions", R_OK) < 0) { 1210 bb_perror_msg_and_die("can not open /proc/partitions "1194 bb_perror_msg_and_die("can't open /proc/partitions " 1211 1195 "(is /proc mounted?)"); 1212 1196 } … … 1220 1204 else 1221 1205 bb_error_msg_and_die( 1222 "can not find matching filesystem: %s", arg);1206 "can't find matching filesystem: %s", arg); 1223 1207 } 1224 1208 devices[num_devices++] = dev ? dev : string_copy(arg); … … 1322 1306 } 1323 1307 1324 int fsck_main(int argc, char **argv) ;1308 int fsck_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1325 1309 int fsck_main(int argc, char **argv) 1326 1310 {
Note:
See TracChangeset
for help on using the changeset viewer.