tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Anonymous vnodes?



Hi,

On Mon, Jun 26, 2023 at 06:13:17PM -0400, Theodore Preduta wrote:
> Is it possible to create a vnode for a regular file in a file system without
> linking the vnode to any directory, so that it disappears when all open file
> descriptors to it are closed?  (As far as I can tell, this isn't possible
> with any of the vn_* or VOP_* functions?)

That's completely normal. If a file is created in a file system and its
unlinked its effectively in this state. If you want a code reference, look at
the system file handling of the UDF file system. A system file is loaded with
udf_get_node() (sys/fs/udf/udf_subc.c) that looks up the vnode and if its not
in the cache it calls udf_loadvnode() (trough vfs_loadvnode) that loads a
newly created vnode representing a file that is not linked to any directory.
It's up to the VFS_NEWVNODE() implementation to accept a NULL dvp or not.

As long as the vnode is referred, see UDF_SET_SYSTEMFILE(), the vnode is kept
alive. If the last reference is dropped the vnode is recycled and disappears.

With regards,
Reinoud



Home | Main Index | Thread Index | Old Index