rgw

package
v1.0.1-0...-e84a606 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package rgw contains a set of wrappers around Ceph's librgw API.

Index

Constants

View Source
const (
	// ErrNotConnected may be returned when client is not connected
	// to a cluster.
	ErrNotConnected = rgwError(-C.ENOTCONN)
)

Variables

View Source
var (
	// ErrEmptyArgument may be returned if a function argument is passed
	// a zero-length slice or map.
	ErrEmptyArgument = errors.New("Argument must contain at least one item")
)

Functions

func ShutdownRGW

func ShutdownRGW(rgw *RGW)

ShutdownRGW shutdown a RGW instance

Implements:

void librgw_shutdown(librgw_t rgw)

func Version

func Version() (int, int, int)

Version get rgwfile version

Implements:

void rgwfile_version(int *major, int *minor, int *extra)

Types

type AttrMask

type AttrMask uint32

AttrMask specifies which part(s) of attrs is/are concerned

const (
	// AttrMode mode is concerned
	AttrMode AttrMask = 1
	// AttrUid uid is concerned
	AttrUid AttrMask = 2
	// AttrGid gid is concerned
	AttrGid AttrMask = 4
	// AttrMtime mtime is concerned
	AttrMtime AttrMask = 8
	// AttrAtime atime is concerned
	AttrAtime AttrMask = 16
	// AttrSize size is concerned
	AttrSize AttrMask = 32
	// AttrCtime ctime is concerned
	AttrCtime AttrMask = 64
)

type CloseFlag

type CloseFlag uint32

CloseFlag is used to control behavior of Close()

const (
	// CloseFlagNone keep the default behavior of Close()
	CloseFlagNone CloseFlag = 0
	// CloseFlagRele also decreases reference count of related FileHandle
	CloseFlagRele CloseFlag = 1
)

type CommitFlag

type CommitFlag uint32

CommitFlag is used to control behavior of Commit()

const (
	// CommitFlagNone keep the default behavior of Commit()
	CommitFlagNone CommitFlag = 0
)

type CreateFlag

type CreateFlag uint32

CreateFlag is used to control behavor of Create()

const (
	// CreateFlagNone keep the default behavior of Create()
	CreateFlagNone CreateFlag = 0
)

type FS

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

FS represents a rgw fs

FS exports ceph's rgw_fs from include/rados/rgw_file.h

func (*FS) Close

func (fs *FS) Close(fh *FileHandle, flags CloseFlag) error

Close file

Implements:

int rgw_close(rgw_fs *fs, rgw_file_handle *fh,
              uint32_t flags)

func (*FS) Commit

func (fs *FS) Commit(fh *FileHandle, offset, length uint64, flags CommitFlag) error

Commit nfs commit operation

Implements:

int rgw_commit(struct rgw_fs *rgw_fs, struct rgw_file_handle *fh,
            uint64_t offset, uint64_t length, uint32_t flags)

func (*FS) Create

func (fs *FS) Create(parentHdl *FileHandle, name string, mask AttrMask,
	posixFlags uint32, flags CreateFlag) (
	*FileHandle, *syscall.Stat_t, error)

Create file

Implements:

int rgw_create(rgw_fs *fs, rgw_file_handle *parent_fh,
               const char *name, stat *st, uint32_t mask,
               rgw_file_handle **fh, uint32_t posix_flags,
               uint32_t flags)

func (*FS) Fsync

func (fs *FS) Fsync(fh *FileHandle, flags FsyncFlag) error

Fsync sync written data. NOTE: Actually, do nothing

Implements:

int rgw_fsync(rgw_fs *fs, rgw_file_handle *fh,
              uint32_t flags)

func (*FS) GetAttr

func (fs *FS) GetAttr(fh *FileHandle, flags GetAttrFlag) (*syscall.Stat_t, error)

GetAttr gets unix attributes for object

Implements:

int rgw_getattr(rgw_fs *fs,
                rgw_file_handle *fh, stat *st,
                uint32_t flags)

func (*FS) GetRootFileHandle

func (fs *FS) GetRootFileHandle() *FileHandle

GetRootFileHandle get the root file handle

func (*FS) Lookup

func (fs *FS) Lookup(parentHdl *FileHandle, path string, stMask AttrMask,
	flags LookupFlag) (*FileHandle, *syscall.Stat_t, error)

Lookup object by name (POSIX style)

Implements:

int rgw_lookup(rgw_fs *fs,
               rgw_file_handle *parent_fh, const char *path,
               rgw_file_handle **fh, stat* st, uint32_t st_mask,
               uint32_t flags)

func (*FS) Mkdir

func (fs *FS) Mkdir(parentHdl *FileHandle, name string, mask AttrMask, flags MkdirFlag) (
	*FileHandle, *syscall.Stat_t, error)

Mkdir creates a new directory

Implements:

