Re: RFC: checking file systems support UF_HIDDEN, UF_SYSTEM

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Thu, 03 Jul 2025 02:59:07 UTC
On Wed, Jul 02, 2025 at 04:54:18PM -0600, Alan Somers wrote:
> On Wed, Jul 2, 2025, 3:03 PM Rick Macklem <rick.macklem@gmail.com> wrote:
> 
> > Hi,
> >
> > I am implementing the "hidden" and "system" attributes for
> > NFSv4 using UF_HIDDEN and UF_SYSTEM.
> >
> > In a couple of places in the code, I need to know if a file
> > system supports these flags.
> > I can think of two ways to do this.
> > #1 - Create a new VFCF_HIDSYS flag that is set via VFS_SET()
> >        for file systems that support the UF_HIDDEN and UF_SYSTEM
> >        flags and test for that flag being set.
> > or
> > #2 - Write it this way...
> >       if (strcmp(vp->v_mount->mnt_vfc->vfc_name, "zfs") != 0 ||
> >           strcmp(vp->v_mount->mnt_vfc->vfc_name, "ufs") != 0 ||
> >           strcmp(vp->v_mount->mnt_vfc->vfc_name, "msdosfs") != 0 ||
> >           strcmp(vp->v_mount->mnt_vfc->vfc_name, "tmpfs") != 0)
> >
> > Which do you think is preferable (or do you have another idea)?
> >
> > Thanks for any comments, rick
> >
> 
> The strcmp method isn't very good, because it doesn't account for the
> possibility that some filesystems may only support the flags conditionally,
> depending on formatting options. I vote for method 1.

Method 1 is also not very good IMO.

For instance, when you add the support for the mentioned attributes to nfs,
it would perhaps be added only to nfs 4.x mounts.  This cannot be expressed
by global VFCF-like property, be it flags or vfs_name string.

I suggest adding more _PC_XXX constants and use VOP_PATHCONF() to get the
property of the specific mount point.  You might query it on the root
vnode and cache it somewhere.  Also this information would become
available to userspace due to pathconf(2).