Initial import of the existing CephFS subvolume migration prototype, including the native libcephfs transport, rsync backend, local Ceph lab environment and integration tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
1.9 KiB
Go
80 lines
1.9 KiB
Go
// Package storage defines the native filesystem operations used by the copier.
|
|
package storage
|
|
|
|
import (
|
|
"io"
|
|
"time"
|
|
)
|
|
|
|
type Node struct {
|
|
Mode uint32
|
|
Inode, Version, Nlink, Size, Rdev uint64
|
|
UID, GID uint32
|
|
Mtime time.Time
|
|
}
|
|
|
|
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
|
|
)
|
|
|
|
func (n Node) Kind() uint32 { return n.Mode & TypeMask }
|
|
|
|
type Entry struct {
|
|
Name string
|
|
Node Node
|
|
}
|
|
type DirectoryStream interface {
|
|
Next() (*Entry, error)
|
|
Close() error
|
|
}
|
|
type File interface {
|
|
io.ReaderAt
|
|
io.WriterAt
|
|
io.Closer
|
|
Truncate(int64) error
|
|
Sync() error
|
|
Lock(uint64) error
|
|
PunchHole(int64, int64) error
|
|
}
|
|
type DiffStream interface {
|
|
Next() (string, error)
|
|
Close() error
|
|
}
|
|
type Extent struct{ Offset, Length uint64 }
|
|
type BlockStream interface {
|
|
Next() ([]Extent, error)
|
|
Close() error
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
type Options struct{ Config, Keyring, User, Filesystem string }
|