The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=8209311c51d34c81edec8d09778201cb6e67c6a5
commit 8209311c51d34c81edec8d09778201cb6e67c6a5 Author: Dag-Erling Smørgrav <[email protected]> AuthorDate: 2025-10-17 11:55:07 +0000 Commit: Dag-Erling Smørgrav <[email protected]> CommitDate: 2025-10-17 11:55:07 +0000 quot: Drop the -h option There was probably a time, more than 30 years ago, when the actual size of a file had to be calculated and this option saved time, but all it does today is give incorrect results for no benefit. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D53132 --- usr.sbin/quot/quot.8 | 6 +----- usr.sbin/quot/quot.c | 36 ++++-------------------------------- 2 files changed, 5 insertions(+), 37 deletions(-) diff --git a/usr.sbin/quot/quot.8 b/usr.sbin/quot/quot.8 index 8da0625b246c..32e666e2a863 100644 --- a/usr.sbin/quot/quot.8 +++ b/usr.sbin/quot/quot.8 @@ -35,7 +35,7 @@ .Nd display disk space occupied by each user .Sh SYNOPSIS .Nm -.Op Fl cfhknv +.Op Fl cfknv .Op Fl a | Ar filesystem ... .Sh DESCRIPTION The @@ -53,10 +53,6 @@ number of files in this category, and aggregate total of blocks in files with this or lower size. .It Fl f For each user, display count of files and space occupied. -.It Fl h -Estimate the number of blocks in each file based on its size. -Note that this does not account for sparse files and is no faster than -reporting the accurate block count. .It Fl k Force the numbers to be reported in kilobyte counts. By default, all sizes are reported in 512-byte block counts. diff --git a/usr.sbin/quot/quot.c b/usr.sbin/quot/quot.c index ad9f65c94877..323648d8d550 100644 --- a/usr.sbin/quot/quot.c +++ b/usr.sbin/quot/quot.c @@ -55,7 +55,6 @@ /* some flags of what to do: */ static bool all; static bool count; -static bool estimate; static bool unused; static void (*func)(int, struct fs *); static long blocksize; @@ -63,7 +62,6 @@ static char *header; static int headerlen; static union dinode *get_inode(int, struct fs *, ino_t); -static int virtualblocks(struct fs *, union dinode *); static int isfree(struct fs *, union dinode *); static void inituser(void); static void usrrehash(void); @@ -149,33 +147,9 @@ get_inode(int fd, struct fs *super, ino_t ino) return ((union dinode *)di2); } -#define actualblocks(fs, dp) DIP(fs, dp, di_blocks) - -static int virtualblocks(struct fs *super, union dinode *dp) -{ - off_t nblk, sz; - - sz = DIP(super, dp, di_size); - - if (lblkno(super, sz) >= UFS_NDADDR) { - nblk = blkroundup(super, sz); - sz = lblkno(super, nblk); - sz = (sz - UFS_NDADDR + NINDIR(super) - 1) / NINDIR(super); - while (sz > 0) { - nblk += sz * super->fs_bsize; - /* sz - 1 rounded up */ - sz = (sz - 1 + NINDIR(super) - 1) / NINDIR(super); - } - } else - nblk = fragroundup(super, sz); - - return nblk / 512; -} - static int isfree(struct fs *super, union dinode *dp) { - switch (DIP(super, dp, di_mode) & IFMT) { case IFIFO: case IFLNK: /* should check FASTSYMLINK? */ @@ -337,8 +311,7 @@ dofsizes(int fd, struct fs *super) if ((dp = get_inode(fd, super, inode)) != NULL && !isfree(super, dp) ) { - sz = estimate ? virtualblocks(super, dp) : - actualblocks(super, dp); + sz = DIP(super, dp, di_blocks); ksz = SIZE(sz); for (fsp = &fsizes; (fp = *fsp); fsp = &fp->fsz_next) { if (ksz < fp->fsz_last) @@ -386,8 +359,7 @@ douser(int fd, struct fs *super) if ((dp = get_inode(fd, super, inode)) != NULL && !isfree(super, dp)) { uses(DIP(super, dp, di_uid), - estimate ? virtualblocks(super, dp) : - actualblocks(super, dp), + DIP(super, dp, di_blocks), DIP(super, dp, di_atime)); } } @@ -454,7 +426,7 @@ donames(int fd, struct fs *super) static void usage(void) { - fprintf(stderr, "usage: quot [-cfhknv] [-a | filesystem ...]\n"); + fprintf(stderr, "usage: quot [-cfknv] [-a | filesystem ...]\n"); exit(1); } @@ -514,7 +486,7 @@ main(int argc, char *argv[]) count = true; break; case 'h': - estimate = true; + /* ignored for backward compatibility */ break; case 'k': blocksize = 1024;
