Changeset 2466 for trunk/src/kmk/kmkbuiltin/rm.c
- Timestamp:
- Jul 12, 2011, 11:52:39 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/kmkbuiltin/rm.c
r2464 r2466 39 39 #endif /* not lint */ 40 40 #include <sys/cdefs.h> 41 / /__FBSDID("$FreeBSD: src/bin/rm/rm.c,v 1.47 2004/04/06 20:06:50 markm Exp $");41 /*__FBSDID("$FreeBSD: src/bin/rm/rm.c,v 1.47 2004/04/06 20:06:50 markm Exp $");*/ 42 42 #endif 43 43 … … 287 287 } 288 288 while ((p = fts_read(fts)) != NULL) { 289 const char *operation = "chflags"; 289 290 switch (p->fts_info) { 290 291 case FTS_DNR: 291 292 if (!fflag || p->fts_errno != ENOENT) { 292 fprintf(stderr, " %s: %s: %s" CUR_LINE() "\n",293 fprintf(stderr, "fts: %s: %s: %s" CUR_LINE() "\n", 293 294 argv0, p->fts_path, strerror(p->fts_errno)); 294 295 eval = 1; … … 297 298 case FTS_ERR: 298 299 fts_close(fts); 299 return errx(1, " %s: %s " CUR_LINE(), p->fts_path, strerror(p->fts_errno));300 return errx(1, "fts: %s: %s " CUR_LINE(), p->fts_path, strerror(p->fts_errno)); 300 301 case FTS_NS: 301 302 /* … … 306 307 break; 307 308 if (!fflag || p->fts_errno != ENOENT) { 308 fprintf(stderr, " %s: %s: %s " CUR_LINE() "\n",309 argv0, p->fts_path, strerror(p->fts_errno) , __LINE__);309 fprintf(stderr, "fts: %s: %s: %s " CUR_LINE() "\n", 310 argv0, p->fts_path, strerror(p->fts_errno)); 310 311 eval = 1; 311 312 } … … 370 371 continue; 371 372 } 373 operation = "mkdir"; 372 374 break; 373 375 … … 381 383 continue; 382 384 } 385 operation = "undelete"; 383 386 break; 384 387 #endif … … 410 413 continue; 411 414 } 415 operation = "unlink"; 416 break; 412 417 } 413 418 } … … 415 420 err: 416 421 #endif 417 fprintf(stderr, "%s: %s: %s " CUR_LINE() "\n", argv0, p->fts_path, strerror(errno));422 fprintf(stderr, "%s: %s: %s: %s " CUR_LINE() "\n", operation, argv0, p->fts_path, strerror(errno)); 418 423 eval = 1; 419 424 } … … 447 452 */ 448 453 while ((f = *argv++) != NULL) { 454 const char *operation = "?"; 449 455 /* Assume if can't stat the file, can't unlink it. */ 450 456 if (lstat(f, &sb)) { … … 457 463 #endif 458 464 if (!fflag || errno != ENOENT) { 459 fprintf(stderr, " %s: %s: %s " CUR_LINE() "\n", argv0, f, strerror(errno));465 fprintf(stderr, "lstat: %s: %s: %s " CUR_LINE() "\n", argv0, f, strerror(errno)); 460 466 eval = 1; 461 467 } … … 485 491 #endif 486 492 if (rval == 0) { 487 if (S_ISWHT(sb.st_mode)) 493 if (S_ISWHT(sb.st_mode)) { 488 494 rval = undelete(f); 489 else if (S_ISDIR(sb.st_mode)) 495 operation = "undelete"; 496 } else if (S_ISDIR(sb.st_mode)) { 490 497 rval = rmdir(f); 491 else { 498 operation = "rmdir"; 499 } else { 492 500 if (Pflag) 493 501 if (!rm_overwrite(f, &sb)) … … 500 508 } 501 509 #endif 510 operation = "unlink"; 502 511 } 503 512 } 504 513 if (rval && (!fflag || errno != ENOENT)) { 505 fprintf(stderr, "%s: %s: %s " CUR_LINE() "\n", argv0, f, strerror(errno));514 fprintf(stderr, "%s: %s: %s: %s" CUR_LINE() "\n", operation, argv0, f, strerror(errno)); 506 515 eval = 1; 507 516 } … … 533 542 int bsize, fd, wlen; 534 543 char *buf = NULL; 544 const char *operation = "lstat"; 535 545 536 546 fd = -1; … … 542 552 if (!S_ISREG(sbp->st_mode)) 543 553 return (1); 554 operation = "open"; 544 555 if ((fd = open(file, O_WRONLY, 0)) == -1) 545 556 goto err; … … 557 568 558 569 #define PASS(byte) { \ 570 operation = "write"; \ 559 571 memset(buf, byte, bsize); \ 560 572 for (len = sbp->st_size; len > 0; len -= wlen) { \ … … 565 577 } 566 578 PASS(0xff); 579 operation = "fsync/lseek"; 567 580 if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) 568 581 goto err; 569 582 PASS(0x00); 583 operation = "fsync/lseek"; 570 584 if (fsync(fd) || lseek(fd, (off_t)0, SEEK_SET)) 571 585 goto err; … … 575 589 return (1); 576 590 } 591 operation = "fsync/close"; 577 592 578 593 err: eval = 1; … … 581 596 if (fd != -1) 582 597 close(fd); 583 fprintf(stderr, "%s: %s: %s " CUR_LINE() "\n", argv0, file, strerror(errno));598 fprintf(stderr, "%s: %s: %s: %s" CUR_LINE() "\n", operation, argv0, file, strerror(errno)); 584 599 return (0); 585 600 }
Note:
See TracChangeset
for help on using the changeset viewer.