libfs

package
v0.0.0-...-fb60582 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2017 License: BSD-3-Clause Imports: 17 Imported by: 0

README

Common library code useful to any file system presentation layer for KBFS.

(TODO: Fill in more details.)

Documentation

Index

Constants

View Source
const (
	// InitErrorCode is the error code for initialization errors
	InitErrorCode = 1
	// MountErrorCode is the error code for mount errors
	MountErrorCode = 2
)
View Source
const (
	HumanErrorFileName   = "kbfs.error.txt"
	HumanNoLoginFileName = "kbfs.nologin.txt"
)

Special files in root directory.

View Source
const DisableAutoJournalsFileName = ".kbfs_disable_auto_journals"

DisableAutoJournalsFileName is the name of the KBFS-wide auto-journal-disabling file. It's accessible anywhere outside a TLF.

View Source
const DisableBlockPrefetchingFileName = ".kbfs_disable_block_prefetching"

DisableBlockPrefetchingFileName is the name of the KBFS-wide prefetching-disabling file. It's accessible anywhere outside a TLF.

View Source
const DisableJournalFileName = ".kbfs_disable_journal"

DisableJournalFileName is the name of the journal-disabling file. It can be reached anywhere within a top-level folder.

View Source
const DisableUpdatesFileName = ".kbfs_disable_updates"

DisableUpdatesFileName is the name of the KBFS update-disabling file -- it can be reached anywhere within a top-level folder.

View Source
const EditHistoryName = ".kbfs_edit_history"

EditHistoryName is the name of the KBFS TLF edit history file -- it can be reached anywhere within a top-level folder.

View Source
const EnableAutoJournalsFileName = ".kbfs_enable_auto_journals"

EnableAutoJournalsFileName is the name of the KBFS-wide auto-journal-enabling file. It's accessible anywhere outside a TLF.

View Source
const EnableBlockPrefetchingFileName = ".kbfs_enable_block_prefetching"

EnableBlockPrefetchingFileName is the name of the KBFS-wide prefetching-enabling file. It's accessible anywhere outside a TLF.

View Source
const EnableJournalFileName = ".kbfs_enable_journal"

EnableJournalFileName is the name of the journal-enabling file. It can be reached anywhere within a top-level folder.

View Source
const EnableUpdatesFileName = ".kbfs_enable_updates"

EnableUpdatesFileName is the name of the KBFS update-enabling file -- it can be reached anywhere within a top-level folder.

View Source
const FileInfoPrefix = ".kbfs_fileinfo_"

FileInfoPrefix is the prefix of the per-file metadata files.

View Source
const FlushJournalFileName = ".kbfs_flush_journal"

FlushJournalFileName is the name of the journal-flushing file. It can be reached anywhere within a top-level folder.

View Source
const MetricsFileName = ".kbfs_metrics"

MetricsFileName is the name of the KBFS metrics file -- it can be reached from any KBFS directory.

View Source
const PauseJournalBackgroundWorkFileName = ".kbfs_pause_journal_background_work"

PauseJournalBackgroundWorkFileName is the name of the file that pauses the background work of a journal. It can be reached anywhere within a top-level folder.

View Source
const ProfileListDirName = ".kbfs_profiles"

ProfileListDirName is the name of the KBFS profile directory -- it can be reached from any KBFS directory.

View Source
const ReclaimQuotaFileName = ".kbfs_reclaim_quota"

ReclaimQuotaFileName is the name of the KBFS quota-reclaiming file -- it can be reached anywhere within a top-level folder.

View Source
const RekeyFileName = ".kbfs_rekey"

RekeyFileName is the name of the KBFS rekeying file -- it can be reached anywhere within a top-level folder.

View Source
const ResetCachesFileName = ".kbfs_reset_caches"

ResetCachesFileName is the name of the KBFS unstaging file.

View Source
const ResumeJournalBackgroundWorkFileName = ".kbfs_resume_journal_background_work"

ResumeJournalBackgroundWorkFileName is the name of the file that resumes the background work of a journal. It can be reached anywhere within a top-level folder.

View Source
const StatusFileName = ".kbfs_status"

StatusFileName is the name of the KBFS status file -- it can be reached anywhere within a top-level folder or inside the Keybase root

View Source
const SyncFromServerFileName = ".kbfs_sync_from_server"

SyncFromServerFileName is the name of the KBFS sync-from-server file -- it can be reached anywhere within a top-level folder.

View Source
const UnstageFileName = ".kbfs_unstage"

UnstageFileName is the name of the KBFS unstaging file -- it can be reached anywhere within a top-level folder.

Variables

This section is empty.

Functions

func FilterTLFEarlyExitError

func FilterTLFEarlyExitError(ctx context.Context, err error, log logger.Logger, name libkbfs.CanonicalTlfName) (
	exitEarly bool, retErr error)

FilterTLFEarlyExitError decides whether an error received while trying to create a TLF should result in showing the user an empty folder (exitEarly == true), or not.

func GetEncodedErrors

func GetEncodedErrors(config libkbfs.Config) func(context.Context) ([]byte, time.Time, error)

GetEncodedErrors gets the list of encoded errors in a format suitable for error file.

func GetEncodedFolderStatus

func GetEncodedFolderStatus(ctx context.Context, config libkbfs.Config,
	folderBranch libkbfs.FolderBranch) (
	data []byte, t time.Time, err error)

GetEncodedFolderStatus returns serialized JSON containing status information for a folder

func GetEncodedMetrics

func GetEncodedMetrics(config libkbfs.Config) func(context.Context) ([]byte, time.Time, error)

GetEncodedMetrics returns metrics encoded as bytes for metrics file.

func GetEncodedStatus

func GetEncodedStatus(ctx context.Context, config libkbfs.Config) (
	data []byte, t time.Time, err error)

