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
|
#ifndef lint
|
||||||
/*static char sccsid[] = "from: @(#)quotacheck.c 8.3 (Berkeley) 1/29/94";*/
|
/*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 */
|
#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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <err.h>
|
||||||
|
|
||||||
char *qfname = QUOTAFILENAME;
|
char *qfname = QUOTAFILENAME;
|
||||||
char *qfextension[] = INITQFNAMES;
|
char *qfextension[] = INITQFNAMES;
|
||||||
|
@ -74,7 +75,7 @@ union {
|
||||||
char dummy[MAXBSIZE];
|
char dummy[MAXBSIZE];
|
||||||
} un;
|
} un;
|
||||||
#define sblock un.sblk
|
#define sblock un.sblk
|
||||||
long dev_bsize = 1;
|
long dev_bsize;
|
||||||
long maxino;
|
long maxino;
|
||||||
|
|
||||||
struct quotaname {
|
struct quotaname {
|
||||||
|
@ -108,7 +109,6 @@ struct fileusage *
|
||||||
char *blockcheck __P((char *));
|
char *blockcheck __P((char *));
|
||||||
void bread __P((daddr_t, char *, long));
|
void bread __P((daddr_t, char *, long));
|
||||||
int chkquota __P((char *, char *, struct quotaname *));
|
int chkquota __P((char *, char *, struct quotaname *));
|
||||||
void err __P((const char *, ...));
|
|
||||||
void freeinodebuf __P((void));
|
void freeinodebuf __P((void));
|
||||||
struct dinode *
|
struct dinode *
|
||||||
getnextinode __P((ino_t));
|
getnextinode __P((ino_t));
|
||||||
|
@ -180,7 +180,7 @@ main(argc, argv)
|
||||||
if (aflag)
|
if (aflag)
|
||||||
exit(checkfstab(1, maxrun, needchk, chkquota));
|
exit(checkfstab(1, maxrun, needchk, chkquota));
|
||||||
if (setfsent() == 0)
|
if (setfsent() == 0)
|
||||||
err("%s: can't open", FSTAB);
|
err(1, "%s: can't open", FSTAB);
|
||||||
while ((fs = getfsent()) != NULL) {
|
while ((fs = getfsent()) != NULL) {
|
||||||
if (((argnum = oneof(fs->fs_file, argv, argc)) >= 0 ||
|
if (((argnum = oneof(fs->fs_file, argv, argc)) >= 0 ||
|
||||||
(argnum = oneof(fs->fs_spec, argv, argc)) >= 0) &&
|
(argnum = oneof(fs->fs_spec, argv, argc)) >= 0) &&
|
||||||
|
@ -218,7 +218,7 @@ needchk(fs)
|
||||||
strcmp(fs->fs_type, FSTAB_RW))
|
strcmp(fs->fs_type, FSTAB_RW))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if ((qnp = malloc(sizeof(*qnp))) == NULL)
|
if ((qnp = malloc(sizeof(*qnp))) == NULL)
|
||||||
err("%s", strerror(errno));
|
err(1, "%s", strerror(errno));
|
||||||
qnp->flags = 0;
|
qnp->flags = 0;
|
||||||
if (gflag && hasquota(fs, GRPQUOTA, &qfnp)) {
|
if (gflag && hasquota(fs, GRPQUOTA, &qfnp)) {
|
||||||
strcpy(qnp->grpqfname, qfnp);
|
strcpy(qnp->grpqfname, qfnp);
|
||||||
|
@ -261,6 +261,7 @@ chkquota(fsname, mntpt, qnp)
|
||||||
(void)printf(" quotas for %s (%s)\n", fsname, mntpt);
|
(void)printf(" quotas for %s (%s)\n", fsname, mntpt);
|
||||||
}
|
}
|
||||||
sync();
|
sync();
|
||||||
|
dev_bsize = 1;
|
||||||
bread(SBOFF, (char *)&sblock, (long)SBSIZE);
|
bread(SBOFF, (char *)&sblock, (long)SBSIZE);
|
||||||
dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
|
dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
|
||||||
maxino = sblock.fs_ncg * sblock.fs_ipg;
|
maxino = sblock.fs_ncg * sblock.fs_ipg;
|
||||||
|
@ -503,7 +504,7 @@ addid(id, type, name)
|
||||||
else
|
else
|
||||||
len = 10;
|
len = 10;
|
||||||
if ((fup = calloc(1, sizeof(*fup) + len)) == NULL)
|
if ((fup = calloc(1, sizeof(*fup) + len)) == NULL)
|
||||||
err("%s", strerror(errno));
|
err(1, "%s", strerror(errno));
|
||||||
fhp = &fuhead[type][id & (FUHASH - 1)];
|
fhp = &fuhead[type][id & (FUHASH - 1)];
|
||||||
fup->fu_next = *fhp;
|
fup->fu_next = *fhp;
|
||||||
*fhp = fup;
|
*fhp = fup;
|
||||||
|
@ -535,7 +536,7 @@ getnextinode(inumber)
|
||||||
static struct dinode *dp;
|
static struct dinode *dp;
|
||||||
|
|
||||||
if (inumber != nextino++ || inumber > maxino)
|
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) {
|
if (inumber >= lastinum) {
|
||||||
readcnt++;
|
readcnt++;
|
||||||
dblk = fsbtodb(&sblock, ino_to_fsba(&sblock, lastinum));
|
dblk = fsbtodb(&sblock, ino_to_fsba(&sblock, lastinum));
|
||||||
|
@ -575,7 +576,7 @@ resetinodebuf()
|
||||||
}
|
}
|
||||||
if (inodebuf == NULL &&
|
if (inodebuf == NULL &&
|
||||||
(inodebuf = malloc((u_int)inobufsize)) == NULL)
|
(inodebuf = malloc((u_int)inobufsize)) == NULL)
|
||||||
err("%s", strerror(errno));
|
err(1, "%s", strerror(errno));
|
||||||
while (nextino < ROOTINO)
|
while (nextino < ROOTINO)
|
||||||
getnextinode(nextino);
|
getnextinode(nextino);
|
||||||
}
|
}
|
||||||
|
@ -604,34 +605,5 @@ bread(bno, buf, cnt)
|
||||||
|
|
||||||
if (lseek(fi, (off_t)bno * dev_bsize, SEEK_SET) < 0 ||
|
if (lseek(fi, (off_t)bno * dev_bsize, SEEK_SET) < 0 ||
|
||||||
read(fi, buf, cnt) != cnt)
|
read(fi, buf, cnt) != cnt)
|
||||||
err("block %ld", bno);
|
err(1, "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 */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ static char copyright[] =
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
/*static char sccsid[] = "from: @(#)quotacheck.c 8.3 (Berkeley) 1/29/94";*/
|
/*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 */
|
#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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <err.h>
|
||||||
|
|
||||||
char *qfname = QUOTAFILENAME;
|
char *qfname = QUOTAFILENAME;
|
||||||
char *qfextension[] = INITQFNAMES;
|
char *qfextension[] = INITQFNAMES;
|
||||||
|
@ -74,7 +75,7 @@ union {
|
||||||
char dummy[MAXBSIZE];
|
char dummy[MAXBSIZE];
|
||||||
} un;
|
} un;
|
||||||
#define sblock un.sblk
|
#define sblock un.sblk
|
||||||
long dev_bsize = 1;
|
long dev_bsize;
|
||||||
long maxino;
|
long maxino;
|
||||||
|
|
||||||
struct quotaname {
|
struct quotaname {
|
||||||
|
@ -108,7 +109,6 @@ struct fileusage *
|
||||||
char *blockcheck __P((char *));
|
char *blockcheck __P((char *));
|
||||||
void bread __P((daddr_t, char *, long));
|
void bread __P((daddr_t, char *, long));
|
||||||
int chkquota __P((char *, char *, struct quotaname *));
|
int chkquota __P((char *, char *, struct quotaname *));
|
||||||
void err __P((const char *, ...));
|
|
||||||
void freeinodebuf __P((void));
|
void freeinodebuf __P((void));
|
||||||
struct dinode *
|
struct dinode *
|
||||||
getnextinode __P((ino_t));
|
getnextinode __P((ino_t));
|
||||||
|
@ -180,7 +180,7 @@ main(argc, argv)
|
||||||
if (aflag)
|
if (aflag)
|
||||||
exit(checkfstab(1, maxrun, needchk, chkquota));
|
exit(checkfstab(1, maxrun, needchk, chkquota));
|
||||||
if (setfsent() == 0)
|
if (setfsent() == 0)
|
||||||
err("%s: can't open", FSTAB);
|
err(1, "%s: can't open", FSTAB);
|
||||||
while ((fs = getfsent()) != NULL) {
|
while ((fs = getfsent()) != NULL) {
|
||||||
if (((argnum = oneof(fs->fs_file, argv, argc)) >= 0 ||
|
if (((argnum = oneof(fs->fs_file, argv, argc)) >= 0 ||
|
||||||
(argnum = oneof(fs->fs_spec, argv, argc)) >= 0) &&
|
(argnum = oneof(fs->fs_spec, argv, argc)) >= 0) &&
|
||||||
|
@ -218,7 +218,7 @@ needchk(fs)
|
||||||
strcmp(fs->fs_type, FSTAB_RW))
|
strcmp(fs->fs_type, FSTAB_RW))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if ((qnp = malloc(sizeof(*qnp))) == NULL)
|
if ((qnp = malloc(sizeof(*qnp))) == NULL)
|
||||||
err("%s", strerror(errno));
|
err(1, "%s", strerror(errno));
|
||||||
qnp->flags = 0;
|
qnp->flags = 0;
|
||||||
if (gflag && hasquota(fs, GRPQUOTA, &qfnp)) {
|
if (gflag && hasquota(fs, GRPQUOTA, &qfnp)) {
|
||||||
strcpy(qnp->grpqfname, qfnp);
|
strcpy(qnp->grpqfname, qfnp);
|
||||||
|
@ -261,6 +261,7 @@ chkquota(fsname, mntpt, qnp)
|
||||||
(void)printf(" quotas for %s (%s)\n", fsname, mntpt);
|
(void)printf(" quotas for %s (%s)\n", fsname, mntpt);
|
||||||
}
|
}
|
||||||
sync();
|
sync();
|
||||||
|
dev_bsize = 1;
|
||||||
bread(SBOFF, (char *)&sblock, (long)SBSIZE);
|
bread(SBOFF, (char *)&sblock, (long)SBSIZE);
|
||||||
dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
|
dev_bsize = sblock.fs_fsize / fsbtodb(&sblock, 1);
|
||||||
maxino = sblock.fs_ncg * sblock.fs_ipg;
|
maxino = sblock.fs_ncg * sblock.fs_ipg;
|
||||||
|
@ -503,7 +504,7 @@ addid(id, type, name)
|
||||||
else
|
else
|
||||||
len = 10;
|
len = 10;
|
||||||
if ((fup = calloc(1, sizeof(*fup) + len)) == NULL)
|
if ((fup = calloc(1, sizeof(*fup) + len)) == NULL)
|
||||||
err("%s", strerror(errno));
|
err(1, "%s", strerror(errno));
|
||||||
fhp = &fuhead[type][id & (FUHASH - 1)];
|
fhp = &fuhead[type][id & (FUHASH - 1)];
|
||||||
fup->fu_next = *fhp;
|
fup->fu_next = *fhp;
|
||||||
*fhp = fup;
|
*fhp = fup;
|
||||||
|
@ -535,7 +536,7 @@ getnextinode(inumber)
|
||||||
static struct dinode *dp;
|
static struct dinode *dp;
|
||||||
|
|
||||||
if (inumber != nextino++ || inumber > maxino)
|
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) {
|
if (inumber >= lastinum) {
|
||||||
readcnt++;
|
readcnt++;
|
||||||
dblk = fsbtodb(&sblock, ino_to_fsba(&sblock, lastinum));
|
dblk = fsbtodb(&sblock, ino_to_fsba(&sblock, lastinum));
|
||||||
|
@ -575,7 +576,7 @@ resetinodebuf()
|
||||||
}
|
}
|
||||||
if (inodebuf == NULL &&
|
if (inodebuf == NULL &&
|
||||||
(inodebuf = malloc((u_int)inobufsize)) == NULL)
|
(inodebuf = malloc((u_int)inobufsize)) == NULL)
|
||||||
err("%s", strerror(errno));
|
err(1, "%s", strerror(errno));
|
||||||
while (nextino < ROOTINO)
|
while (nextino < ROOTINO)
|
||||||
getnextinode(nextino);
|
getnextinode(nextino);
|
||||||
}
|
}
|
||||||
|
@ -604,34 +605,5 @@ bread(bno, buf, cnt)
|
||||||
|
|
||||||
if (lseek(fi, (off_t)bno * dev_bsize, SEEK_SET) < 0 ||
|
if (lseek(fi, (off_t)bno * dev_bsize, SEEK_SET) < 0 ||
|
||||||
read(fi, buf, cnt) != cnt)
|
read(fi, buf, cnt) != cnt)
|
||||||
err("block %ld", bno);
|
err(1, "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 */
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue