common

package
v2.0.0-...-82e32b5 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

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

	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 * MbToBytes
	BfuseStats = "blobfuse_stats"

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

	UserAgentHeader = "User-Agent"
)

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 BlobFuse2WarningsURL = "https://aka.ms/blobfuse2warnings"
View Source
const Blobfuse2ListContainerURL = "https://blobfuse2.blob.core.windows.net/release"

Variables

View Source
var BfsDisabled = false
View Source
var Blobfuse2Version = Blobfuse2Version_()
View Source
var DefaultLogFilePath = filepath.Join(DefaultWorkDir, "blobfuse2.log")
View Source
var DefaultWorkDir = "$HOME/.blobfuse2"
View Source
var ELogLevel = LogLevel(0).INVALID()
View Source
var EnableMonitoring = false
View Source
var ForegroundMount bool
View Source
var MountPath string
View Source
var PollingPipe = "/tmp/pollPipe"
View Source
var RootMount bool
View Source
var StatsConfigFilePath = filepath.Join(DefaultWorkDir, "stats_monitor.cfg")
View Source
var TransferPipe = "/tmp/transferPipe"

Functions

func Blobfuse2Version_

func Blobfuse2Version_() string

func DecryptData

func DecryptData(cipherData []byte, key []byte) ([]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 []byte) ([]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 blobfuse2 command.

func GetDiskUsageFromStatfs

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

GetDiskUsageFromStatfs: Current disk usage of temp path

func GetFuseMinorVersion

func GetFuseMinorVersion() int

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 ListMountPoints

func ListMountPoints() ([]string, error)

List all mount points which were mounted using blobfuse2

func MonitorBfs

func MonitorBfs() 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

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

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

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 blobfuse2 or bfusemon
}

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 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