common

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxLogFileSize = 512
	DefaultLogFileCount   = 10
	FileSystemName        = "cloudfuse"

	DefaultConfigFilePath = "config.yaml"

	MaxConcurrency     = 40
	DefaultConcurrency = 20

	MaxDirListCount                             = 5000
	DefaultFilePermissionBits       os.FileMode = 0755
	DefaultDirectoryPermissionBits  os.FileMode = 0775
	DefaultAllowOtherPermissionBits os.FileMode = 0777

	MbToBytes         = 1024 * 1024
	GbToBytes         = 1024 * 1024 * 1024
	TbToBytes         = 1024 * 1024 * 1024 * 1024
	DefaultCapacityMb = TbToBytes / MbToBytes
	CfuseStats        = "cloudfuse_stats"

	FuseAllowedFlags = "" /* 229-byte string literal not displayed */

	UserAgentHeader = "User-Agent"

	BlockCacheRWErrMsg = "" /* 302-byte string literal not displayed */
)

Standard config default values

View Source
const (
	BlockFlagUnknown uint16 = iota
	DirtyBlock
	TruncatedBlock
	RemovedBlocks
)

Flags for blocks

View Source
const (
	BolFlagUnknown uint16 = iota
	SmallFile
)

Flags for block offset list

View Source
const CloudfuseReleaseURL = "https://api.github.com/repos/Seagate/cloudfuse/releases"
View Source
const SectorSize = 4096

Sector size of disk

Variables

View Source
var CfsDisabled = false
View Source
var CloudfuseVersion = CloudfuseVersion_()
View Source
var CommitDate = "undated"
View Source
var DefaultLogFilePath string
View Source
var DefaultWorkDir string
View Source
var ELogLevel = LogLevel(0).INVALID()
View Source
var EnableMonitoring = false
View Source
var ForegroundMount bool
View Source
var GitCommit = "**local_build**"
View Source
var GoVersion = runtime.Version()
View Source
var MountPath string
View Source
var OsArch = fmt.Sprintf("%s %s", runtime.GOOS, runtime.GOARCH)
View Source
var PollingPipe = "/tmp/pollPipe"
View Source
var RootMount bool
View Source
var StatsConfigFilePath string
View Source
var TransferPipe = "/tmp/transferPipe"

Functions

func CloudfuseVersion_

func CloudfuseVersion_() string

func DecryptData

func DecryptData(cipherData []byte, key string) ([]byte, error)

Decrypt given data using the key provided

func DirectoryExists

func DirectoryExists(path string) bool

DirectoryExists is a utility function that returns true if the directory at that path exists and returns false if it does not exist.

func EncryptData

func EncryptData(plainData []byte, key string) ([]byte, error)

Encrypt given data using the key provided

func ExpandPath

func ExpandPath(path string) string

convert ~ to $HOME in path

func FuseIgnoredFlags

func FuseIgnoredFlags() []string

func GetCurrentDistro

func GetCurrentDistro() string

func GetCurrentUser

func GetCurrentUser() (uint32, uint32, error)

GetCurrentUser is a utility function that returns the UID and GID of the user that invokes the cloudfuse command.

func GetDefaultWorkDir added in v1.1.0

func GetDefaultWorkDir() string

func GetDiskUsageFromStatfs

func GetDiskUsageFromStatfs(path string) (float64, float64, error)

GetDiskUsageFromStatfs: Current disk usage of temp path

func GetIdLength

func GetIdLength(id string) int64

func GetUsage

func GetUsage(path string) (float64, error)

GetUsage: The current disk usage in MB

func IsDirectoryEmpty

func IsDirectoryEmpty(path string) bool

IsDirectoryEmpty is a utility function that returns true if the directory at that path is empty or not

func IsDirectoryMounted

func IsDirectoryMounted(path string) bool

IsDirectoryMounted is a utility function that returns true if the directory is already mounted using fuse

func IsDriveLetter

func IsDriveLetter(path string) bool

IsDriveLetter returns true if the path is a drive letter on Windows, such as 'D:' or 'f:'. Returns false otherwise.

func IsMountActive added in v1.6.0

func IsMountActive(path string) (bool, error)

func JoinUnixFilepath

func JoinUnixFilepath(elem ...string) string

JoinUnixFilepath uses filepath.join to join a path and ensures that path only uses unix path delimiters.

func ListMountPoints

func ListMountPoints() ([]string, error)

List all mount points which were mounted using cloudfuse

func MonitorCfs

func MonitorCfs() bool

check if health monitor is enabled and blofuse stats monitor is not disabled

func NewUUID

func NewUUID() (u uuid)

NewUUID returns a new uuid using RFC 4122 algorithm.

func NewUUIDWithLength

func NewUUIDWithLength(length int64) []byte

NewUUIDWithLength returns a new uuid using RFC 4122 algorithm with the given length.

func NormalizeObjectName

func NormalizeObjectName(name string) string

normalizeObjectName : If file contains \\ in name replace it with ..

func NotifyMountToParent

func NotifyMountToParent() error

NotifyMountToParent : Send a signal to parent process about successful mount

func Open

func Open(name string) (*os.File, error)

Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

func OpenFile

func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)

OpenFile on linux passes the call to the os. This file is needed so we can easily compile the code on both windows and linux.

func TempCacheCleanup added in v1.6.0

func TempCacheCleanup(path string) error

Types

type BitMap16

type BitMap16 uint16

func (*BitMap16) Clear

func (bm *BitMap16) Clear(bit uint16)

