Fix an obvious bogon when checking multiple file systems, and use the libc
version of err(3).
This commit is contained in:
parent
0c5a342fde
commit
c55423b664
|
@ -42,7 +42,7 @@ static char copyright[] =
|
|||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)quotacheck.c 8.3 (Berkeley) 1/29/94";*/
|
||||
static char *rcsid = "$Id: quotacheck.c,v 1.5 1994/06/08 19:32:34 mycroft Exp $";
|
||||
static char *rcsid = "$Id: quotacheck.c,v 1.6 1994/08/16 19:22:02 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -64,6 +64,7 @@ static char *rcsid = "$Id: quotacheck.c,v 1.5 1994/06/08 19:32:34 mycroft Exp $"
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
|
||||
char *qfname = QUOTAFILENAME;
|
||||
char *qfextension[] = INITQFNAMES;
|
||||
|
@ -74,7 +75,7 @@ union {
|
|||
char dummy[MAXBSIZE];
|
||||
} un;
|
||||
#define sblock un.sblk
|
||||
long dev_bsize = 1;
|
||||
long dev_bsize;
|
||||
long maxino;
|
||||
|
||||
struct quotaname {
|
||||
|
@ -108,7 +109,6 @@ struct fileusage *
|
|||
char *blockcheck __P((char *));
|
||||
void bread __P((daddr_t, char *, long));
|
||||
int chkquota __P((char *, char *, struct quotaname *));
|
||||
void err __P((const char *, ...));
|
||||
void freeinodebuf __P((void));
|
||||
struct dinode *
|
||||
getnextinode __P((ino_t));
|
||||
|
@ -180,7 +180,7 @@ main(argc, argv)
|
|||
if (aflag)
|
||||
exit(checkfstab(1, maxrun, needchk, chkquota));
|
||||
if (setfsent() == 0)
|
||||
err("%s: can't open", FSTAB);
|
||||
err(1, "%s: can't open", FSTAB);
|
||||
while ((fs = getfsent()) != NULL) {
|
||||
if (((argnum = oneof(fs->fs_file, argv, argc)) >= 0 ||
|
||||
(argnum = oneof(fs->fs_spec, argv, argc)) >= 0) &&
|
||||
|
@ -218,7 +218,7 @@ needchk(fs)
|
|||
strcmp(fs->fs_type, FSTAB_RW))
|
||||
return (NULL);
|
||||
if ((qnp = malloc(sizeof(*qnp))) == NULL)
|
||||
err("%s", strerror(errno));
|
||||
err(1, "%s", strerror(errno));
|
||||
qnp->flags = 0;
|
||||
if (gflag && hasquota(fs, GRPQUOTA, &qfnp)) {
|
||||
strcpy(qnp->grpqfname, qfnp);
|
||||
|
@ -261,6 +261,7 @@ chkquota(fsname, mntpt, qnp)
|
|||
(void)printf(" quotas for %s (%s)\n", fsname, mntpt);
|
||||
}
|
||||
sync();
|
||||
dev_bsize = 1;
|
||||
bread(SBOFF, (char *)&sblock, (long)SBSIZE);
|
||||
dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
|
||||
maxino = sblock.fs_ncg * sblock.fs_ipg;
|
||||
|
@ -503,7 +504,7 @@ addid(id, type, name)
|
|||
else
|
||||
len = 10;
|
||||
if ((fup = calloc(1, sizeof(*fup) + len)) == NULL)
|
||||
err("%s", strerror(errno));
|
||||
err(1, "%s", strerror(errno));
|
||||
fhp = &fuhead[type][id & (FUHASH - 1)];
|
||||
fup->fu_next = *fhp;
|
||||
*fhp = fup;
|
||||
|
@ -535,7 +536,7 @@ getnextinode(inumber)
|
|||
static struct dinode *dp;
|
||||
|
||||
if (inumber != nextino++ || inumber > maxino)
|
||||
err("bad inode number %d to nextinode", inumber);
|
||||
err(1, "bad inode number %d to nextinode", inumber);
|
||||
if (inumber >= lastinum) {
|
||||
readcnt++;
|
||||
dblk = fsbtodb(&sblock, ino_to_fsba(&sblock, lastinum));
|
||||
|
@ -575,7 +576,7 @@ resetinodebuf()
|
|||
}
|
||||
if (inodebuf == NULL &&
|
||||
(inodebuf = malloc((u_int)inobufsize)) == NULL)
|
||||
err("%s", strerror(errno));
|
||||
err(1, "%s", strerror(errno));
|
||||
while (nextino < ROOTINO)
|
||||
getnextinode(nextino);
|
||||
}
|
||||
|
@ -604,34 +605,5 @@ bread(bno, buf, cnt)
|
|||
|
||||
if (lseek(fi, (off_t)bno * dev_bsize, SEEK_SET) < 0 ||
|
||||
read(fi, buf, cnt) != cnt)
|
||||
err("block %ld", bno);
|
||||
}
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
err(const char *fmt, ...)
|
||||
#else
|
||||
err(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "quotacheck: ");
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
exit(1);
|
||||
/* NOTREACHED */
|
||||
err(1, "block %ld", bno);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ static char copyright[] =
|
|||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)quotacheck.c 8.3 (Berkeley) 1/29/94";*/
|
||||
static char *rcsid = "$Id: quotacheck.c,v 1.5 1994/06/08 19:32:34 mycroft Exp $";
|
||||
static char *rcsid = "$Id: quotacheck.c,v 1.6 1994/08/16 19:22:02 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
|
@ -64,6 +64,7 @@ static char *rcsid = "$Id: quotacheck.c,v 1.5 1994/06/08 19:32:34 mycroft Exp $"
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
|
||||
char *qfname = QUOTAFILENAME;
|
||||
char *qfextension[] = INITQFNAMES;
|
||||
|
@ -74,7 +75,7 @@ union {
|
|||
char dummy[MAXBSIZE];
|
||||
} un;
|
||||
#define sblock un.sblk
|
||||
long dev_bsize = 1;
|
||||
long dev_bsize;
|
||||
long maxino;
|
||||
|
||||
struct quotaname {
|
||||
|
@ -108,7 +109,6 @@ struct fileusage *
|
|||
char *blockcheck __P((char *));
|
||||
void bread __P((daddr_t, char *, long));
|
||||
int chkquota __P((char *, char *, struct quotaname *));
|
||||
void err __P((const char *, ...));
|
||||
void freeinodebuf __P((void));
|
||||
struct dinode *
|
||||
getnextinode __P((ino_t));
|
||||
|
@ -180,7 +180,7 @@ main(argc, argv)
|
|||
if (aflag)
|
||||
exit(checkfstab(1, maxrun, needchk, chkquota));
|
||||
if (setfsent() == 0)
|
||||
err("%s: can't open", FSTAB);
|
||||
err(1, "%s: can't open", FSTAB);
|
||||
while ((fs = getfsent()) != NULL) {
|
||||
if (((argnum = oneof(fs->fs_file, argv, argc)) >= 0 ||
|
||||
(argnum = oneof(fs->fs_spec, argv, argc)) >= 0) &&
|
||||
|
@ -218,7 +218,7 @@ needchk(fs)
|
|||
strcmp(fs->fs_type, FSTAB_RW))
|
||||
return (NULL);
|
||||
if ((qnp = malloc(sizeof(*qnp))) == NULL)
|
||||
err("%s", strerror(errno));
|
||||
err(1, "%s", strerror(errno));
|
||||
qnp->flags = 0;
|
||||
if (gflag && hasquota(fs, GRPQUOTA, &qfnp)) {
|
||||
strcpy(qnp->grpqfname, qfnp);
|
||||
|
@ -261,6 +261,7 @@ chkquota(fsname, mntpt, qnp)
|
|||
(void)printf(" quotas for %s (%s)\n", fsname, mntpt);
|
||||
}
|
||||
sync();
|
||||
dev_bsize = 1;
|
||||
bread(SBOFF, (char *)&sblock, (long)SBSIZE);
|
||||
dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
|
||||
maxino = sblock.fs_ncg * sblock.fs_ipg;
|
||||
|
@ -503,7 +504,7 @@ addid(id, type, name)
|
|||
else
|
||||
len = 10;
|
||||
if ((fup = calloc(1, sizeof(*fup) + len)) == NULL)
|
||||
err("%s", strerror(errno));
|
||||
err(1, "%s", strerror(errno));
|
||||
fhp = &fuhead[type][id & (FUHASH - 1)];
|
||||
fup->fu_next = *fhp;
|
||||
*fhp = fup;
|
||||
|
@ -535,7 +536,7 @@ getnextinode(inumber)
|
|||
static struct dinode *dp;
|
||||
|
||||
if (inumber != nextino++ || inumber > maxino)
|
||||
err("bad inode number %d to nextinode", inumber);
|
||||
err(1, "bad inode number %d to nextinode", inumber);
|
||||
if (inumber >= lastinum) {
|
||||
readcnt++;
|
||||
dblk = fsbtodb(&sblock, ino_to_fsba(&sblock, lastinum));
|
||||
|
@ -575,7 +576,7 @@ resetinodebuf()
|
|||
}
|
||||
if (inodebuf == NULL &&
|
||||
(inodebuf = malloc((u_int)inobufsize)) == NULL)
|
||||
err("%s", strerror(errno));
|
||||
err(1, "%s", strerror(errno));
|
||||
while (nextino < ROOTINO)
|
||||
getnextinode(nextino);
|
||||
}
|
||||
|
@ -604,34 +605,5 @@ bread(bno, buf, cnt)
|
|||
|
||||
if (lseek(fi, (off_t)bno * dev_bsize, SEEK_SET) < 0 ||
|
||||
read(fi, buf, cnt) != cnt)
|
||||
err("block %ld", bno);
|
||||
}
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
err(const char *fmt, ...)
|
||||
#else
|
||||
err(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "quotacheck: ");
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
exit(1);
|
||||
/* NOTREACHED */
|
||||
err(1, "block %ld", bno);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue