Page MenuHomeFreeBSD

quot: Clean up
ClosedPublic

Authored by des on Oct 16 2025, 10:32 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 21, 3:36 AM
Unknown Object (File)
Mon, Nov 3, 12:00 AM
Unknown Object (File)
Sun, Oct 26, 10:39 AM
Unknown Object (File)
Sun, Oct 26, 10:39 AM
Unknown Object (File)
Sun, Oct 26, 10:39 AM
Unknown Object (File)
Sun, Oct 26, 10:37 AM
Unknown Object (File)
Oct 24 2025, 2:08 PM
Unknown Object (File)
Oct 18 2025, 1:59 PM

Details

Summary
  • Fix numerous style violations.
  • Modernize somewhat.
  • Don't bother examining errno after calling get_inode(), as it always exits on error.
  • Fix confusing wording in the manual page.

The code remains somewhat idiosyncratic, e.g. in its insistance on
counting down rather than up in simple for loops, but in the absence
of comprehensive automated tests, the risk of introducing bugs exceeds
the benefit of rewriting these into more idiomatic forms.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Oct 16 2025, 10:32 AM
emaste added inline comments.
usr.sbin/quot/quot.c
262

I don't understand this change. (The existing code is indeed quite unidiomatic.)

obiwac added a subscriber: obiwac.
obiwac added inline comments.
usr.sbin/quot/quot.8
58–60

maybe the note about this option being discouraged should be preserved?

usr.sbin/quot/quot.c
56–60

all seems only to be used in main(). unless it is style to put all flags up here

112

?

261–262

when can this condition happen?

This revision is now accepted and ready to land.Oct 16 2025, 9:21 PM
des marked 2 inline comments as done.Oct 16 2025, 9:52 PM
des added inline comments.
usr.sbin/quot/quot.c
112

Why?

261–262

Standard open hashing, but counting down instead of up. We want to store our user in slot uid % nusers (which was unwisely microoptimized to uid & (nusers - 1), which only works if nusers is a power of two); if that is taken we decrement and try again until we hit a free slot (we already know that there must be at least one free slot because we are rehashing into a new table twice the size of the old one). If usrn <= users it means we ran off the bottom of our table, so we add the size of the table to roll back around to the top. Although the condition is <=, in practice only == can happen (because we only decrement by one and check before decrementing), so my version is equivalent to the original version, but (in my opinion) more easily recognizable as correct.

The logic in user() below is the same, except that we don't know for sure that there is a free slot in the table.

des marked an inline comment as done.Oct 16 2025, 9:57 PM
des added inline comments.
usr.sbin/quot/quot.8
58–60

Let's not overthink it, it gets dropped in D53132.

des marked 2 inline comments as done.Oct 16 2025, 9:58 PM
des added inline comments.
usr.sbin/quot/quot.c
56–60

Yes, I prefer to group all the options together, even if one of them is only used in main().

des marked an inline comment as done.Oct 16 2025, 9:58 PM
usr.sbin/quot/quot.c
112

ino_to_cg takes an inode number (64 bit) and divides it by inodes per group, so the resulting may not necessarily fit in 32 bits. Don't know if that's an issue here, not very familiar with this code :)

des marked 2 inline comments as done.Oct 17 2025, 10:45 AM
des added inline comments.
usr.sbin/quot/quot.c
112

ino_t is 64 bits because FreeBSD supports 64-bit filesystems, but UFS is not one of them. UFS2 uses 64-bit block pointers to support larger disks (UFS1 tops out at 4 TB), but cylinder group and inode numbers are still limited to 32 bits. See sys/ufs/ffs/fs.h or section 9.2 of D&I for details. The original code used int here, and I changed it to unsigned long because a) the compiler (not unreasonably) complains if it's signed and b) long gives us 64 bits on 64-bit platforms without adding cost on 32-bit platforms; but I could have safely used uint32_t.

des marked an inline comment as done.Oct 17 2025, 10:46 AM
This revision was automatically updated to reflect the committed changes.