summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2017-09-07 03:24:10 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2017-09-07 03:24:10 +0000
commit9334016033f393141355a76c6c5def775c7316d2 (patch)
treeb31a499ff67f63534fc527c05336cbd3ce7441c7 /usr.sbin
parent094646b634b62eda3a49341c46858d1a3fdc6dfa (diff)
unifdef some ancient COMPAT code that's not used. 500 byte blocks!
noticed by miod
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/quot/quot.c69
1 files changed, 1 insertions, 68 deletions
diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c
index 74c5b902775..26517892fea 100644
--- a/usr.sbin/quot/quot.c
+++ b/usr.sbin/quot/quot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: quot.c,v 1.29 2017/08/31 12:03:02 otto Exp $ */
+/* $OpenBSD: quot.c,v 1.30 2017/09/07 03:24:09 tedu Exp $ */
/*
* Copyright (C) 1991, 1994 Wolfgang Solfrank.
@@ -58,19 +58,7 @@ static long blocksize;
static char *header;
static int headerlen;
-/*
- * Original BSD quot doesn't round to number of frags/blocks,
- * doesn't account for indirection blocks and gets it totally
- * wrong if the size is a multiple of the blocksize.
- * The new code always counts the number of DEV_BSIZE byte blocks
- * instead of the number of kilobytes and converts them to
- * KByte when done (on request).
- */
-#ifdef COMPAT
-#define SIZE(n) (n)
-#else
#define SIZE(n) (howmany(((off_t)(n)) * DEV_BSIZE, blocksize))
-#endif
#define INOCNT(fs) ((fs)->fs_ipg)
#define INOSZ(fs) (((fs)->fs_magic == FS_UFS1_MAGIC ? \
@@ -140,11 +128,7 @@ get_inode(int fd, struct fs *super, ino_t ino)
return ((union dinode *)di2);
}
-#ifdef COMPAT
-#define actualblocks(fs, ip) (DIP(fs, dp, di_blocks) / 2)
-#else
#define actualblocks(fs, ip) DIP(fs, dp, di_blocks)
-#endif
static int
virtualblocks(struct fs *super, union dinode *dp)
@@ -152,15 +136,6 @@ virtualblocks(struct fs *super, union dinode *dp)
off_t nblk, sz;
sz = DIP(super, dp, di_size);
-#ifdef COMPAT
- if (lblkno(super, sz) >= NDADDR) {
- nblk = blkroundup(super, sz);
- if (sz == nblk)
- nblk += super->fs_bsize;
- }
-
- return sz / 1024;
-#else /* COMPAT */
if (lblkno(super, sz) >= NDADDR) {
nblk = blkroundup(super, sz);
@@ -175,15 +150,11 @@ virtualblocks(struct fs *super, union dinode *dp)
nblk = fragroundup(super, sz);
return nblk / DEV_BSIZE;
-#endif /* COMPAT */
}
static int
isfree(struct fs *super, union dinode *dp)
{
-#ifdef COMPAT
- return (DIP(super, dp, di_mode) & IFMT) == 0;
-#else /* COMPAT */
switch (DIP(super, dp, di_mode) & IFMT) {
case IFIFO:
case IFLNK: /* should check FASTSYMLINK? */
@@ -198,7 +169,6 @@ isfree(struct fs *super, union dinode *dp)
default:
errx(1, "unknown IFMT 0%o", DIP(super, dp, di_mode) & IFMT);
}
-#endif
}
static struct user {
@@ -316,11 +286,7 @@ uses(uid_t uid, daddr_t blks, time_t act)
usr->spc30 += blks;
}
-#ifdef COMPAT
-#define FSZCNT 500
-#else
#define FSZCNT 512
-#endif
struct fsizes {
struct fsizes *fsz_next;
daddr_t fsz_first, fsz_last;
@@ -352,31 +318,13 @@ dofsizes(int fd, struct fs *super, char *name)
int i;
maxino = super->fs_ncg * super->fs_ipg - 1;
-#ifdef COMPAT
- if (!(fsizes = malloc(sizeof(struct fsizes))))
- err(1, "alloc fsize structure");
-#endif /* COMPAT */
for (inode = 0; inode < maxino; inode++) {
errno = 0;
if ((dp = get_inode(fd, super, inode))
-#ifdef COMPAT
- && ((DIP(super, dp, di_mode) & IFMT) == IFREG
- || (DIP(super, dp, di_mode) & IFMT) == IFDIR)
-#else /* COMPAT */
&& !isfree(super, dp)
-#endif /* COMPAT */
) {
sz = estimate ? virtualblocks(super, dp) :
actualblocks(super, dp);
-#ifdef COMPAT
- if (sz >= FSZCNT) {
- fsizes->fsz_count[FSZCNT-1]++;
- fsizes->fsz_sz[FSZCNT-1] += sz;
- } else {
- fsizes->fsz_count[sz]++;
- fsizes->fsz_sz[sz] += sz;
- }
-#else /* COMPAT */
ksz = SIZE(sz);
for (fsp = &fsizes; (fp = *fsp); fsp = &fp->fsz_next) {
if (ksz < fp->fsz_last)
@@ -398,7 +346,6 @@ dofsizes(int fd, struct fs *super, char *name)
}
fp->fsz_count[ksz % FSZCNT]++;
fp->fsz_sz[ksz % FSZCNT] += sz;
-#endif /* COMPAT */
} else if (errno)
err(1, "%s", name);
}
@@ -470,16 +417,10 @@ donames(int fd, struct fs *super, char *name)
inode1 = -1;
while (scanf("%llu", &inode) == 1) {
if (inode > maxino) {
-#ifndef COMPAT
fprintf(stderr, "invalid inode %llu\n",
(unsigned long long)inode);
-#endif
return;
}
-#ifdef COMPAT
- if (inode < inode1)
- continue;
-#endif
errno = 0;
if ((dp = get_inode(fd, super, inode)) && !isfree(super, dp)) {
printf("%s\t", user(DIP(super, dp, di_uid))->name);
@@ -507,11 +448,7 @@ donames(int fd, struct fs *super, char *name)
static void
usage(void)
{
-#ifdef COMPAT
- fprintf(stderr, "usage: quot [-nfcvha] [filesystem ...]\n");
-#else /* COMPAT */
fprintf(stderr, "usage: quot [-acfhknv] [filesystem ...]\n");
-#endif /* COMPAT */
exit(1);
}
@@ -605,9 +542,7 @@ main(int argc, char *argv[])
all = 0;
func = douser;
-#ifndef COMPAT
header = getbsize(&headerlen, &blocksize);
-#endif
while (--argc > 0 && **++argv == '-') {
while (*++*argv) {
switch (**argv) {
@@ -626,11 +561,9 @@ main(int argc, char *argv[])
case 'h':
estimate = 1;
break;
-#ifndef COMPAT
case 'k':
blocksize = 1024;
break;
-#endif /* COMPAT */
case 'v':
unused = 1;
break;