xattrs

package
v2.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OcisPrefix    string = "user.ocis."
	ParentidAttr  string = OcisPrefix + "parentid"
	OwnerIDAttr   string = OcisPrefix + "owner.id"
	OwnerIDPAttr  string = OcisPrefix + "owner.idp"
	OwnerTypeAttr string = OcisPrefix + "owner.type"
	// the base name of the node
	// updated when the file is renamed or moved
	NameAttr string = OcisPrefix + "name"

	BlobIDAttr   string = OcisPrefix + "blobid"
	BlobsizeAttr string = OcisPrefix + "blobsize"

	// grantPrefix is the prefix for sharing related extended attributes
	GrantPrefix         string = OcisPrefix + "grant."
	GrantUserAcePrefix  string = OcisPrefix + "grant." + UserAcePrefix
	GrantGroupAcePrefix string = OcisPrefix + "grant." + GroupAcePrefix
	MetadataPrefix      string = OcisPrefix + "md."

	// favorite flag, per user
	FavPrefix string = OcisPrefix + "fav."

	// a temporary etag for a folder that is removed when the mtime propagation happens
	TmpEtagAttr     string = OcisPrefix + "tmp.etag"
	ReferenceAttr   string = OcisPrefix + "cs3.ref"      // arbitrary metadata
	ChecksumPrefix  string = OcisPrefix + "cs."          // followed by the algorithm, eg. ocis.cs.sha1
	TrashOriginAttr string = OcisPrefix + "trash.origin" // trash origin

	// we use a single attribute to enable or disable propagation of both: synctime and treesize
	// The propagation attribute is set to '1' at the top of the (sub)tree. Propagation will stop at
	// that node.
	PropagationAttr string = OcisPrefix + "propagation"

	// the tree modification time of the tree below this node,
	// propagated when synctime_accounting is true and
	// user.ocis.propagation=1 is set
	// stored as a readable time.RFC3339Nano
	TreeMTimeAttr string = OcisPrefix + "tmtime"

	// the deletion/disabled time of a space or node
	// used to mark space roots as disabled
	// stored as a readable time.RFC3339Nano
	DTimeAttr string = OcisPrefix + "dtime"

	// the size of the tree below this node,
	// propagated when treesize_accounting is true and
	// user.ocis.propagation=1 is set
	// stored as uint64, little endian
	TreesizeAttr string = OcisPrefix + "treesize"

	// the quota for the storage space / tree, regardless who accesses it
	QuotaAttr string = OcisPrefix + "quota"

	// the name given to a storage space. It should not contain any semantics as its only purpose is to be read.
	SpaceNameAttr        string = OcisPrefix + "space.name"
	SpaceTypeAttr        string = OcisPrefix + "space.type"
	SpaceDescriptionAttr string = OcisPrefix + "space.description"
	SpaceReadmeAttr      string = OcisPrefix + "space.readme"
	SpaceImageAttr       string = OcisPrefix + "space.image"
	SpaceAliasAttr       string = OcisPrefix + "space.alias"

	UserAcePrefix  string = "u:"
	GroupAcePrefix string = "g:"
)

Declare a list of xattr keys TODO the below comment is currently copied from the owncloud driver, revisit Currently,extended file attributes have four separated namespaces (user, trusted, security and system) followed by a dot. A non root user can only manipulate the user. namespace, which is what we will use to store ownCloud specific metadata. To prevent name collisions with other apps We are going to introduce a sub namespace "user.ocis."

Variables

This section is empty.

Functions

func All

func All(filePath string) (attribs map[string]string, err error)

All reads all extended attributes for a node, protected by a shared file lock

func CopyMetadata

func CopyMetadata(src, target string, filter func(attributeName string) bool) (err error)

CopyMetadata copies all extended attributes from source to target. The optional filter function can be used to filter by attribute name, e.g. by checking a prefix For the source file, a shared lock is acquired. For the target, an exclusive write lock is acquired.

func CopyMetadataWithSourceLock added in v2.12.0

func CopyMetadataWithSourceLock(src, target string, filter func(attributeName string) bool, readLock *flock.Flock) (err error)

CopyMetadataWithSourceLock copies all extended attributes from source to target. The optional filter function can be used to filter by attribute name, e.g. by checking a prefix For the source file, a shared lock is acquired. For the target, an exclusive write lock is acquired.

func Get

func Get(filePath, key string) (string, error)

Get an extended attribute value for the given key No file locking is involved here as reading a single xattr is considered to be atomic.

func GetInt64

func GetInt64(filePath, key string) (int64, error)

GetInt64 reads a string as int64 from the xattrs

func IsAttrUnset

func IsAttrUnset(err error) bool

IsAttrUnset checks the xattr.ENOATTR from the xattr package which redifines it as ENODATA on platforms that do not natively support it (eg. linux) see https://github.com/pkg/xattr/blob/8725d4ccc0fcef59c8d9f0eaf606b3c6f962467a/xattr_linux.go#L19-L22

func IsNotExist

func IsNotExist(err error) bool

IsNotExist checks if there is a os not exists error buried inside the xattr error, as we cannot just use os.IsNotExist().

func List added in v2.11.0

func List(filePath string) (attribs []string, err error)

List retrieves a list of names of extended attributes associated with the given path in the file system.

func ReferenceFromAttr

func ReferenceFromAttr(b []byte) (*provider.Reference, error)

ReferenceFromAttr returns a CS3 reference from xattr of a node. Supported formats are: "cs3:storageid/nodeid"

func Remove

func Remove(filePath string, key string) (err error)

Remove an extended attribute key

func Set

func Set(filePath string, key string, val string) (err error)

Set an extended attribute key to the given value

func SetMultiple

func SetMultiple(filePath string, attribs map[string]string) (err error)

SetMultiple allows setting multiple key value pairs at once the changes are protected with an file lock If the file lock can not be acquired the function returns a lock error.

func SetMultipleWithLock added in v2.12.0

func SetMultipleWithLock(filePath string, attribs map[string]string, fileLock *flock.Flock) (err error)

SetMultipleWithLock allows setting multiple key value pairs at once with an existing lock

func SetWithLock added in v2.12.0

func SetWithLock(filePath string, key string, val string, fileLock *flock.Flock) (err error)

SetWithLock an extended attribute key to the given value with an existing lock

Types

This section is empty.

Jump to

Keyboard shortcuts

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