int rgw_mkdir(rgw_fs *fs,
              rgw_file_handle *parent_fh,
              const char *name, stat *st, uint32_t mask,
              rgw_file_handle **fh, uint32_t flags)

func (*FS) Mount

func (fs *FS) Mount(rgw *RGW, uid, key, secret string, flags MountFlag) error

Mount the filesystem

Implements:

int rgw_mount(librgw_t rgw, const char *uid, const char *key,
            const char *secret, rgw_fs **fs, uint32_t flags)

func (*FS) Open

func (fs *FS) Open(fh *FileHandle, posixFlags uint32, flags OpenFlag) error

Open file

Implements:

int rgw_open(struct rgw_fs *rgw_fs,
          struct rgw_file_handle *fh, uint32_t posix_flags, uint32_t flags)

func (*FS) Read

func (fs *FS) Read(fh *FileHandle, offset, length uint64, buffer []byte,
	flags ReadFlag) (bytes_read uint64, err error)

Read data from file

Implements:

int rgw_read(rgw_fs *fs,
             rgw_file_handle *fh, uint64_t offset,
             size_t length, size_t *bytes_read, void *buffer,
             uint32_t flags)

func (*FS) ReadDir

func (fs *FS) ReadDir(parentHdl *FileHandle, cb ReadDirCallback, offset uint64, flags ReadDirFlag) (uint64, bool, error)

ReadDir read directory content

Implements:

int rgw_readdir(struct rgw_fs *rgw_fs,
              struct rgw_file_handle *parent_fh, uint64_t *offset,
              rgw_readdir_cb rcb, void *cb_arg, bool *eof,
              uint32_t flags)

func (*FS) Rename

func (fs *FS) Rename(oldDirHdl *FileHandle, oldName string,
	newDirHdl *FileHandle, newName string, flags RenameFlag) error

Rename object

Implements:

int rgw_rename(rgw_fs *fs,
               rgw_file_handle *olddir, const char* old_name,
               rgw_file_handle *newdir, const char* new_name,
               uint32_t flags)

func (*FS) SetAttr

func (fs *FS) SetAttr(fh *FileHandle, stat *syscall.Stat_t, mask AttrMask, flags SetAttrFlag) error

SetAttr sets unix attributes for object

Implements:

int rgw_setattr(rgw_fs *fs, rgw_file_handle *fh, stat *st,
                uint32_t mask, uint32_t flags)

func (*FS) StatFS

func (fs *FS) StatFS(pFH *FileHandle, flags StatFSFlag) (*StatVFS, error)

StatFS returns file system wide statistics.

Implements:

int rgw_statfs(rgw_fs *fs, rgw_file_handle *parent_fh,
               rgw_statvfs *vfs_st, uint32_t flags)

func (*FS) Truncate

func (fs *FS) Truncate(fh *FileHandle, size uint64, flags TruncFlag) error

Truncate file. Actually, do nothing

Implements:

int rgw_truncate(rgw_fs *fs, rgw_file_handle *fh, uint64_t size, uint32_t flags)

func (*FS) Umount

func (fs *FS) Umount(flags UmountFlag) error

Umount the file system.

Implements:

int rgw_umount(rgw_fs *fs, uint32_t flags)
func (fs *FS) Unlink(parentHdl *FileHandle, path string, flags UnlinkFlag) error

Unlink remove file or directory

Implements:

int rgw_unlink(rgw_fs *fs,
               rgw_file_handle *parent_fh, const char* path,
               uint32_t flags)

func (*FS) Write

func (fs *FS) Write(fh *FileHandle, buffer []byte, offset uint64, length uint64,
	flags uint32) (bytesWritten uint, err error)

Write data to file

Implements:

int rgw_write(rgw_fs *fs,
              rgw_file_handle *fh, uint64_t offset,
              size_t length, size_t *bytes_written, void *buffer,
              uint32_t flags)

type FileHandle

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

FileHandle represents a file/dir

struct rgw_file_handle

type FsyncFlag

type FsyncFlag uint32

FsyncFlag is used to control behavior of Fsync()

const (
	// FsyncFlagNone keep the default behavior of Fsync()
	FsyncFlagNone FsyncFlag = 0
)

type GetAttrFlag

type GetAttrFlag uint32

GetAttrFlag is used to control behavior of GetAttr()

const (
	// GetAttrFlagNone keep the default behavior of GetAttr()
	GetAttrFlagNone GetAttrFlag = 0
)

type LookupFlag

type LookupFlag uint32

LookupFlag is used to control behavor of Lookup()