Clear : Clear the given bit from bitmap

func (BitMap16) IsSet

func (bm BitMap16) IsSet(bit uint16) bool

IsSet : Check whether the given bit is set or not

func (*BitMap16) Reset added in v1.1.0

func (bm *BitMap16) Reset()

Reset : Reset the whole bitmap by setting it to 0

func (*BitMap16) Set

func (bm *BitMap16) Set(bit uint16)

Set : Set the given bit in bitmap

type Block

type Block struct {
	sync.RWMutex
	StartIndex int64
	EndIndex   int64
	Flags      BitMap16
	Id         string
	Data       []byte
}

func (*Block) Dirty

func (block *Block) Dirty() bool

Dirty : Handle is dirty or not

func (*Block) Removed added in v0.3.0

func (block *Block) Removed() bool

func (*Block) Truncated

func (block *Block) Truncated() bool

Truncated : block created on a truncate operation

type BlockOffsetList

type BlockOffsetList struct {
	BlockList     []*Block //blockId to offset mapping
	Flags         BitMap16
	BlockIdLength int64
	Size          int64
	Mtime         time.Time
}

list that holds blocks containing ids and corresponding offsets

func (BlockOffsetList) BinarySearch

func (bol BlockOffsetList) BinarySearch(offset int64) (bool, int)

return true if item found and index of the item

func (BlockOffsetList) FindBlocks

func (bol BlockOffsetList) FindBlocks(offset, length int64) ([]*Block, bool)

returns index of first mod block, size of mod data, does the new data exceed current size?, is it append only?

func (BlockOffsetList) FindBlocksToModify

func (bol BlockOffsetList) FindBlocksToModify(offset, length int64) (int, int64, bool, bool)

returns index of first mod block, size of mod data, does the new data exceed current size?, is it append only?

func (*BlockOffsetList) SmallFile

func (bol *BlockOffsetList) SmallFile() bool

Dirty : Handle is dirty or not

type KeyedMutex

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

func (*KeyedMutex) GetLock

func (m *KeyedMutex) GetLock(key string) *sync.Mutex

type LockMap

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

Map holding locks for all the files

func NewLockMap

func NewLockMap() *LockMap

func (*LockMap) Delete

func (l *LockMap) Delete(name string)

Delete item from file lock map

func (*LockMap) Get

func (l *LockMap) Get(name string) *LockMapItem

Get the lock item based on file name, if item does not exists create it

func (*LockMap) Locked

func (l *LockMap) Locked(name string) bool

Check if this file is already exLocked or not

type LockMapItem

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

Lock item for each file

func (*LockMapItem) Count

func (l *LockMapItem) Count() uint32

Get the current handle count

func (*LockMapItem) Dec

func (l *LockMapItem) Dec()

Decrement the handle count

func (*LockMapItem) DownloadTime

func (l *LockMapItem) DownloadTime() time.Time

Get the download time of the file

func (*LockMapItem) Inc

func (l *LockMapItem) Inc()

Increment the handle count

func (*LockMapItem) Lock

func (l *LockMapItem) Lock()

Lock Item level operation Lock this file exclusively

func (*LockMapItem) SetDownloadTime

func (l *LockMapItem) SetDownloadTime()

Set the download time of the file

func (*LockMapItem) Unlock

func (l *LockMapItem) Unlock()

UnLock this file exclusively

type LogConfig

type LogConfig struct {
	Level       LogLevel
	MaxFileSize uint64
	FileCount   uint64
	FilePath    string
	TimeTracker bool
	Tag         string // logging tag which can be either cloudfuse or cfusemon
}

type LogLevel

type LogLevel int

LogLevel enum

func (LogLevel) INVALID

func (LogLevel) INVALID() LogLevel

func (LogLevel) LOG_CRIT

func (LogLevel) LOG_CRIT() LogLevel

func (LogLevel) LOG_DEBUG

func (LogLevel) LOG_DEBUG() LogLevel

func (LogLevel) LOG_ERR

func (LogLevel) LOG_ERR() LogLevel

func (LogLevel) LOG_INFO

func (LogLevel) LOG_INFO() LogLevel

func (LogLevel) LOG_OFF

func (LogLevel) LOG_OFF() LogLevel

func (LogLevel) LOG_TRACE

func (LogLevel) LOG_TRACE() LogLevel

func (LogLevel) LOG_WARNING

func (LogLevel) LOG_WARNING() LogLevel

func (*LogLevel) Parse

func (l *LogLevel) Parse(s string) error

func (LogLevel) String

func (l LogLevel) String() string

type Statfs_t

type Statfs_t struct {
	Bsize   int64
	Blocks  uint64
	Bfree   uint64
	Bavail  uint64
	Files   uint64
	Ffree   uint64
	Frsize  int64
	Flags   int64
	Namemax uint64
}

Statfs type used by component in replace of syscall.Statfs_t as defined by cgofuse https://pkg.go.dev/github.com/winfsp/cgofuse/fuse#Statfs_t

type Version

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

func ParseVersion

func ParseVersion(raw string) (*Version, error)

To keep the code simple, we assume we only use a simple subset of semantic versions. Namely, the version is either a normal stable version, or a pre-release version with '~preview' or '-preview' attached. Examples: 10.1.0, 11.2.0-preview.1, 11.2.0~preview.1

func (Version) NewerThan

func (v Version) NewerThan(v2 Version) bool

detect if version v is newer than v2

func (Version) OlderThan

func (v Version) OlderThan(v2 Version) bool

detect if version v is older than v2

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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