Document every exported type, function and method in the migration, storage and cephfsnative packages and add package comments for migration and the cephmig command, following the commentary rules of Effective Go. Comments on unexported helpers now start with the name they describe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
96 lines
2.5 KiB
Go
96 lines
2.5 KiB
Go
// Package storage defines the native filesystem operations used by the copier.
|
|
package storage
|
|
|
|
import (
|
|
"io"
|
|
"time"
|
|
)
|
|
|
|
// Node holds the inode attributes the copier needs.
|
|
type Node struct {
|
|
Mode uint32
|
|
Inode, Version, Nlink, Size, Rdev uint64
|
|
UID, GID uint32
|
|
Mtime time.Time
|
|
}
|
|
|
|
// File type bits of Node.Mode, as in stat(2).
|
|
const (
|
|
TypeMask uint32 = 0170000
|
|
Regular uint32 = 0100000
|
|
Directory uint32 = 0040000
|
|
Symlink uint32 = 0120000
|
|
FIFO uint32 = 0010000
|
|
Socket uint32 = 0140000
|
|
BlockDevice uint32 = 0060000
|
|
CharDevice uint32 = 0020000
|
|
)
|
|
|
|
// Kind returns the file type bits of n.Mode.
|
|
func (n Node) Kind() uint32 { return n.Mode & TypeMask }
|
|
|
|
// Entry is a single directory entry.
|
|
type Entry struct {
|
|
Name string
|
|
Node Node
|
|
}
|
|
|
|
// DirectoryStream iterates over a directory. Next returns io.EOF at the end.
|
|
type DirectoryStream interface {
|
|
Next() (*Entry, error)
|
|
Close() error
|
|
}
|
|
|
|
// File is an open regular file.
|
|
type File interface {
|
|
io.ReaderAt
|
|
io.WriterAt
|
|
io.Closer
|
|
Truncate(int64) error
|
|
Sync() error
|
|
Lock(uint64) error
|
|
PunchHole(int64, int64) error
|
|
}
|
|
|
|
// DiffStream yields the paths that differ between two snapshots.
|
|
type DiffStream interface {
|
|
Next() (string, error)
|
|
Close() error
|
|
}
|
|
|
|
// Extent is a changed byte range of a file.
|
|
type Extent struct{ Offset, Length uint64 }
|
|
|
|
// BlockStream yields batches of changed extents between two snapshots.
|
|
type BlockStream interface {
|
|
Next() ([]Extent, error)
|
|
Close() error
|
|
}
|
|
|
|
// FS is the filesystem interface implemented by the native libcephfs client.
|
|
type FS interface {
|
|
Stat(string) (Node, error) // Never follows the final symlink.
|
|
Open(string, int, uint32) (File, error)
|
|
OpenDir(string) (DirectoryStream, error)
|
|
Mkdir(string, uint32) error
|
|
Unlink(string) error
|
|
Rmdir(string) error
|
|
Rename(string, string) error
|
|
Link(string, string) error
|
|
Symlink(string, string) error
|
|
Readlink(string) (string, error)
|
|
Mknod(string, uint32, uint64) error
|
|
SetAttr(string, Node) error // Numeric owner, mode and mtime; no symlink following.
|
|
ListXattr(string) ([]string, error)
|
|
GetXattr(string, string) ([]byte, error)
|
|
SetXattr(string, string, []byte) error
|
|
RemoveXattr(string, string) error
|
|
SnapDiff(string, string, string, string) (DiffStream, error)
|
|
BlockDiff(string, string, string, string) (BlockStream, error)
|
|
Sync() error
|
|
Close() error
|
|
}
|
|
|
|
// Options identifies the cluster, credentials and filesystem to connect to.
|
|
type Options struct{ Config, Keyring, User, Filesystem string }
|