Documentation ¶
Index ¶
- func EqualXAttrs(pathname1, pathname2 string) (bool, error)
- func MaxNlinkVal(pathname string) uint64
- func ReadChunk(f *os.File, buf []byte) (n int, err error)
- type DevStatInfo
- type Digest
- type FilenamePaths
- func (f *FilenamePaths) Add(ps P.Pathsplit)
- func (f *FilenamePaths) Any() P.Pathsplit
- func (f *FilenamePaths) AnyWithFilename(filename string) P.Pathsplit
- func (f *FilenamePaths) CountPaths() int
- func (f *FilenamePaths) HasFilename(filename string) bool
- func (f *FilenamePaths) HasPath(ps P.Pathsplit) bool
- func (f *FilenamePaths) IsEmpty() bool
- func (f *FilenamePaths) PathsAsSlice() []P.Pathsplit
- func (f *FilenamePaths) Remove(ps P.Pathsplit)
- type Hash
- type Ino
- type InoDigests
- type InoHashes
- type InoStatInfo
- type LinkableInoSets
- type PathInfo
- type PathsMap
- func (pm PathsMap) AllPaths(ino Ino) <-chan P.Pathsplit
- func (pm PathsMap) AppendPath(ino Ino, path P.Pathsplit)
- func (pm PathsMap) ArbitraryFilenamePath(ino Ino, filename string) P.Pathsplit
- func (pm PathsMap) ArbitraryPath(ino Ino) P.Pathsplit
- func (pm PathsMap) HasPath(ino Ino, path P.Pathsplit) bool
- func (pm PathsMap) MovePath(dstPath P.Pathsplit, srcIno Ino, dstIno Ino)
- func (pm PathsMap) PathCount() (paths int64, dirs int64)
- type Set
- type StatInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualXAttrs ¶
func MaxNlinkVal ¶
MaxNlinkVal returns the maximum number of supported NLinks to pathname. Since the syscall interface to Pathconf isn't supported on all unixes (such as Linux, for some reason), we instead call out to the getconf program, which should always be available as a basic command on both BSDs and Linux, to obtain the value. Since this only needs to be done once per device (ie. once per Stat_t.Dev), it isn't a performance concern.
Types ¶
type DevStatInfo ¶
We need the Dev value returned from stat, but it can be discarded when we separate the Info into a map indexed by the Dev value
func LStatInfo ¶
func LStatInfo(pathname string) (DevStatInfo, error)
type Digest ¶
type Digest uint32
func ContentDigest ¶
ContentDigest returns a short digest of the first part of the given pathname, to help determine if two files are definitely not equivalent, without doing a full comparison. Typically this will be used when a full file comparison will be performed anyway (incurring the IO overhead), and saving the digest to help quickly reduce the set of possibly equal inodes later (ie. reducing the length of the repeated linear searches).
type FilenamePaths ¶
type FilenamePaths struct { FPMap map[string]pathsplitSet // key = filename // contains filtered or unexported fields }
FilenamePaths holds a map of filenames to their full pathnames (ie. the different paths to an inode), and also holds an arbitrary pathname that can be used for consistency (rather than a fully random one from the map)
func (*FilenamePaths) Add ¶
func (f *FilenamePaths) Add(ps P.Pathsplit)
func (*FilenamePaths) Any ¶
func (f *FilenamePaths) Any() P.Pathsplit
When choosing an arbitrary pathname, remember what was chosen and return it consistently. This prevents the source link paths from changing unnecessarily, and basically makes the output a bit more friendly.
func (*FilenamePaths) AnyWithFilename ¶
func (f *FilenamePaths) AnyWithFilename(filename string) P.Pathsplit
AnyWithFilename will return an arbitrary path with the given filename
func (*FilenamePaths) CountPaths ¶
func (f *FilenamePaths) CountPaths() int
CountPaths returns the number of stored paths
func (*FilenamePaths) HasFilename ¶
func (f *FilenamePaths) HasFilename(filename string) bool
func (*FilenamePaths) IsEmpty ¶
func (f *FilenamePaths) IsEmpty() bool
func (*FilenamePaths) PathsAsSlice ¶
func (f *FilenamePaths) PathsAsSlice() []P.Pathsplit
PathsAsSlice returns a slice of all the stored paths
func (*FilenamePaths) Remove ¶
func (f *FilenamePaths) Remove(ps P.Pathsplit)
type Hash ¶
type Hash uint64
type InoDigests ¶
func NewInoDigests ¶
func NewInoDigests() InoDigests
func (*InoDigests) Add ¶
func (id *InoDigests) Add(pi PathInfo, digest Digest)
func (*InoDigests) GetInos ¶
func (id *InoDigests) GetInos(d Digest) Set
type InoStatInfo ¶
type LinkableInoSets ¶
func (LinkableInoSets) Add ¶
func (l LinkableInoSets) Add(ino1, ino2 Ino)
Add places both ino1 and ino2 into the LinkableInoSets map.
Potentially races with All(), but typically all the data is collected and added with AddLinkableInos() before calling All() (so we don't bother with locking).
func (LinkableInoSets) All ¶
func (l LinkableInoSets) All() <-chan Set
All sends all the linkable InoSets over the returned channel. The InoSets are ordered, by starting with the lowest inode and progressing through the highest (rather than returning InoSets in random order).
This method races with the Add() method, but since it is called after all the Add()s have completed (ie. the path/inode information gathering phase has completed, and moved to the link generation phase), no locking of LinkableInoSets is required.
func (LinkableInoSets) Containing ¶
func (l LinkableInoSets) Containing(ino Ino) Set
Containing calls linkableInoSetHelper to return a single set of linkable inodes containing the given 'ino'. Linkable inodes are those determined by the algorithm to have been able to be hardlinked together (ie. have identical contents, and compatible inode parameters)
type PathInfo ¶
func (PathInfo) EqualOwnership ¶
type PathsMap ¶
type PathsMap map[Ino]*FilenamePaths
func (PathsMap) AllPaths ¶
AllPaths returns a channel that can be iterated over to sequentially access all the paths for a given inode.
func (PathsMap) ArbitraryFilenamePath ¶
func (PathsMap) MovePath ¶
MovePath moves the given destination path, from the given destination inode, to the source inode.
func (PathsMap) PathCount ¶
PathCount returns the number of unique paths and dirs encountered after the initial walk is completed. This can give us an accurate count of the number of inode nlinks we should encounter if all linked paths are included in the walk. Conversely, if we count the nlinks from all the encountered inodes, and compare to the number of paths this function returns, we should have a count of how many inode paths were not seen by the walk.
type Set ¶
type Set map[Ino]struct{}
func SetIntersections ¶
Return an intersection of multiple Sets
func (Set) Difference ¶
Return a difference of the other Set from the receiver
func (Set) Intersection ¶
Return an intersection of the receiver with a Set