genericfstree

package
v0.0.0-...-973e103 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2024 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Overview

Package genericfstree provides tools for implementing vfs.FilesystemImpls that follow a standard pattern for synchronizing Dentry parent and name.

Clients using this package must use the go_template_instance rule in tools/go_generics/defs.bzl to create an instantiation of this template package, providing types to use in place of Filesystem and Dentry.

TODO: As of this writing, every filesystem implementation with its own dentry type uses at least part of genericfstree, suggesting that we may want to merge its functionality into vfs.Dentry. However, this will incur the cost of an extra (entirely predictable) branch per directory traversal, since Dentry.parent will need to be atomic.Pointer[vfs.Dentry] rather than a filesystem-specific dentry, requiring a type assertion to the latter.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugPathname

func DebugPathname(fs *Filesystem, d *Dentry) string

DebugPathname returns a pathname to d relative to its filesystem root. DebugPathname does not correspond to any Linux function; it's used to generate dentry pathnames for debugging.

func IsAncestorDentry

func IsAncestorDentry(fs *Filesystem, d, d2 *Dentry) bool

IsAncestorDentry returns true if d is an ancestor of d2; that is, d is either d2's parent or an ancestor of d2's parent.

func IsDescendant

func IsDescendant(fs *Filesystem, vfsroot *vfs.Dentry, d *Dentry) bool

IsDescendant returns true if vd is a descendant of vfsroot or if vd and vfsroot are the same dentry.

func PrependPath

func PrependPath(fs *Filesystem, vfsroot vfs.VirtualDentry, mnt *vfs.Mount, d *Dentry, b *fspath.Builder) error

PrependPath is a generic implementation of FilesystemImpl.PrependPath().

func SetParentAndName

func SetParentAndName(fs *Filesystem, d, newParent *Dentry, newName string)

SetParentAndName atomically replaces a Dentry's parent and name.

SetParentAndName must be used when changes to a Dentry's parent and name may race with observations of the same. If a Dentry is not visible to other goroutines (including concurrent calls to PrependPath or IsDescendant) when its parent and name are changed, it is safe to either call SetParentAndName or mutate d.parent and d.name directly.

Types

type Dentry

type Dentry struct {
	// contains filtered or unexported fields
}

Dentry is a required type parameter that is a struct with the given fields.

func ParentOrSelf

func ParentOrSelf(d *Dentry) *Dentry

ParentOrSelf returns d.parent. If d.parent is nil, ParentOrSelf returns d.

type Filesystem

type Filesystem struct {
	// contains filtered or unexported fields
}

Filesystem is a required type parameter that is a struct with the given fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL