utilities.c (21f181a06a5f4ad70e5a553fd29005d55dce4804) | utilities.c (9ea6f4f0beddb78d2370ec6fe0b8e55330cbc73c) |
---|---|
1/* 2 * Copyright (c) 1980, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 26 unchanged lines hidden (view full) --- 35#if 0 36static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95"; 37#endif 38static const char rcsid[] = 39 "$FreeBSD$"; 40#endif /* not lint */ 41 42#include <sys/param.h> | 1/* 2 * Copyright (c) 1980, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 26 unchanged lines hidden (view full) --- 35#if 0 36static const char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95"; 37#endif 38static const char rcsid[] = 39 "$FreeBSD$"; 40#endif /* not lint */ 41 42#include <sys/param.h> |
43#include <sys/types.h> 44#include <sys/stat.h> |
|
43 44#include <ufs/ufs/dinode.h> 45#include <ufs/ufs/dir.h> 46#include <ufs/ffs/fs.h> 47 48#include <err.h> | 45 46#include <ufs/ufs/dinode.h> 47#include <ufs/ufs/dir.h> 48#include <ufs/ffs/fs.h> 49 50#include <err.h> |
51#include <errno.h> |
|
49#include <string.h> | 52#include <string.h> |
53#include <ctype.h> 54#include <fstab.h> 55#include <stdio.h> 56#include <stdlib.h> 57#include <unistd.h> |
|
50 51#include "fsck.h" 52 53long diskreads, totalreads; /* Disk cache statistics */ 54 55static void rwerror __P((char *mesg, ufs_daddr_t blk)); 56 57int --- 498 unchanged lines hidden (view full) --- 556{ 557 558 switch (idesc->id_fix) { 559 560 case DONTKNOW: 561 if (idesc->id_type == DATA) 562 direrror(idesc->id_number, msg); 563 else | 58 59#include "fsck.h" 60 61long diskreads, totalreads; /* Disk cache statistics */ 62 63static void rwerror __P((char *mesg, ufs_daddr_t blk)); 64 65int --- 498 unchanged lines hidden (view full) --- 564{ 565 566 switch (idesc->id_fix) { 567 568 case DONTKNOW: 569 if (idesc->id_type == DATA) 570 direrror(idesc->id_number, msg); 571 else |
564 pwarn("%s", msg); | 572 pwarn(msg); |
565 if (preen) { 566 printf(" (SALVAGED)\n"); 567 idesc->id_fix = FIX; 568 return (ALTERED); 569 } 570 if (reply("SALVAGE") == 0) { 571 idesc->id_fix = NOFIX; 572 return (0); --- 103 unchanged lines hidden (view full) --- 676#else 677 va_start(ap); 678#endif 679 pfatal("INTERNAL INCONSISTENCY:"); 680 (void)vfprintf(stderr, fmt, ap); 681 va_end(ap); 682 exit(EEXIT); 683} | 573 if (preen) { 574 printf(" (SALVAGED)\n"); 575 idesc->id_fix = FIX; 576 return (ALTERED); 577 } 578 if (reply("SALVAGE") == 0) { 579 idesc->id_fix = NOFIX; 580 return (0); --- 103 unchanged lines hidden (view full) --- 684#else 685 va_start(ap); 686#endif 687 pfatal("INTERNAL INCONSISTENCY:"); 688 (void)vfprintf(stderr, fmt, ap); 689 va_end(ap); 690 exit(EEXIT); 691} |
692 693char * 694blockcheck(origname) 695 char *origname; 696{ 697 struct stat stslash, stblock, stchar; 698 char *newname, *raw; 699 struct fstab *fsinfo; 700 int retried = 0, len; 701 702 newname = origname; 703retry: 704 if (stat(newname, &stblock) < 0) { 705 printf("Can't stat %s: %s\n", newname, strerror(errno)); 706 return (origname); 707 } 708 switch(stblock.st_mode & S_IFMT) { 709 case S_IFCHR: 710 case S_IFBLK: 711 return(newname); 712 case S_IFDIR: 713 if (retried) 714 break; 715 716 len = strlen(origname) - 1; 717 if (len > 0 && origname[len] == '/') 718 /* remove trailing slash */ 719 origname[len] = '\0'; 720 if ((fsinfo = getfsfile(origname)) == NULL) { 721 printf("Can't resolve %s to character special device", 722 origname); 723 return (0); 724 } 725 newname = fsinfo->fs_spec; 726 retried++; 727 goto retry; 728 } 729 /* 730 * Not a block or character device, just return name and 731 * let the user decide whether to use it. 732 */ 733 return (origname); 734} |
|