GetEncodedStatus returns serialized JSON containing top-level KBFS status information

func GetEncodedTlfEditHistory

func GetEncodedTlfEditHistory(ctx context.Context, config libkbfs.Config,
	folderBranch libkbfs.FolderBranch) (
	data []byte, t time.Time, err error)

GetEncodedTlfEditHistory returns serialized JSON containing the file edit history for a folder.

func IsSupportedProfileName

func IsSupportedProfileName(name string) bool

IsSupportedProfileName matches a string against allowed profile names.

func PrettyJSON

func PrettyJSON(value interface{}) ([]byte, error)

PrettyJSON marshals a value to human-readable JSON.

func ProfileGet

func ProfileGet(name string) func(context.Context) ([]byte, time.Time, error)

ProfileGet gets the relevant read function for the profile or nil if it doesn't exist.

func TimeEqual

func TimeEqual(a, b time.Time) bool

TimeEqual compares two filesystem-related timestamps.

On platforms that don't use nanosecond-accurate timestamps in their filesystem APIs, it truncates the timestamps to make them comparable.

func UnstageForTesting

func UnstageForTesting(ctx context.Context, log logger.Logger,
	config libkbfs.Config, fb libkbfs.FolderBranch,
	data []byte) (int, error)

UnstageForTesting unstages all unmerged commits and fast-forwards to the current master, if the given data is non-empty. If the given data is empty, it does nothing.

This should only be needed if there is a bug in automatic conflict resolution.

If the given data begins with the bytes "async", the unstaging is done asynchronously, i.e. this function returns immediately and the unstaging happens in the background. (Other subsequent IO operations may be blocked, though.) You can figure out when the unstage succeeds by consulting .kbfs_status.

Types

type CtxAppIDType

type CtxAppIDType int

CtxAppIDType is the type used for the app ID context tag

const (
	// CtxAppIDKey is the context app id
	CtxAppIDKey CtxAppIDType = iota
)

type Error

type Error struct {
	Code    int
	Message string
}

Error defines errors with codes

func InitError

func InitError(message string) *Error

InitError is for initialization errors

func MountError

func MountError(message string) *Error

MountError is for mount errors

type FSNotifications

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

FSNotifications processes notifications (arbitrary functions, usually triggered by libkbfs) and lets other objects block on them, usually for testing.

func NewFSNotifications

func NewFSNotifications(log logger.Logger) *FSNotifications

NewFSNotifications creates a new FSNotifications object.

func (*FSNotifications) LaunchProcessor

func (f *FSNotifications) LaunchProcessor(ctx context.Context)

LaunchProcessor launches the notification processor.

func (*FSNotifications) QueueNotification

func (f *FSNotifications) QueueNotification(fn func())

QueueNotification queues a notification, which must be goroutine-safe.

func (*FSNotifications) Wait

func (f *FSNotifications) Wait()

Wait waits until all current notifications are done.

type JSONReportedError

type JSONReportedError struct {
	Time  time.Time
	Error string
	Stack []goerrors.StackFrame
}

JSONReportedError stringifies the reported error before marshalling

type JournalAction

type JournalAction int

JournalAction enumerates all the possible actions to take on a TLF's journal.

const (
	// JournalEnable is to turn the journal on.
	JournalEnable JournalAction = iota
	// JournalFlush is to flush the journal.
	JournalFlush
	// JournalPauseBackgroundWork is to pause journal background
	// work.
	JournalPauseBackgroundWork
	// JournalResumeBackgroundWork is to resume journal background
	// work.
	JournalResumeBackgroundWork
	// JournalDisable is to disable the journal.
	JournalDisable
	// JournalEnableAuto is to turn on journals for all TLFs, persistently.
	JournalEnableAuto
	// JournalDisableAuto is to turn off automatic journaling for new TLFs.
	JournalDisableAuto
)

func (JournalAction) Execute

func (a JournalAction) Execute(
	ctx context.Context, jServer *libkbfs.JournalServer,
	tlfID tlf.ID) error

Execute performs the action on the given JournalServer for the given TLF.

func (JournalAction) String

func (a JournalAction) String() string

type RemoteStatus

type RemoteStatus struct {
	sync.Mutex
	// contains filtered or unexported fields
}

RemoteStatus is for maintaining status of various remote connections like keybase service and md-server.

func (*RemoteStatus) ExtraFileName

func (r *RemoteStatus) ExtraFileName() string

ExtraFileName returns the extra file name or an empty string for none.

func (*RemoteStatus) ExtraFileNameAndSize

func (r *RemoteStatus) ExtraFileNameAndSize() (string, int64)

ExtraFileNameAndSize returns the extra file name or an empty string for none and the size of the extra file.

func (*RemoteStatus) Init

Init a RemoteStatus and register it with libkbfs.

func (*RemoteStatus) NewSpecialReadFunc

func (r *RemoteStatus) NewSpecialReadFunc(ctx context.Context) ([]byte, time.Time, error)

NewSpecialReadFunc implements a special read file that contains human readable current status.

type RemoteStatusUpdater

type RemoteStatusUpdater interface {
	// UserChanged is called when the kbfs user is changed.
	// Either oldName or newName, or both may be empty.
	UserChanged(ctx context.Context, oldName, newName libkb.NormalizedUsername)
}

RemoteStatusUpdater has callbacks that will be called from libfs when kbfs status changes in interesting ways.

type TlfDoesNotExist

type TlfDoesNotExist struct{}

TlfDoesNotExist is a shortcut error for the cases a TLF does not exist and an early successful exit via FilterTLFEarlyExitError is wished.

func (TlfDoesNotExist) Error

func (TlfDoesNotExist) Error() string

Error - implement error interface.

Jump to

Keyboard shortcuts

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