summaryrefslogtreecommitdiffstats
path: root/sbin/quotacheck
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1998-12-03 02:27:35 +0000
committerjulian <julian@FreeBSD.org>1998-12-03 02:27:35 +0000
commitc1ef9f83c919949e90841ae0990aa9a0273d6490 (patch)
tree766d55719160577172499b05ce54cc96670cf3c4 /sbin/quotacheck
parent1a5eceeafeb45fc95a5c9fe1830e0d3e349ec69a (diff)
downloadFreeBSD-src-c1ef9f83c919949e90841ae0990aa9a0273d6490.zip
FreeBSD-src-c1ef9f83c919949e90841ae0990aa9a0273d6490.tar.gz
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.
Diffstat (limited to 'sbin/quotacheck')
-rw-r--r--sbin/quotacheck/preen.c62
1 files changed, 33 insertions, 29 deletions
diff --git a/sbin/quotacheck/preen.c b/sbin/quotacheck/preen.c
index 9705aee..ba0140b 100644
--- a/sbin/quotacheck/preen.c
+++ b/sbin/quotacheck/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);
OpenPOWER on IntegriCloud