const (
	// LookupFlagNone keep the default behavior of Lookup()
	LookupFlagNone LookupFlag = 0
	// LookupFlagCreate create if not exist
	LookupFlagCreate LookupFlag = 1
	// LookupFlagRCB readdir callback hint
	LookupFlagRCB LookupFlag = 2
	// LookupFlagDir FileHandle type is dir
	LookupFlagDir LookupFlag = 4
	// LookupFlagFile FileHandle type is file
	LookupFlagFile LookupFlag = 8
	// LookupTypeFlags FileHandle type is file or dir
	LookupTypeFlags LookupFlag = LookupFlagDir | LookupFlagFile
)

type MkdirFlag

type MkdirFlag uint32

MkdirFlag is used to control behavor of Mkdir()

const (
	// MkdirFlagNone keep the default behavior of Mkdir()
	MkdirFlagNone MkdirFlag = 0
)

type MountFlag

type MountFlag uint32

MountFlag is used to control behavior of Mount()

const (
	// MountFlagNone keep the default behavior of Mount()
	MountFlagNone MountFlag = 0
)

type OpenFlag

type OpenFlag uint32

OpenFlag is used to control behavior of Open()

const (
	// OpenFlagNone keep the default behavior of Open()
	OpenFlagNone OpenFlag = 0
	// OpenFlagCreate create if not exist
	OpenFlagCreate OpenFlag = 1
	// OpenFlagV3 ops have v3 semantics
	OpenFlagV3 OpenFlag = 2
	// OpenFlagStateless alias of OpenFlagV3
	OpenFlagStateless OpenFlag = 2
)

type RGW

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

RGW represents a librgw handle

typedef void* librgw_t;

func CreateRGW

func CreateRGW(argv []string) (*RGW, error)

CreateRGW create a RGW instance

type ReadDirCallback

type ReadDirCallback interface {
	Callback(name string, st *syscall.Stat_t, mask AttrMask, flags uint32, offset uint64) bool
}

ReadDirCallback will be applied to each dentry when ReadDir() is called

type ReadDirFlag

type ReadDirFlag uint32

ReadDirFlag is used to control behavor of ReadDir()

const (
	// ReadDirFlagNone keep the default behavior of ReadDir()
	ReadDirFlagNone ReadDirFlag = 0
	// ReadDirFlagDotDot send dot names
	ReadDirFlagDotDot ReadDirFlag = 1
)

type ReadFlag

type ReadFlag uint32

ReadFlag is used to control behavior of Read()

const (
	// ReadFlagNone keep the default behavior of Read()
	ReadFlagNone ReadFlag = 0
)

type RenameFlag

type RenameFlag uint32

RenameFlag is used to control behavior of Rename()

const (
	// RenameFlagNone keep the default behavior of Rename()
	RenameFlagNone RenameFlag = 0
)

type SetAttrFlag

type SetAttrFlag uint32

SetAttrFlag is used to control behavior of SetAttr()

const (
	// SetAttrFlagNone keep the default behavior of SetAttr()
	SetAttrFlagNone SetAttrFlag = 0
)

type StatFSFlag

type StatFSFlag uint32

StatFSFlag is used to control behavior of StatFS()

const (
	// StatFSFlagNone keep the default behavior of StatFS()
	StatFSFlagNone StatFSFlag = 0
)

type StatVFS

type StatVFS struct {
	// Bsize reports the file system's block size.
	Bsize int64
	// Fragment reports the file system's fragment size.
	Frsize int64
	// Blocks reports the number of blocks in the file system.
	Blocks uint64
	// Bfree reports the number of free blocks.
	Bfree uint64
	// Bavail reports the number of free blocks for unprivileged users.
	Bavail uint64
	// Files reports the number of inodes in the file system.
	Files uint64
	// Ffree reports the number of free indoes.
	Ffree uint64
	// Favail reports the number of free indoes for unprivileged users.
	Favail uint64
	// Fsid reports the file system ID number.
	Fsid [2]int64
	// Flag reports the file system mount flags.
	Flag int64
	// Namemax reports the maximum file name length.
	Namemax int64
}

StatVFS instances are returned from the StatFS call. It reports file-system wide statistics.

type TruncFlag

type TruncFlag uint32

TruncFlag is used to control behavior of Truncate()

const (
	// TruncFlagNone keep the default behavior of Truncate()
	TruncFlagNone TruncFlag = 0
)

type UmountFlag

type UmountFlag uint32

UmountFlag is used to control behavior of Umount()

const (
	// UmountFlagNone keep the default behavior of Umount()
	UmountFlagNone UmountFlag = 0
)

type UnlinkFlag

type UnlinkFlag uint32

UnlinkFlag is used to control behavior of Unlink()

const (
	// UnlinkFlagNone keep the default behavior of Unlink()
	UnlinkFlagNone UnlinkFlag = 0
)

type WriteFlag

type WriteFlag uint32

WriteFlag is used to control behavor of Write()

const (
	// WriteFlagNone keep the default behavior of Write()
	WriteFlagNone WriteFlag = 0
)

Jump to

Keyboard shortcuts

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