Page MenuHomeFreeBSD

vfs: Introduce VN_ISDEV() macro
ClosedPublic

Authored by des on Aug 17 2025, 2:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Oct 13, 1:17 AM
Unknown Object (File)
Sun, Oct 12, 10:15 AM
Unknown Object (File)
Sun, Oct 12, 10:15 AM
Unknown Object (File)
Sun, Oct 12, 10:15 AM
Unknown Object (File)
Sun, Oct 12, 10:15 AM
Unknown Object (File)
Sat, Oct 11, 11:23 PM
Unknown Object (File)
Sat, Oct 11, 11:23 PM
Unknown Object (File)
Sat, Oct 11, 11:23 PM

Details

Summary

We frequently need to check if a vnode refers to either a character or
block special, so we might as well have a macro for it.

Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 66309
Build 63192: arc lint + arc unit

Event Timeline

des requested review of this revision.Aug 17 2025, 2:17 PM
des planned changes to this revision.Aug 17 2025, 2:19 PM

looks like I missed a few occurrences, brb

sys/fs/nfsserver/nfs_nfsdport.c
1260 ↗(On Diff #160460)

I do not think this chunk could compile.

sys/sys/vnode.h
241

I suggest to add

#define VN_TYPE_ISDEV(typ) ((typ) == VCHR || (typ) == VBLK)

and then

define VN_ISDEV(_vp) VN_TYPE_ISDEV((_vp)->v_type)

This allows to convert several more cases to the VN_TYPE_ISDEV() macro.

This revision is now accepted and ready to land.Aug 17 2025, 4:17 PM
This revision now requires review to proceed.Aug 17 2025, 4:33 PM
des marked an inline comment as done.Aug 17 2025, 4:35 PM
This revision is now accepted and ready to land.Aug 17 2025, 4:36 PM
mckusick added a subscriber: mckusick.

I am always in favor of improvement to code clarity.