aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck_ifs/preen.c
diff options
context:
space:
mode:
authorJulian Elischer <julian@FreeBSD.org>1998-12-03 02:27:35 +0000
committerJulian Elischer <julian@FreeBSD.org>1998-12-03 02:27:35 +0000
commitd33e92f93e2ed9f0bec931917cc23c03c8b5a378 (patch)
treec68b2f7c5232d6013783c8637a106e69396adccc /sbin/fsck_ifs/preen.c
parent233fbe28b0a766be5dd3b15f4f8c8c6056c81c68 (diff)
downloadsrc-d33e92f93e2ed9f0bec931917cc23c03c8b5a378.tar.gz
src-d33e92f93e2ed9f0bec931917cc23c03c8b5a378.zip
Reviewed by: Don Lewis <Don.Lewis@tsc.tdk.com>
Submitted by: Kirk McKusick <mckusick@McKusick.COM> Obtained from: Mckusick, BSDI and a host of others This exactly matches Kirks sources imported under the Tag MCKUSICK2. These are as supplied by kirk with one small change needed to compile under freeBSD. Some FreeBSD patches will be added back, though many have been added to Kirk's sources already.
Notes
Notes: svn path=/head/; revision=41474
Diffstat (limited to 'sbin/fsck_ifs/preen.c')
-rw-r--r--sbin/fsck_ifs/preen.c62
1 files changed, 33 insertions, 29 deletions
diff --git a/sbin/fsck_ifs/preen.c b/sbin/fsck_ifs/preen.c
index 9705aeea9280..ba0140b54b3a 100644
--- a/sbin/fsck_ifs/preen.c
+++ b/sbin/fsck_ifs/preen.c
@@ -32,11 +32,7 @@
*/
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)preen.c 8.5 (Berkeley) 4/28/95";
-#endif
-static const char rcsid[] =
- "$Id$";
#endif /* not lint */
#include <sys/param.h>
@@ -46,7 +42,7 @@ static const char rcsid[] =
#include <ufs/ufs/dinode.h>
#include <ctype.h>
-#include <err.h>
+#include <errno.h>
#include <fstab.h>
#include <string.h>
@@ -93,7 +89,8 @@ checkfstab(preen, maxrun, docheck, chkit)
sumstatus = 0;
for (passno = 1; passno <= 2; passno++) {
if (setfsent() == 0) {
- warnx("can't open checklist file: %s", _PATH_FSTAB);
+ fprintf(stderr, "Can't open checklist file: %s\n",
+ _PATH_FSTAB);
return (8);
}
while ((fsp = getfsent()) != 0) {
@@ -222,11 +219,15 @@ finddisk(name)
dk->name[len] == 0)
return (dk);
}
- if ((*dkp = (struct disk *)malloc(sizeof(struct disk))) == NULL)
- errx(8, "out of memory");
+ if ((*dkp = (struct disk *)malloc(sizeof(struct disk))) == NULL) {
+ fprintf(stderr, "out of memory");
+ exit (8);
+ }
dk = *dkp;
- if ((dk->name = malloc(len + 1)) == NULL)
- errx(8, "out of memory");
+ if ((dk->name = malloc(len + 1)) == NULL) {
+ fprintf(stderr, "out of memory");
+ exit (8);
+ }
(void)strncpy(dk->name, name, len);
dk->name[len] = '\0';
dk->part = NULL;
@@ -249,14 +250,20 @@ addpart(name, fsname, auxdata)
printf("%s in fstab more than once!\n", name);
return;
}
- if ((*ppt = (struct part *)malloc(sizeof(struct part))) == NULL)
- errx(8, "out of memory");
+ if ((*ppt = (struct part *)malloc(sizeof(struct part))) == NULL) {
+ fprintf(stderr, "out of memory");
+ exit (8);
+ }
pt = *ppt;
- if ((pt->name = malloc(strlen(name) + 1)) == NULL)
- errx(8, "out of memory");
+ if ((pt->name = malloc(strlen(name) + 1)) == NULL) {
+ fprintf(stderr, "out of memory");
+ exit (8);
+ }
(void)strcpy(pt->name, name);
- if ((pt->fsname = malloc(strlen(fsname) + 1)) == NULL)
- errx(8, "out of memory");
+ if ((pt->fsname = malloc(strlen(fsname) + 1)) == NULL) {
+ fprintf(stderr, "out of memory");
+ exit (8);
+ }
(void)strcpy(pt->fsname, fsname);
pt->next = NULL;
pt->auxdata = auxdata;
@@ -271,7 +278,7 @@ startdisk(dk, checkit)
dk->pid = fork();
if (dk->pid < 0) {
- warn("fork");
+ perror("fork");
return (8);
}
if (dk->pid == 0)
@@ -287,19 +294,17 @@ blockcheck(origname)
struct stat stslash, stblock, stchar;
char *newname, *raw;
struct fstab *fsinfo;
- int retried = 0, l;
+ int retried = 0, len;
hotroot = 0;
if (stat("/", &stslash) < 0) {
- warn("/");
- printf("Can't stat root\n");
+ printf("Can't stat /: %s\n", strerror(errno));
return (origname);
}
newname = origname;
retry:
if (stat(newname, &stblock) < 0) {
- warn("%s", newname);
- printf("Can't stat %s\n", newname);
+ printf("Can't stat %s: %s\n", newname, strerror(errno));
return (origname);
}
if ((stblock.st_mode & S_IFMT) == S_IFBLK) {
@@ -307,8 +312,7 @@ retry:
hotroot++;
raw = rawname(newname);
if (stat(raw, &stchar) < 0) {
- warn("%s", raw);
- printf("Can't stat %s\n", raw);
+ printf("Can't stat %s: %s\n", raw, strerror(errno));
return (origname);
}
if ((stchar.st_mode & S_IFMT) == S_IFCHR) {
@@ -318,15 +322,15 @@ retry:
return (origname);
}
} else if ((stblock.st_mode & S_IFMT) == S_IFCHR && !retried) {
- newname = unrawname(origname);
+ newname = unrawname(newname);
retried++;
goto retry;
} else if ((stblock.st_mode & S_IFMT) == S_IFDIR && !retried) {
- l = strlen(origname) - 1;
- if (l > 0 && origname[l] == '/')
+ len = strlen(origname) - 1;
+ if (len > 0 && origname[len] == '/')
/* remove trailing slash */
- origname[l] = '\0';
- if(!(fsinfo=getfsfile(origname))) {
+ origname[len] = '\0';
+ if ((fsinfo = getfsfile(origname)) == NULL) {
printf("Can't resolve %s to character special device",
origname);
return (0);